-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add module with tests and gh workflow (#20)
* Add module with tests and gh workflow Signed-off-by: David Kornel <[email protected]>
- Loading branch information
Showing
7 changed files
with
286 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?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> | ||
|
||
<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> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.platform</groupId> | ||
<artifactId>junit-platform-commons</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.platform</groupId> | ||
<artifactId>junit-platform-launcher</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.platform</groupId> | ||
<artifactId>junit-platform-engine</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<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>integration</id> | ||
<properties> | ||
<it.skip>false</it.skip> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
63 changes: 63 additions & 0 deletions
63
test-frame-test/src/test/java/io/skodjob/testframe/test/integration/ResourceManagerIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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.annotations.TestVisualSeparator; | ||
import io.skodjob.testframe.clients.KubeClusterException; | ||
import io.skodjob.testframe.resources.ResourceManager; | ||
import org.junit.jupiter.api.AfterAll; | ||
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; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
@io.skodjob.testframe.annotations.ResourceManager | ||
@TestVisualSeparator | ||
@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()); | ||
} | ||
|
||
@AfterAll | ||
void afterAll() { | ||
assertNull(ResourceManager.getKubeClient().getClient().namespaces().withName("test2").get()); | ||
assertNull(ResourceManager.getKubeClient().getClient().namespaces().withName("test3").get()); | ||
} | ||
|
||
@Test | ||
void createResource() { | ||
ResourceManager.getInstance().createResourceWithWait( | ||
new NamespaceBuilder().withNewMetadata().withName("test3").endMetadata().build()); | ||
} | ||
|
||
@Test | ||
void testKubeClientNamespacesExists() { | ||
assertNotNull(ResourceManager.getKubeClient().getClient().namespaces().withName("test").get()); | ||
assertNotNull(ResourceManager.getKubeClient().getClient().namespaces().withName("test2").get()); | ||
assertNull(ResourceManager.getKubeClient().getClient().namespaces().withName("test3").get()); | ||
} | ||
|
||
@Test | ||
void testKubeCmdClientNamespacesExists() { | ||
assertNotNull(ResourceManager.getKubeCmdClient().get("namespace", "test")); | ||
assertNotNull(ResourceManager.getKubeCmdClient().get("namespace", "test2")); | ||
assertThrows(KubeClusterException.class, () -> ResourceManager.getKubeCmdClient().get("namespace", "test3")); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
test-frame-test/src/test/java/io/skodjob/testframe/test/unit/UnitTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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; | ||
|
||
//TODO Implement mock kube to be able to work with RM | ||
@EnableKubernetesMockClient(crud = true) | ||
public class UnitTests { | ||
private KubernetesClient kubernetesClient; | ||
private KubernetesMockServer server; | ||
|
||
@Test | ||
void tmpTest() { | ||
System.out.println("Placeholder for test"); | ||
} | ||
} |