diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a01ef1c..47e1e05 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml new file mode 100644 index 0000000..809040e --- /dev/null +++ b/.github/workflows/verify.yaml @@ -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 diff --git a/pom.xml b/pom.xml index 5d63d73..06950dc 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ test-frame-common test-frame-kubernetes test-frame-openshift + test-frame-test diff --git a/test-frame-test/pom.xml b/test-frame-test/pom.xml new file mode 100644 index 0000000..c93a093 --- /dev/null +++ b/test-frame-test/pom.xml @@ -0,0 +1,152 @@ + + + 4.0.0 + + io.skodjob + test-frame + 0.1.0-SNAPSHOT + + + test-frame-test + + + 17 + 17 + UTF-8 + + 5.10.2 + 1.10.2 + 3.2.2 + 6.10.0 + + true + true + + + + + io.skodjob + test-frame-common + + + io.fabric8 + openshift-client + + + io.fabric8 + kubernetes-model + + + io.fabric8 + generator-annotations + + + io.fabric8 + kubernetes-server-mock + ${fabric8.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + + + org.junit.jupiter + junit-jupiter-params + ${junit.jupiter.version} + + + org.junit.platform + junit-platform-commons + ${junit.platform.version} + + + org.junit.platform + junit-platform-launcher + ${junit.platform.version} + + + org.junit.platform + junit-platform-engine + ${junit.platform.version} + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven.surefire.version} + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.version} + + io.skodjob.testframe.test.unit.** + + + junit.jupiter.extensions.autodetection.enabled = true + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven.surefire.version} + + + + verify + integration-test + + + + + ${it.skip} + 0 + + io.skodjob.testframe.test.integration.** + + + + junit.jupiter.extensions.autodetection.enabled = true + + + + + + + + + + none + + true + + + true + + + + + integration + + false + + + + + \ No newline at end of file diff --git a/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/ResourceManagerIT.java b/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/ResourceManagerIT.java new file mode 100644 index 0000000..03267e5 --- /dev/null +++ b/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/ResourceManagerIT.java @@ -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()); + } +} diff --git a/test-frame-test/src/test/java/io/skodjob/testframe/test/unit/UnitTests.java b/test-frame-test/src/test/java/io/skodjob/testframe/test/unit/UnitTests.java new file mode 100644 index 0000000..0fe8e7e --- /dev/null +++ b/test-frame-test/src/test/java/io/skodjob/testframe/test/unit/UnitTests.java @@ -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"); + } +}