Skip to content

Commit

Permalink
Add module with tests and gh workflow
Browse files Browse the repository at this point in the history
Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys committed Feb 29, 2024
1 parent c259c02 commit f4e98c8
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-
- name: Validate with Maven
env:
MAVEN_OPTS: "-Xmx6144m"
- name: Build
run: mvn --batch-mode install
30 changes: 30 additions & 0 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Verify

on:
pull_request:
branches: [ main ]

jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Cache m2 repo
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1

- name: Verify
run: mvn verify -P integration
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<module>test-frame-common</module>
<module>test-frame-kubernetes</module>
<module>test-frame-openshift</module>
<module>test-frame-test</module>
</modules>

<licenses>
Expand Down
152 changes: 152 additions & 0 deletions test-frame-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.skodjob</groupId>
<artifactId>test-frame</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>

<artifactId>test-frame-test</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<junit.jupiter.version>5.10.2</junit.jupiter.version>
<junit.platform.version>1.10.2</junit.platform.version>
<maven.surefire.version>3.2.2</maven.surefire.version>
<fabric8.version>6.10.0</fabric8.version>

<maven.deploy.skip>true</maven.deploy.skip>
<it.skip>true</it.skip>
</properties>

<dependencies>
<dependency>
<groupId>io.skodjob</groupId>
<artifactId>test-frame-common</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-client</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>generator-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-server-mock</artifactId>
<version>${fabric8.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>${junit.platform.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.platform.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>${junit.platform.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.surefire.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<test>io.skodjob.testframe.test.unit.**</test>
<properties>
<configurationParameters>
junit.jupiter.extensions.autodetection.enabled = true
</configurationParameters>
</properties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.surefire.version}</version>
<executions>
<execution>
<goals>
<goal>verify</goal>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
<configuration>
<skipITs>${it.skip}</skipITs>
<forkCount>0</forkCount>
<includes>
<include>io.skodjob.testframe.test.integration.**</include>
</includes>
<properties>
<configurationParameters>
junit.jupiter.extensions.autodetection.enabled = true
</configurationParameters>
</properties>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>none</id>
<properties>
<it.skip>true</it.skip>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>

<profile>
<id>integration</id>
<properties>
<it.skip>false</it.skip>
</properties>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.test.integration;

import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.skodjob.testframe.resources.ResourceManager;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;

import static org.junit.jupiter.api.Assertions.assertNotNull;

@io.skodjob.testframe.annotations.ResourceManager
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class ResourceManagerIT {

@BeforeAll
void setupAll() {
ResourceManager.getInstance().createResourceWithWait(
new NamespaceBuilder().withNewMetadata().withName("test").endMetadata().build());
}

@BeforeEach
void setupEach() {
ResourceManager.getInstance().createResourceWithWait(
new NamespaceBuilder().withNewMetadata().withName("test2").endMetadata().build());
}

@Test
void test() {
assertNotNull(ResourceManager.getKubeClient().getClient().namespaces().withName("test").get());
assertNotNull(ResourceManager.getKubeClient().getClient().namespaces().withName("test2").get());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.test.unit;

import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import org.junit.jupiter.api.Test;

@EnableKubernetesMockClient(crud = true)
public class UnitTests {
private KubernetesClient kubernetesClient;
private KubernetesMockServer server;

@Test
void tmpTest() {
System.out.println("Placeholder for test");
}
}

0 comments on commit f4e98c8

Please sign in to comment.