From a43d4825415338f73ce489dd6c6a0394c58bef10 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Thu, 10 Oct 2024 14:32:27 +0200 Subject: [PATCH 1/6] feat(build): split ITs by category, parallel CRD generation Also avoid generating CRDs when not needed by default, summarizes test results. Signed-off-by: Chris Laprun --- .github/workflows/build.yml | 37 ++++++ .../fabric8-next-version-schedule.yml | 42 +------ .github/workflows/integration-tests.yml | 20 ++- .github/workflows/pr.yml | 40 +----- .../WorkflowReconcileExecutorTest.java | 7 +- operator-framework/pom.xml | 10 +- pom.xml | 116 +++++++++++++++++- 7 files changed, 179 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..7124d8087d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build + +env: + MAVEN_ARGS: -V -ntp -e + +on: + workflow_call: + +jobs: + integration_tests: + strategy: + matrix: + java: [ 17, 21 ] + kubernetes: [ 'v1.28.14', 'v1.29.9','1.30.5', '1.31.1' ] + it-category: [ 'baseapi', 'dependent', 'workflow' ] + httpclient: [ 'vertx', 'jdk', 'jetty' ] + uses: ./.github/workflows/integration-tests.yml + with: + java-version: ${{ matrix.java }} + kube-version: ${{ matrix.kubernetes }} + it-category: ${{ matrix.it-category }} + http-client: ${{ matrix.httpclient }} + + special_integration_tests: + runs-on: ubuntu-latest + strategy: + matrix: + java: [ 17, 21 ] + steps: + - uses: actions/checkout@v4 + - name: Set up Java and Maven + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{ matrix.java }} + - name: Run Special Integration Tests + run: ./mvnw ${MAVEN_ARGS} -B package -P minimal-watch-timeout-dependent-it --file pom.xml \ No newline at end of file diff --git a/.github/workflows/fabric8-next-version-schedule.yml b/.github/workflows/fabric8-next-version-schedule.yml index b0bc57ea75..64d2042135 100644 --- a/.github/workflows/fabric8-next-version-schedule.yml +++ b/.github/workflows/fabric8-next-version-schedule.yml @@ -23,46 +23,8 @@ jobs: with: distribution: temurin java-version: 17 - cache: 'maven' - name: Run unit tests run: ./mvnw ${MAVEN_ARGS} clean install --file pom.xml - integration_tests: - strategy: - matrix: - java: [ 11, 17 ] - kubernetes: ['v1.28.12', 'v1.29.7','1.30.3', '1.31.0'] - uses: ./.github/workflows/integration-tests.yml - with: - java-version: ${{ matrix.java }} - kube-version: ${{ matrix.kubernetes }} - - httpclient-tests: - strategy: - matrix: - httpclient: [ 'vertx', 'jdk', 'jetty' ] - uses: ./.github/workflows/integration-tests.yml - with: - java-version: 17 - kube-version: 'v1.29.1' - http-client: ${{ matrix.httpclient }} - experimental: true - checkout-ref: 'fabric8-next-version' - - special_integration_tests: - runs-on: ubuntu-latest - strategy: - matrix: - java: [ 11, 17 ] - steps: - - uses: actions/checkout@v4 - with: - ref: 'fabric8-next-version' - - name: Set up Java and Maven - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: ${{ matrix.java }} - cache: 'maven' - - name: Run Special Integration Tests - run: ./mvnw ${MAVEN_ARGS} -B package -P minimal-watch-timeout-dependent-it --file pom.xml \ No newline at end of file + build: + uses: ./.github/workflows/build.yml \ No newline at end of file diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index cb68af25d2..009d760de3 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -21,6 +21,10 @@ on: type: string required: false default: '' + it-category: + type: string + required: false + default: '' jobs: integration_tests: @@ -42,9 +46,17 @@ jobs: - name: Set up Minikube uses: manusa/actions-setup-minikube@v2.12.0 with: - minikube version: v1.33.0 - kubernetes version: ${{ inputs.kube-version }} + minikube version: 'v1.33.0' + kubernetes version: '${{ inputs.kube-version }}' driver: 'docker' github token: ${{ secrets.GITHUB_TOKEN }} - - name: Run integration tests - run: ./mvnw ${MAVEN_ARGS} -B package -P no-unit-tests -Dfabric8-httpclient-impl.name=${{inputs.http-client}} --file pom.xml \ No newline at end of file + - name: "${{inputs.it-category}} integration tests (kube: ${{ inputs.kube-version }} / java: ${{ inputs.java-version }} / client: ${{ inputs.http-client }})" + run: | + if [ -z "${{inputs.it-category}}" ]; then + it_profile="integration-tests" + else + it_profile="integration-tests-${{inputs.it-category}}" + fi + echo "Using profile: ${it_profile}" + ./mvnw ${MAVEN_ARGS} -B install -DskipTests -Pno-apt --file pom.xml + ./mvnw ${MAVEN_ARGS} -B package -T1C -P${it_profile} -Dfabric8-httpclient-impl.name=${{inputs.http-client}} --file pom.xml \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 471cea503e..facd6be13a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -28,41 +28,7 @@ jobs: run: | ./mvnw ${MAVEN_ARGS} spotless:check --file pom.xml - name: Run unit tests - run: ./mvnw ${MAVEN_ARGS} clean install --file pom.xml + run: ./mvnw ${MAVEN_ARGS} clean install -Pno-apt --file pom.xml - integration_tests: - strategy: - matrix: - java: [ 17, 21 ] - kubernetes: [ 'v1.28.12', 'v1.29.7','1.30.3', '1.31.0' ] - uses: ./.github/workflows/integration-tests.yml - with: - java-version: ${{ matrix.java }} - kube-version: ${{ matrix.kubernetes }} - - httpclient-tests: - strategy: - matrix: - httpclient: [ 'vertx', 'jdk', 'jetty' ] - uses: ./.github/workflows/integration-tests.yml - with: - java-version: 17 - kube-version: 'v1.29.1' - http-client: ${{ matrix.httpclient }} - experimental: true - - special_integration_tests: - runs-on: ubuntu-latest - strategy: - matrix: - java: [ 17, 21 ] - steps: - - uses: actions/checkout@v4 - - name: Set up Java and Maven - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: ${{ matrix.java }} - cache: 'maven' - - name: Run Special Integration Tests - run: ./mvnw ${MAVEN_ARGS} -B package -P minimal-watch-timeout-dependent-it --file pom.xml \ No newline at end of file + build: + uses: ./.github/workflows/build.yml \ No newline at end of file diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutorTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutorTest.java index f399655041..c843a1bade 100644 --- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutorTest.java +++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/workflow/WorkflowReconcileExecutorTest.java @@ -6,6 +6,9 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.HasMetadata; @@ -20,6 +23,7 @@ import static org.mockito.Mockito.*; class WorkflowReconcileExecutorTest extends AbstractWorkflowExecutorTest { + private static final Logger log = LoggerFactory.getLogger(WorkflowReconcileExecutorTest.class); @SuppressWarnings("unchecked") Context mockContext = mock(Context.class); @@ -30,7 +34,8 @@ class WorkflowReconcileExecutorTest extends AbstractWorkflowExecutorTest { @BeforeEach @SuppressWarnings("unchecked") - void setup() { + void setup(TestInfo testInfo) { + log.debug("==> Starting test {}", testInfo.getDisplayName()); when(mockContext.getWorkflowExecutorService()).thenReturn(executorService); when(mockContext.eventSourceRetriever()).thenReturn(mock(EventSourceRetriever.class)); } diff --git a/operator-framework/pom.xml b/operator-framework/pom.xml index 172f176c73..455b1268fd 100644 --- a/operator-framework/pom.xml +++ b/operator-framework/pom.xml @@ -57,11 +57,6 @@ compile-testing test - - io.fabric8 - crd-generator-apt - test - io.fabric8 @@ -113,7 +108,10 @@ + + org.apache.maven.plugins + maven-surefire-plugin + - diff --git a/pom.xml b/pom.xml index a89059e155..8d63726674 100644 --- a/pom.xml +++ b/pom.xml @@ -255,6 +255,11 @@ org.apache.maven.plugins maven-compiler-plugin ${maven-compiler-plugin.version} + + + -Aio.fabric8.crd.generator.parallel=true + + org.apache.maven.plugins @@ -275,6 +280,23 @@ org.apache.maven.plugins maven-surefire-plugin ${maven-surefire-plugin.version} + + + plain + + true + + + UNICODE + + + + + me.fabriciorby + maven-surefire-junit5-tree-reporter + 1.3.0 + + org.apache.maven.plugins @@ -349,7 +371,14 @@ - all-tests + integration-tests + + + io.fabric8 + crd-generator-apt + test + + @@ -357,17 +386,26 @@ maven-surefire-plugin - **/*Test.java **/*IT.java - **/*E2E.java + + **/*Test.java + **/*E2E.java + - no-unit-tests + integration-tests-baseapi + + + io.fabric8 + crd-generator-apt + test + + @@ -375,7 +413,61 @@ maven-surefire-plugin - **/*IT.java + io/javaoperatorsdk/operator/baseapi/**/*IT.java + + + **/*Test.java + **/*E2E.java + + + + + + + + integration-tests-dependent + + + io.fabric8 + crd-generator-apt + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + io/javaoperatorsdk/operator/dependent/**/*IT.java + + + **/*Test.java + **/*E2E.java + + + + + + + + integration-tests-workflow + + + io.fabric8 + crd-generator-apt + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + io/javaoperatorsdk/operator/workflow/**/*IT.java **/*Test.java @@ -389,6 +481,13 @@ minimal-watch-timeout-dependent-it + + + io.fabric8 + crd-generator-apt + test + + @@ -410,6 +509,13 @@ end-to-end-tests + + + io.fabric8 + crd-generator-apt + test + + From 31467f8856933a39e6daaf6eb83c8b14cfc7adb0 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Tue, 15 Oct 2024 14:25:03 +0200 Subject: [PATCH 2/6] chore(deps): bump actions-setup-minikube to 2.13.0 Signed-off-by: Chris Laprun --- .github/workflows/e2e-test.yml | 2 +- .github/workflows/integration-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 6e00ecfd12..df2d6ca584 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Minikube-Kubernetes - uses: manusa/actions-setup-minikube@v2.12.0 + uses: manusa/actions-setup-minikube@v2.13.0 with: minikube version: v1.33.0 kubernetes version: v1.31.0 diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 009d760de3..0a382130a1 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -44,7 +44,7 @@ jobs: java-version: ${{ inputs.java-version }} cache: 'maven' - name: Set up Minikube - uses: manusa/actions-setup-minikube@v2.12.0 + uses: manusa/actions-setup-minikube@v2.13.0 with: minikube version: 'v1.33.0' kubernetes version: '${{ inputs.kube-version }}' From e415f6c955873d461a8d03c1f304bd9cbdeccc98 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Tue, 15 Oct 2024 15:12:44 +0200 Subject: [PATCH 3/6] feat: default to use vertx client Signed-off-by: Chris Laprun --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 0a382130a1..519bf0c531 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -12,7 +12,7 @@ on: http-client: type: string required: false - default: 'jdk' + default: 'vertx' experimental: type: boolean required: false From a1a63ad38ff96040167febdbbe4c3988e317dfce Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Tue, 15 Oct 2024 15:14:10 +0200 Subject: [PATCH 4/6] chore(ci): reduce tested combinations, only run client tests on baseapi Signed-off-by: Chris Laprun --- .github/workflows/build.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7124d8087d..67ab977ac3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,18 @@ jobs: java: [ 17, 21 ] kubernetes: [ 'v1.28.14', 'v1.29.9','1.30.5', '1.31.1' ] it-category: [ 'baseapi', 'dependent', 'workflow' ] + uses: ./.github/workflows/integration-tests.yml + with: + java-version: ${{ matrix.java }} + kube-version: ${{ matrix.kubernetes }} + it-category: ${{ matrix.it-category }} + + http_client_tests: + strategy: + matrix: + java: [ 17, 21 ] + kubernetes: [ 'v1.28.14', 'v1.29.9','1.30.5', '1.31.1' ] + it-category: [ 'baseapi' ] httpclient: [ 'vertx', 'jdk', 'jetty' ] uses: ./.github/workflows/integration-tests.yml with: From 4a3cad190a912732b8406715bce5745792d16cd0 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Wed, 16 Oct 2024 17:28:32 +0200 Subject: [PATCH 5/6] fix: do not run tests in parallel Signed-off-by: Chris Laprun --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 519bf0c531..b536cc76e2 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -59,4 +59,4 @@ jobs: fi echo "Using profile: ${it_profile}" ./mvnw ${MAVEN_ARGS} -B install -DskipTests -Pno-apt --file pom.xml - ./mvnw ${MAVEN_ARGS} -B package -T1C -P${it_profile} -Dfabric8-httpclient-impl.name=${{inputs.http-client}} --file pom.xml \ No newline at end of file + ./mvnw ${MAVEN_ARGS} -B package -P${it_profile} -Dfabric8-httpclient-impl.name=${{inputs.http-client}} --file pom.xml \ No newline at end of file From 6adf7bea0e411ec1d3f53cfc78d3fb940aaec7b0 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Thu, 17 Oct 2024 09:35:56 +0200 Subject: [PATCH 6/6] fix: increase deletion timeout Signed-off-by: Chris Laprun --- .github/workflows/integration-tests.yml | 4 ++-- .../clusterscopedresource/ClusterScopedResourceIT.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index b536cc76e2..e36add39c2 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -58,5 +58,5 @@ jobs: it_profile="integration-tests-${{inputs.it-category}}" fi echo "Using profile: ${it_profile}" - ./mvnw ${MAVEN_ARGS} -B install -DskipTests -Pno-apt --file pom.xml - ./mvnw ${MAVEN_ARGS} -B package -P${it_profile} -Dfabric8-httpclient-impl.name=${{inputs.http-client}} --file pom.xml \ No newline at end of file + ./mvnw ${MAVEN_ARGS} -T1C -B install -DskipTests -Pno-apt --file pom.xml + ./mvnw ${MAVEN_ARGS} -T1C -B package -P${it_profile} -Dfabric8-httpclient-impl.name=${{inputs.http-client}} --file pom.xml \ No newline at end of file diff --git a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/clusterscopedresource/ClusterScopedResourceIT.java b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/clusterscopedresource/ClusterScopedResourceIT.java index c17cf632c2..e923084425 100644 --- a/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/clusterscopedresource/ClusterScopedResourceIT.java +++ b/operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/clusterscopedresource/ClusterScopedResourceIT.java @@ -9,6 +9,7 @@ import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; import io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension; +import static io.javaoperatorsdk.operator.IntegrationTestConstants.GARBAGE_COLLECTION_TIMEOUT_SECONDS; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -46,7 +47,7 @@ void crudOperationOnClusterScopedCustomResource() { }); operator.delete(resource); - await().atMost(Duration.ofSeconds(30)) + await().atMost(Duration.ofSeconds(GARBAGE_COLLECTION_TIMEOUT_SECONDS)) .untilAsserted(() -> assertThat(operator.get(ConfigMap.class, TEST_NAME)).isNull()); }