Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez authored Jul 30, 2024
2 parents eb3399c + 4952337 commit 3e63698
Show file tree
Hide file tree
Showing 97 changed files with 420 additions and 252 deletions.
12 changes: 11 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ updates:
schedule:
interval: "weekly"
open-pull-requests-limit: 10
ignore:
- dependency-name: "com.influxdb:influxdb-java-client"
update-types: [ "version-update:semver-major" ]
- package-ecosystem: "gradle"
directory: "/modules/jdbc"
schedule:
Expand Down Expand Up @@ -376,13 +379,20 @@ updates:
update-types: [ "version-update:semver-major" ]
- dependency-name: "com.diffplug.spotless"
update-types: [ "version-update:semver-minor" ]

- dependency-name: "com.hazelcast:hazelcast"
update-types: [ "version-update:semver-minor" ]

# Smoke test
- package-ecosystem: "gradle"
directory: "/smoke-test"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
ignore:
- dependency-name: "ch.qos.logback:logback-classic"
update-types: [ "version-update:semver-minor" ]
- dependency-name: "com.diffplug.spotless"
update-types: [ "version-update:semver-minor" ]

# GitHub Actions
- package-ecosystem: "github-actions"
Expand Down
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- core/src/main/java/org/testcontainers/containers/ComposeDelegate.java
- core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java
- core/src/main/java/org/testcontainers/containers/DockerComposeFiles.java
- core/src/test/java/org/testcontainers/containers/Compose*Test.java
- core/src/test/java/org/testcontainers/containers/DockerCompose*Test.java
- core/src/test/java/org/testcontainers/junit/Compose*Test.java
- core/src/test/java/org/testcontainers/junit/DockerCompose*Test.java
"github_actions":
- changed-files:
- any-glob-to-any-file:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/combine-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
steps:
- name: combine-prs
id: combine-prs
uses: github/combine-prs@v5.0.0
uses: github/combine-prs@v5.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/update-docs-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
sed -i "s/latest_version: .*/latest_version: ${GITHUB_REF##*/}/g" mkdocs.yml
git diff
- name: Create Pull Request
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v3.10.1
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v3.10.1
with:
title: Update docs version to ${GITHUB_REF##*/}
body: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-testcontainers-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
sed -i "s/^testcontainers\.version=.*/testcontainers\.version=${GITHUB_REF##*/}/g" gradle.properties
git diff
- name: Create Pull Request
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v3.10.1
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v3.10.1
with:
title: Update testcontainers version to ${GITHUB_REF##*/}
body: |
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ buildscript {

dependencies {
// https://github.com/melix/japicmp-gradle-plugin/issues/36
classpath 'com.google.guava:guava:32.1.2-jre'
classpath 'com.google.guava:guava:33.2.1-jre'
classpath 'com.github.tjni.captainhook:captain-hook:0.1.5'
}
}

plugins {
id 'io.franzbecker.gradle-lombok' version '5.0.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'me.champeau.gradle.japicmp' version '0.4.2' apply false
id 'me.champeau.gradle.japicmp' version '0.4.3' apply false
id 'com.diffplug.spotless' version '6.13.0' apply false
}

Expand Down
8 changes: 4 additions & 4 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ dependencies {

api 'com.github.docker-java:docker-java-transport-zerodep'

shaded 'com.google.guava:guava:33.2.0-jre'
shaded 'com.google.guava:guava:33.2.1-jre'
shaded "org.yaml:snakeyaml:1.33"

shaded 'org.glassfish.main.external:trilead-ssh2-repackaged:4.1.2'
Expand All @@ -120,13 +120,13 @@ dependencies {
// Synthetic JAR used for MountableFileTest and DirectoryTarResourceTest
testImplementation files('testlib/repo/fakejar/fakejar/0/fakejar-0.jar')

testImplementation 'org.assertj:assertj-core:3.25.3'
testImplementation 'io.rest-assured:rest-assured:5.4.0'
testImplementation 'org.assertj:assertj-core:3.26.3'
testImplementation 'io.rest-assured:rest-assured:5.5.0'

jarFileTestCompileOnly "org.projectlombok:lombok:${lombok.version}"
jarFileTestAnnotationProcessor "org.projectlombok:lombok:${lombok.version}"
jarFileTestImplementation 'junit:junit:4.13.2'
jarFileTestImplementation 'org.assertj:assertj-core:3.25.3'
jarFileTestImplementation 'org.assertj:assertj-core:3.26.3'
jarFileTestImplementation 'org.ow2.asm:asm-debug-all:5.2'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.testcontainers;

import java.net.URI;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
Expand All @@ -14,7 +16,8 @@ public abstract class AbstractJarFileTest {
static {
try {
Path jarFilePath = Paths.get(System.getProperty("jarFile"));
URI jarFileUri = new URI("jar", jarFilePath.toUri().toString(), null);
String decodedPath = URLDecoder.decode(jarFilePath.toUri().toString(), StandardCharsets.UTF_8.name());
URI jarFileUri = new URI("jar", decodedPath, null);
FileSystem fileSystem = FileSystems.newFileSystem(jarFileUri, Collections.emptyMap());
root = fileSystem.getPath("/");
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.testcontainers.containers;

import org.apache.commons.lang3.StringUtils;

import java.util.Set;

class ComposeCommand {

static String getDownCommand(ComposeDelegate.ComposeVersion composeVersion, Set<String> options) {
String composeOptions = optionsAsString(options);
if (composeOptions == null || composeOptions.equals("")) {
return composeVersion == ComposeDelegate.ComposeVersion.V1 ? "down" : "compose down";
}
String cmd = composeVersion == ComposeDelegate.ComposeVersion.V1 ? "%s down" : "compose %s down";
return String.format(cmd, composeOptions);
}

static String getUpCommand(ComposeDelegate.ComposeVersion composeVersion, Set<String> options) {
String composeOptions = optionsAsString(options);
if (composeOptions == null || composeOptions.equals("")) {
return composeVersion == ComposeDelegate.ComposeVersion.V1 ? "up -d" : "compose up -d";
}
String cmd = composeVersion == ComposeDelegate.ComposeVersion.V1 ? "%s up -d" : "compose %s up -d";
return String.format(cmd, composeOptions);
}

private static String optionsAsString(final Set<String> options) {
String optionsString = String.join(" ", options);
if (!optionsString.isEmpty()) {
// ensures that there is a space between the options and 'up' if options are passed.
return optionsString;
} else {
// otherwise two spaces would appear between 'docker-compose' and 'up'
return StringUtils.EMPTY;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ public void stop() {
this.composeDelegate.getAmbassadorContainer().stop();

// Kill the services using docker
String cmd = "compose down";
String cmd = ComposeCommand.getDownCommand(ComposeDelegate.ComposeVersion.V2, this.options);

if (removeVolumes) {
cmd += " -v";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import lombok.NonNull;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.output.OutputFrame;
import org.testcontainers.containers.output.Slf4jLogConsumer;
Expand Down Expand Up @@ -146,7 +145,7 @@ void createServices(
.distinct()
.collect(Collectors.joining(" "));

String command = getUpCommand(optionsAsString(options));
String command = ComposeCommand.getUpCommand(this.composeVersion, options);

if (build) {
command += " --build";
Expand All @@ -164,25 +163,6 @@ void createServices(
runWithCompose(localCompose, command, env, fileCopyInclusions);
}

private String getUpCommand(String options) {
if (options == null || options.equals("")) {
return this.composeVersion == ComposeVersion.V1 ? "up -d" : "compose up -d";
}
String cmd = this.composeVersion == ComposeVersion.V1 ? "%s up -d" : "compose %s up -d";
return String.format(cmd, options);
}

private String optionsAsString(final Set<String> options) {
String optionsString = options.stream().collect(Collectors.joining(" "));
if (optionsString.length() != 0) {
// ensures that there is a space between the options and 'up' if options are passed.
return optionsString;
} else {
// otherwise two spaces would appear between 'docker-compose' and 'up'
return StringUtils.EMPTY;
}
}

void waitUntilServiceStarted(boolean tailChildContainers) {
listChildContainers().forEach(container -> createServiceInstance(container, tailChildContainers));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,16 @@ public ContainerisedDockerCompose(
public void invoke() {
super.start();

this.followOutput(new Slf4jLogConsumer(logger()));
followOutput(new Slf4jLogConsumer(logger()));

// wait for the compose container to stop, which should only happen after it has spawned all the service containers
logger()
.info("Docker Compose container is running for command: {}", Joiner.on(" ").join(this.getCommandParts()));
while (this.isRunning()) {
logger().info("Docker Compose container is running for command: {}", Joiner.on(" ").join(getCommandParts()));
while (isRunning()) {
logger().trace("Compose container is still running");
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
logger().info("Docker Compose has finished running");

AuditLogger.doComposeLog(this.getCommandParts(), this.getEnv());
AuditLogger.doComposeLog(getCommandParts(), getEnv());

final Integer exitCode = getDockerClient()
.inspectContainerCmd(getContainerId())
Expand All @@ -107,9 +105,11 @@ public void invoke() {
"Containerised Docker Compose exited abnormally with code " +
exitCode +
" whilst running command: " +
StringUtils.join(this.getCommandParts(), ' ')
StringUtils.join(getCommandParts(), ' ')
);
}

logger().info("Docker Compose has finished running");
}

private String convertToUnixFilesystemPath(String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void stop() {
this.composeDelegate.getAmbassadorContainer().stop();

// Kill the services using docker-compose
String cmd = "down";
String cmd = ComposeCommand.getDownCommand(ComposeDelegate.ComposeVersion.V1, this.options);

if (removeVolumes) {
cmd += " -v";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.testcontainers;
package org.testcontainers.containers;

import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.commons.lang3.SystemUtils;
Expand All @@ -9,7 +9,6 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.rnorth.ducttape.unreliables.Unreliables;
import org.testcontainers.containers.ComposeContainer;
import org.testcontainers.utility.CommandLine;

import java.io.BufferedReader;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.testcontainers.containers;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.File;

import static org.assertj.core.api.Assertions.assertThat;

@RunWith(Parameterized.class)
public class ComposeProfilesOptionTest {

@Parameterized.Parameters(name = "{0}")
public static Boolean[] local() {
return new Boolean[] { Boolean.TRUE, Boolean.FALSE };
}

@Parameterized.Parameter
public boolean local;

public static final File COMPOSE_FILE = new File("src/test/resources/compose-profile-option/compose-test.yml");

@Test
public void testProfileOption() {
try (
ComposeContainer compose = new ComposeContainer(COMPOSE_FILE)
.withOptions("--profile=cache")
.withLocalCompose(true)
) {
compose.start();
assertThat(compose.listChildContainers()).hasSize(1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.testcontainers.containers;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.File;

import static org.assertj.core.api.Assertions.assertThat;

@RunWith(Parameterized.class)
public class DockerComposeProfilesOptionTest {

@Parameterized.Parameters(name = "{0}")
public static Boolean[] local() {
return new Boolean[] { Boolean.TRUE, Boolean.FALSE };
}

@Parameterized.Parameter
public boolean local;

public static final File COMPOSE_FILE = new File("src/test/resources/compose-profile-option/compose-test.yml");

@Test
public void testProfileOption() {
try (
DockerComposeContainer<?> compose = new DockerComposeContainer<>(COMPOSE_FILE)
.withOptions("--profile=cache")
.withLocalCompose(this.local)
) {
compose.start();
assertThat(compose.listChildContainers()).hasSize(1);
}
}
}
11 changes: 11 additions & 0 deletions core/src/test/resources/compose-profile-option/compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
redis:
image: redis
profiles:
- cache
db:
image: mysql:8.0.36
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "true"
profiles:
- db
4 changes: 2 additions & 2 deletions docs/examples/junit4/generic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ dependencies {
testImplementation project(":mysql")

testRuntimeOnly 'mysql:mysql-connector-java:8.0.33'
testImplementation "org.seleniumhq.selenium:selenium-api:4.21.0"
testImplementation 'org.assertj:assertj-core:3.25.3'
testImplementation "org.seleniumhq.selenium:selenium-api:4.22.0"
testImplementation 'org.assertj:assertj-core:3.26.3'
}

test {
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/junit4/redis/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
description = "Examples for docs"

dependencies {
api "io.lettuce:lettuce-core:6.3.1.RELEASE"
api "io.lettuce:lettuce-core:6.3.2.RELEASE"

testImplementation "junit:junit:4.13.2"
testImplementation project(":testcontainers")
testImplementation 'org.assertj:assertj-core:3.25.3'
testImplementation 'org.assertj:assertj-core:3.26.3'
}
Loading

0 comments on commit 3e63698

Please sign in to comment.