Skip to content

Commit

Permalink
feat(ci): split integration tests execution by category
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Laprun <claprun@redhat.com>
  • Loading branch information
metacosm committed Oct 10, 2024
1 parent 3dd77c1 commit 407deaf
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 81 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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 ]
uses: ./.github/workflows/integration-tests.yml
with:
java-version: ${{ matrix.java }}
kube-version: ${{ matrix.kubernetes }}
it-category: ${{ matrix.it-category }}

httpclient-tests:
strategy:
matrix:
httpclient: [ 'vertx', 'jdk', 'jetty' ]
uses: ./.github/workflows/integration-tests.yml
with:
java-version: 17
kube-version: 'v1.30.5'
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
41 changes: 2 additions & 39 deletions .github/workflows/fabric8-next-version-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,5 @@ jobs:
- 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
build:
uses: ./.github/workflows/build.yml
15 changes: 12 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ on:
type: string
required: false
default: ''
it-category:
type: string
required: false
default: ''

jobs:
integration_tests:
Expand All @@ -42,9 +46,14 @@ 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
run: |
it_profile="integration-tests"
if [ -z "${{inputs.it-category}}" ]; then
it_profile="integration-tests-${{inputs.it-category}}"
fi
./mvnw ${MAVEN_ARGS} -B package -P${it_profile} -Dfabric8-httpclient-impl.name=${{inputs.http-client}} --file pom.xml
38 changes: 2 additions & 36 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,5 @@ jobs:
- name: Run unit tests
run: ./mvnw ${MAVEN_ARGS} clean install --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
build:
uses: ./.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.concurrent.Executors;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -14,12 +15,16 @@
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource;
import io.javaoperatorsdk.operator.processing.event.EventSourceRetriever;
import io.javaoperatorsdk.operator.sample.simple.TestCustomResource;
import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static io.javaoperatorsdk.operator.processing.dependent.workflow.ExecutionAssert.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

class WorkflowReconcileExecutorTest extends AbstractWorkflowExecutorTest {
private static final Logger log = LoggerFactory.getLogger(WorkflowReconcileExecutorTest.class);

@SuppressWarnings("unchecked")
Context<TestCustomResource> mockContext = mock(Context.class);
Expand All @@ -30,11 +35,12 @@ 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));
}

@Test
void reconcileTopLevelResources() {
var workflow = new WorkflowBuilder<TestCustomResource>()
Expand Down
62 changes: 61 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
</build>
</profile>
<profile>
<id>no-unit-tests</id>
<id>integration-tests</id>
<build>
<plugins>
<plugin>
Expand All @@ -386,6 +386,66 @@
</plugins>
</build>
</profile>
<profile>
<id>integration-tests-baseapi</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>io/javaoperatorsdk/operator/baseapi/**/*IT.java</include>
</includes>
<excludes>
<exclude>**/*Test.java</exclude>
<exclude>**/*E2E.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration-tests-dependent</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>io/javaoperatorsdk/operator/dependent/**/*IT.java</include>
</includes>
<excludes>
<exclude>**/*Test.java</exclude>
<exclude>**/*E2E.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration-tests-workflow</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>io/javaoperatorsdk/operator/workflow/**/*IT.java</include>
</includes>
<excludes>
<exclude>**/*Test.java</exclude>
<exclude>**/*E2E.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- Special category of tests. See usage in source code. -->
<profile>
<id>minimal-watch-timeout-dependent-it</id>
Expand Down

0 comments on commit 407deaf

Please sign in to comment.