Skip to content

Commit

Permalink
Excavator: Switch to JUnit 5 to parallelize tests and speed up CI
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot committed Nov 7, 2021
1 parent 465d592 commit 7270693
Show file tree
Hide file tree
Showing 61 changed files with 139 additions and 107 deletions.
8 changes: 8 additions & 0 deletions docker-compose-rule-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ dependencies {
testImplementation 'com.github.tomakehurst:wiremock'

integrationTestCompile project.sourceSets.test.output
integrationTestImplementation 'org.junit.jupiter:junit-jupiter'
integrationTestRuntimeOnly 'org.junit.vintage:junit-vintage-engine', {
because 'allows JUnit 3 and JUnit 4 tests to run'
}
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine', {
because 'allows JUnit 3 and JUnit 4 tests to run'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.palantir.docker.compose.logging.DoNothingLogCollector;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class AggressiveShutdownStrategyIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.HashSet;
import java.util.Set;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class AggressiveShutdownWithNetworkCleanupStrategyIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

public class DockerComposeManagerNativeHealthcheckIntegrationTest {

private final ExecutorService pool = Executors.newFixedThreadPool(1);
private DockerComposeManager docker = null;

@After
@AfterEach
public void shutdownPool() {
pool.shutdown();
if (docker != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
import com.palantir.docker.compose.connection.waiting.ClusterWait;
import java.io.IOException;
import org.joda.time.Duration;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class DockerComposeManagerUpContainerIntegrationTest {

private static final String SERVICE_NAME = "infinite-netcat-loop";

private DockerComposeManager dockerComposeManager;

@Before
@BeforeEach
public void before() throws Exception {
dockerComposeManager = new DockerComposeManager.Builder()
.shutdownStrategy(AGGRESSIVE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import com.palantir.docker.compose.events.WaitForServicesEvent;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;

@SuppressWarnings("IllegalThrows")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.palantir.docker.compose.connection.waiting.SuccessOrFailure;
import org.apache.commons.lang3.SystemUtils;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class HostNetworkedPortsIntegrationTest {
private static HealthCheck<DockerPort> toBeOpen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.palantir.docker.compose.execution.DockerExecutionException;
import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class RemoveConflictingContainersIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import java.time.Duration;
import org.awaitility.core.ConditionFactory;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ContainerIntegrationTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@

import com.palantir.docker.compose.DockerComposeManager;
import com.palantir.docker.compose.connection.DockerMachine;
import java.io.File;
import java.nio.file.Path;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class EnvironmentVariableIntegrationTest {

@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@TempDir
public File temporaryFolder;

@Test
public void docker_compose_gets_environment_variables_from_docker_machine_and_passes_it_into_a_test_container()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@
import com.palantir.docker.compose.DockerComposeManager;
import java.io.File;
import java.io.IOException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class LoggingIntegrationTest {

@Rule
public TemporaryFolder logFolder = new TemporaryFolder();
@TempDir
public File logFolder;

private DockerComposeManager dockerComposeRule;

@Before
@BeforeEach
public void before() {
dockerComposeRule = new DockerComposeManager.Builder()
.file("src/test/resources/docker-compose.yaml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.TemporaryFolder;

public class ReportingIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.palantir.docker.compose.execution.DockerCompose;
import com.palantir.docker.compose.execution.DockerExecutionException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class AggressiveShutdownStrategyTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.palantir.docker.compose.execution.DockerCompose;
import com.palantir.docker.compose.execution.DockerExecutionException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class AggressiveShutdownWithNetworkCleanupStrategyTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.IOUtils;
import org.joda.time.Duration;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public final class DockerComposeManagerShould {

private static final String IP = "127.0.0.1";
Expand All @@ -91,7 +94,7 @@ public final class DockerComposeManagerShould {
private LogCollector logCollector = mock(LogCollector.class);
private DockerComposeManager dockerComposeManager;

@Before
@BeforeEach
public void before() {
when(machine.getIp()).thenReturn(IP);
dockerComposeManager = defaultBuilder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import org.mockito.Mockito;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class AdditionalEnvironmentValidatorShould {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class DaemonEnvironmentValidatorShould {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class DaemonHostIpResolverShould {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import java.io.File;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.Optional;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class DockerTypeShould {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import java.util.List;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class ProjectNameShould {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class RemoteEnvironmentValidatorShould {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class RemoteHostIpResolverShould {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import com.palantir.docker.compose.execution.Docker;
import com.palantir.docker.compose.execution.DockerCompose;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ContainerCacheShould {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static org.hamcrest.core.Is.is;

import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ContainerNameShould {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.palantir.docker.compose.execution.DockerCompose;
import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class ContainerShould {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class DockerPortFormattingShould {
private final DockerPort dockerPort = new DockerPort("hostname", 1234, 4321);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class LocalBuilderShould {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.hamcrest.core.Is.is;

import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class PortsShould {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;

public class RemoteBuilderShould {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
import com.palantir.docker.compose.connection.Cluster;
import com.palantir.docker.compose.connection.ContainerCache;
import com.palantir.docker.compose.connection.ImmutableCluster;
import java.util.concurrent.TimeUnit;
import org.joda.time.Duration;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.rules.ExpectedException;

public class ClusterWaitShould {
Expand Down Expand Up @@ -59,7 +61,8 @@ public void check_until_a_cluster_is_ready() throws InterruptedException {
verify(clusterHealthCheck, times(2)).isClusterHealthy(cluster);
}

@Test(timeout = 2000L)
@Test
@Timeout(value = 2000L, unit = TimeUnit.MILLISECONDS)
public void timeout_if_the_cluster_is_not_healthy() throws InterruptedException {
when(clusterHealthCheck.isClusterHealthy(cluster)).thenReturn(failure("failure!"));

Expand Down
Loading

0 comments on commit 7270693

Please sign in to comment.