Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run all tests against TC Cloud #273

Merged
merged 8 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 54 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,57 @@ on:
- 'revapi.json'
workflow_dispatch: { }
jobs:
build:
name: Build & Verify
check:
name: Linting & Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
- name: Check
id: check
run: mvn -B -DskipTests verify
cloud:
env:
TC_CLOUD_TOKEN: ${{ secrets.TC_CLOUD_TOKEN }}
TC_CLOUD_CONCURRENCY: 4
name: Test (Cloud)
runs-on: ubuntu-latest
steps:
- name: Prepare Testcontainers Cloud agent
if: env.TC_CLOUD_TOKEN != ''
run: |
curl -L -o agent https://app.testcontainers.cloud/download/testcontainers-cloud-agent_linux_x86-64
chmod +x agent
./agent &
./agent wait
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
- name: Build
id: build
run: mvn -B -DskipTests -DskipChecks install
- name: Test
id: test
timeout-minutes: 20
run: >
mvn -B -Pparallel-tests -DforkCount=2C -DskipChecks test
- name: Archive Test Results
uses: actions/upload-artifact@v3
with:
name: test-results
path: target/surefire-reports/
retention-days: 7
local:
name: Test (Local)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -26,15 +75,14 @@ jobs:
cache: 'maven'
- name: Build
id: build
run: mvn -B -DskipTests clean verify
run: mvn -B -DskipTests -DskipChecks install
- name: Test
id: test
timeout-minutes: 20
run: >
mvn -B test
- name: Archive Test Results on Failure
mvn -B -DskipChecks -Plocal-test test
- name: Archive Test Results
uses: actions/upload-artifact@v3
if: failure()
with:
name: test-results
path: target/surefire-reports/
Expand Down
29 changes: 28 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@
<profile>
<id>parallel-tests</id>
<properties>
<forkCount>0.5C</forkCount>
<forkCount>1C</forkCount>
</properties>
<build>
<plugins>
Expand All @@ -560,6 +560,33 @@
<configuration>
<forkCount>${forkCount}</forkCount>
<reuseForks>true</reuseForks>
<properties>
<configurationParameters>junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.config.strategy = fixed
junit.jupiter.execution.parallel.config.fixed.parallelism = 2</configurationParameters>
</properties>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<!--
this profile will run all tests annotated with @SmokeTest. the profile is mainly used to
ensure that we can run basic tests on Windows, macOS, and Linux, thereby ensuring minimal
multi-platform support for development.
-->
<profile>
<id>local-test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<failIfNoTests>false</failIfNoTests>
<groups>local-test</groups>
</configuration>
</plugin>
</plugins>
Expand Down
17 changes: 12 additions & 5 deletions src/test/java/io/zeebe/containers/ZeebeBrokerNodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import io.camunda.zeebe.client.api.response.ProcessInstanceEvent;
import io.camunda.zeebe.model.bpmn.Bpmn;
import io.camunda.zeebe.model.bpmn.BpmnModelInstance;
import io.zeebe.containers.util.TestUtils;
import io.zeebe.containers.util.TestSupport;
import io.zeebe.containers.util.TestcontainersSupport.DisabledIfTestcontainersCloud;
import io.zeebe.containers.util.TopologyAssert;
import java.io.IOException;
import java.net.HttpURLConnection;
Expand All @@ -46,7 +47,8 @@
import org.junit.jupiter.params.provider.MethodSource;
import org.testcontainers.containers.GenericContainer;

class ZeebeBrokerNodeTest {
final class ZeebeBrokerNodeTest {
@SuppressWarnings("unused")
@Timeout(value = 5, unit = TimeUnit.MINUTES)
@ParameterizedTest(name = "{0} should be ready on start")
@MethodSource("nodeProvider")
Expand Down Expand Up @@ -98,6 +100,7 @@ void shouldExposeAllPortsButGateway(
@ParameterizedTest(name = "{0}")
@MethodSource("reuseDataTestCases")
@EnabledOnOs(LINUX)
@DisabledIfTestcontainersCloud
void shouldReuseHostDataOnRestart(
@SuppressWarnings("unused") final String testName,
final BrokerNodeProvider brokerNodeProvider,
Expand All @@ -112,7 +115,7 @@ void shouldReuseHostDataOnRestart(
broker.start();
gateway.start();

try (final ZeebeClient client = ZeebeClientFactory.newZeebeClient(gateway)) {
try (final ZeebeClient client = TestSupport.newZeebeClient(gateway)) {
// deploy a new process, which we can use on restart to assert that the data was correctly
// reused
final DeploymentEvent deployment = deploySampleProcess(client);
Expand Down Expand Up @@ -140,7 +143,7 @@ private static ZeebeBrokerNode<?> provideBrokerWithHostData(
// temporary directory at the end. Note that this is only necessary when not running the tests
// as root
final ZeebeHostData data = new ZeebeHostData(dataDir.toAbsolutePath().toString());
final String runAsUser = TestUtils.getRunAsUser();
final String runAsUser = TestSupport.getRunAsUser();
broker
.withZeebeData(data)
.self()
Expand All @@ -156,7 +159,11 @@ private ProcessInstanceEvent createSampleProcessInstance(final ZeebeClient clien
private DeploymentEvent deploySampleProcess(final ZeebeClient client) {
final BpmnModelInstance sampleProcess =
Bpmn.createExecutableProcess("process").startEvent().endEvent().done();
return client.newDeployCommand().addProcessModel(sampleProcess, "process.bpmn").send().join();
return client
.newDeployResourceCommand()
.addProcessModel(sampleProcess, "process.bpmn")
.send()
.join();
}

private void awaitUntilTopologyIsComplete(final ZeebeClient client) {
Expand Down
29 changes: 0 additions & 29 deletions src/test/java/io/zeebe/containers/ZeebeClientFactory.java

This file was deleted.

5 changes: 3 additions & 2 deletions src/test/java/io/zeebe/containers/ZeebeContainerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.Topology;
import io.zeebe.containers.util.TestSupport;
import java.util.concurrent.TimeUnit;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
Expand All @@ -25,7 +26,7 @@
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
class ZeebeContainerTest {
final class ZeebeContainerTest {
@Container private final ZeebeContainer zeebeContainer = new ZeebeContainer();

@Test
Expand All @@ -35,7 +36,7 @@ void shouldStartWithEmbeddedGatewayByDefault() {
final Topology topology;

// when
try (final ZeebeClient client = ZeebeClientFactory.newZeebeClient(zeebeContainer)) {
try (final ZeebeClient client = TestSupport.newZeebeClient(zeebeContainer)) {
topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
}

Expand Down
19 changes: 16 additions & 3 deletions src/test/java/io/zeebe/containers/ZeebeGatewayContainerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,43 @@
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.BrokerInfo;
import io.camunda.zeebe.client.api.response.Topology;
import io.zeebe.containers.util.TestSupport;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.Network;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
class ZeebeGatewayContainerTest {
@Container private final ZeebeBrokerContainer brokerContainer = new ZeebeBrokerContainer();
final class ZeebeGatewayContainerTest {
private final Network network = Network.newNetwork();

@Container
private final ZeebeBrokerContainer brokerContainer =
new ZeebeBrokerContainer().withNetwork(network);

@Container
private final ZeebeGatewayContainer gatewayContainer =
new ZeebeGatewayContainer()
.withNetwork(network)
.withEnv(
"ZEEBE_GATEWAY_CLUSTER_CONTACTPOINT", brokerContainer.getInternalClusterAddress());

@AfterEach
void afterEach() {
network.close();
}

@Test
void shouldConnectToBroker() {
// given
final Topology topology;

// when
try (final ZeebeClient client = ZeebeClientFactory.newZeebeClient(gatewayContainer)) {
try (final ZeebeClient client = TestSupport.newZeebeClient(gatewayContainer)) {
topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
}

Expand Down
9 changes: 7 additions & 2 deletions src/test/java/io/zeebe/containers/ZeebeHostDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,29 @@
package io.zeebe.containers;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.condition.OS.LINUX;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.InspectContainerResponse;
import com.github.dockerjava.api.command.InspectContainerResponse.Mount;
import com.github.dockerjava.api.model.Volume;
import io.zeebe.containers.util.TestUtils;
import io.zeebe.containers.util.TestSupport;
import io.zeebe.containers.util.TestcontainersSupport.DisabledIfTestcontainersCloud;
import java.nio.file.Path;
import java.util.Objects;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.io.TempDir;
import org.testcontainers.DockerClientFactory;

@EnabledOnOs(LINUX)
@DisabledIfTestcontainersCloud
final class ZeebeHostDataTest {
@Test
void shouldAttachToZeebeContainer(final @TempDir Path dataDir) {
// given
final DockerClient client = DockerClientFactory.lazyClient();
final String runAsUser = TestUtils.getRunAsUser();
final String runAsUser = TestSupport.getRunAsUser();

// when
final InspectContainerResponse response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@
import java.nio.file.Path;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.testcontainers.containers.SocatContainer;
import org.testcontainers.utility.MountableFile;

@Execution(ExecutionMode.CONCURRENT)
final class ContainerArchiveBuilderTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.testcontainers.utility.MountableFile;

@Execution(ExecutionMode.CONCURRENT)
final class ContainerArchiveTest {

@Test
Expand Down
10 changes: 8 additions & 2 deletions src/test/java/io/zeebe/containers/cluster/ZeebeClusterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@
import io.camunda.zeebe.client.api.response.Topology;
import io.zeebe.containers.ZeebeGatewayNode;
import io.zeebe.containers.util.TopologyAssert;
import java.util.Optional;
import org.agrona.CloseHelper;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.Network;

final class ZeebeClusterTest {
private final Network network = Network.newNetwork();
private ZeebeCluster cluster;

@AfterEach
void afterEach() {
Optional.ofNullable(cluster).ifPresent(ZeebeCluster::stop);
CloseHelper.quietCloseAll(cluster, network);
}

@Test
Expand All @@ -42,6 +44,7 @@ void shouldStartSingleNodeCluster() {
.withReplicationFactor(1)
.withPartitionsCount(1)
.withBrokersCount(1)
.withNetwork(network)
.build();

// when
Expand Down Expand Up @@ -71,6 +74,7 @@ void shouldStartClusterWithEmbeddedGateways() {
.withReplicationFactor(2)
.withPartitionsCount(2)
.withBrokersCount(2)
.withNetwork(network)
.build();

// when
Expand Down Expand Up @@ -108,6 +112,7 @@ void shouldStartClusterWithStandaloneGateway() {
.withPartitionsCount(1)
.withBrokersCount(1)
.withGatewaysCount(1)
.withNetwork(network)
.build();

// when
Expand Down Expand Up @@ -139,6 +144,7 @@ void shouldStartClusterWithMixedGateways() {
.withPartitionsCount(1)
.withBrokersCount(1)
.withGatewaysCount(1)
.withNetwork(network)
.build();

// when
Expand Down
Loading