Skip to content

Commit 5ad874f

Browse files
authored
Merge branch 'main' into docker-context
2 parents 055523f + e0321d9 commit 5ad874f

File tree

100 files changed

+1374
-454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1374
-454
lines changed

.github/ISSUE_TEMPLATE/bug_report.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ body:
6464
- Timeplus
6565
- ToxiProxy
6666
- Trino
67+
- Typesense
6768
- Vault
6869
- Weaviate
6970
- YugabyteDB

.github/ISSUE_TEMPLATE/enhancement.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ body:
6464
- Timeplus
6565
- ToxiProxy
6666
- Trino
67+
- Typesense
6768
- Vault
6869
- Weaviate
6970
- YugabyteDB

.github/ISSUE_TEMPLATE/feature.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ body:
6464
- Timeplus
6565
- ToxiProxy
6666
- Trino
67+
- Typesense
6768
- Vault
6869
- Weaviate
6970
- YugabyteDB

.github/dependabot.yml

+5
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ updates:
361361
schedule:
362362
interval: "weekly"
363363
open-pull-requests-limit: 10
364+
- package-ecosystem: "gradle"
365+
directory: "/modules/typesense"
366+
schedule:
367+
interval: "weekly"
368+
open-pull-requests-limit: 10
364369
- package-ecosystem: "gradle"
365370
directory: "/modules/vault"
366371
schedule:

.github/labeler.yml

+4
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@
232232
- changed-files:
233233
- any-glob-to-any-file:
234234
- modules/trino/**/*
235+
"modules/typesense":
236+
- changed-files:
237+
- any-glob-to-any-file:
238+
- modules/typesense/**/*
235239
"modules/vault":
236240
- changed-files:
237241
- any-glob-to-any-file:

.github/settings.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repository:
1313
homepage: https://testcontainers.org
1414

1515
# A comma-separated list of topics to set on the repository
16-
topics: java,testing,docker,docker-compose,jvm,test-automation,junit,hacktoberfest
16+
topics: java,testing,docker,docker-compose,jvm,test-automation,junit,hacktoberfest,integration-testing
1717

1818
# Either `true` to make the repository private, or `false` to make it public.
1919
private: false
@@ -262,6 +262,9 @@ labels:
262262
- name: modules/trino
263263
color: '#006b75'
264264

265+
- name: modules/typesense
266+
color: '#006b75'
267+
265268
- name: modules/vault
266269
color: '#006b75'
267270

.github/workflows/ci-windows.yml

+61-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ permissions:
4343
contents: read
4444

4545
jobs:
46-
core:
47-
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event.client_payload.slash_command.command == 'windows-test' }}
46+
main:
47+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
4848
runs-on: self-hosted
4949
permissions:
5050
checks: write
@@ -53,3 +53,62 @@ jobs:
5353
- name: Build with Gradle
5454
run: ./gradlew.bat cleanTest testcontainers:test --no-daemon --continue --scan --no-build-cache
5555
- uses: ./.github/actions/setup-junit-report
56+
57+
pr:
58+
if: ${{ github.event.client_payload.slash_command.command == 'windows-test' }}
59+
runs-on: self-hosted
60+
permissions:
61+
checks: write
62+
statuses: write
63+
steps:
64+
- name: Create pending status
65+
uses: actions/github-script@v7
66+
with:
67+
github-token: ${{ secrets.GITHUB_TOKEN }}
68+
script: |
69+
github.rest.repos.createCommitStatus({
70+
owner: context.repo.owner,
71+
repo: context.repo.repo,
72+
sha: context.payload.client_payload.pull_request.head.sha,
73+
state: 'pending',
74+
target_url: `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`,
75+
context: 'CI - Windows',
76+
})
77+
- uses: actions/checkout@v4
78+
with:
79+
token: ${{ secrets.GITHUB_TOKEN }}
80+
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
81+
ref: ${{ github.event.client_payload.pull_request.head.ref }}
82+
- name: Build with Gradle
83+
run: ./gradlew.bat cleanTest testcontainers:test --no-daemon --continue --scan --no-build-cache
84+
- uses: ./.github/actions/setup-junit-report
85+
86+
- name: Create success status
87+
uses: actions/github-script@v7
88+
if: success()
89+
with:
90+
github-token: ${{ secrets.GITHUB_TOKEN }}
91+
script: |
92+
github.rest.repos.createCommitStatus({
93+
owner: context.repo.owner,
94+
repo: context.repo.repo,
95+
sha: context.payload.client_payload.pull_request.head.sha,
96+
state: 'success',
97+
target_url: `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`,
98+
context: 'CI - Windows',
99+
})
100+
101+
- name: Create failure status
102+
uses: actions/github-script@v7
103+
if: failure()
104+
with:
105+
github-token: ${{ secrets.GITHUB_TOKEN }}
106+
script: |
107+
github.rest.repos.createCommitStatus({
108+
owner: context.repo.owner,
109+
repo: context.repo.repo,
110+
sha: context.payload.client_payload.pull_request.head.sha,
111+
state: 'failure',
112+
target_url: `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`,
113+
context: 'CI - Windows',
114+
})

.github/workflows/moby-latest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
{
5151
"tc_project": "testcontainers-java",
5252
"tc_docker_install_type": "${{ matrix.install-docker-type }}",
53-
"tc_github_action_url": "https://github.com/testcontainers/testcontainers-java/actions/runs/${{ env.GITHUB_RUN_ID }}/job/${{ env.GITHUB_RUN_NUMBER }}",
53+
"tc_github_action_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.run_number }}",
5454
"tc_github_action_status": "FAILED",
5555
"tc_slack_channel_id": "${{ secrets.SLACK_DOCKER_LATEST_CHANNEL_ID }}"
5656
}

core/src/main/java/org/testcontainers/containers/ComposeCommand.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package org.testcontainers.containers;
22

3-
import org.apache.commons.lang3.StringUtils;
4-
53
import java.util.Set;
64

75
class ComposeCommand {
86

97
static String getDownCommand(ComposeDelegate.ComposeVersion composeVersion, Set<String> options) {
108
String composeOptions = optionsAsString(options);
11-
if (composeOptions == null || composeOptions.equals("")) {
9+
if (composeOptions.isEmpty()) {
1210
return composeVersion == ComposeDelegate.ComposeVersion.V1 ? "down" : "compose down";
1311
}
1412
String cmd = composeVersion == ComposeDelegate.ComposeVersion.V1 ? "%s down" : "compose %s down";
@@ -17,7 +15,7 @@ static String getDownCommand(ComposeDelegate.ComposeVersion composeVersion, Set<
1715

1816
static String getUpCommand(ComposeDelegate.ComposeVersion composeVersion, Set<String> options) {
1917
String composeOptions = optionsAsString(options);
20-
if (composeOptions == null || composeOptions.equals("")) {
18+
if (composeOptions.isEmpty()) {
2119
return composeVersion == ComposeDelegate.ComposeVersion.V1 ? "up -d" : "compose up -d";
2220
}
2321
String cmd = composeVersion == ComposeDelegate.ComposeVersion.V1 ? "%s up -d" : "compose %s up -d";
@@ -31,7 +29,7 @@ private static String optionsAsString(final Set<String> options) {
3129
return optionsString;
3230
} else {
3331
// otherwise two spaces would appear between 'docker-compose' and 'up'
34-
return StringUtils.EMPTY;
32+
return "";
3533
}
3634
}
3735
}

core/src/main/java/org/testcontainers/containers/ComposeContainer.java

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public void stop() {
171171
}
172172
this.composeDelegate.runWithCompose(this.localCompose, cmd, this.env, this.filesInDirectory);
173173
} finally {
174+
this.composeDelegate.clear();
174175
this.project = this.composeDelegate.randomProjectId();
175176
}
176177
}

core/src/main/java/org/testcontainers/containers/ComposeDelegate.java

+7
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,13 @@ String getServiceHost() {
386386
return this.ambassadorContainer.getHost();
387387
}
388388

389+
void clear() {
390+
this.logConsumers.clear();
391+
this.ambassadorPortMappings.clear();
392+
this.serviceInstanceMap.clear();
393+
this.waitStrategyMap.clear();
394+
}
395+
389396
enum ComposeVersion {
390397
V1("_"),
391398

core/src/main/java/org/testcontainers/containers/DockerComposeContainer.java

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public void stop() {
177177
}
178178
this.composeDelegate.runWithCompose(this.localCompose, cmd, this.env, this.filesInDirectory);
179179
} finally {
180+
this.composeDelegate.clear();
180181
this.project = this.composeDelegate.randomProjectId();
181182
}
182183
}

core/src/main/java/org/testcontainers/containers/GenericContainer.java

-8
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import org.jetbrains.annotations.Nullable;
3535
import org.junit.runner.Description;
3636
import org.junit.runners.model.Statement;
37-
import org.rnorth.ducttape.ratelimits.RateLimiter;
38-
import org.rnorth.ducttape.ratelimits.RateLimiterBuilder;
3937
import org.rnorth.ducttape.unreliables.Unreliables;
4038
import org.slf4j.Logger;
4139
import org.testcontainers.DockerClientFactory;
@@ -193,12 +191,6 @@ public class GenericContainer<SELF extends GenericContainer<SELF>>
193191

194192
private static final Set<String> AVAILABLE_IMAGE_NAME_CACHE = new HashSet<>();
195193

196-
private static final RateLimiter DOCKER_CLIENT_RATE_LIMITER = RateLimiterBuilder
197-
.newBuilder()
198-
.withRate(1, TimeUnit.SECONDS)
199-
.withConstantThroughput()
200-
.build();
201-
202194
@Nullable
203195
private Map<String, String> tmpFsMapping;
204196

core/src/main/java/org/testcontainers/containers/ParsedDockerComposeFile.java

+22-16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.yaml.snakeyaml.LoaderOptions;
1212
import org.yaml.snakeyaml.Yaml;
1313
import org.yaml.snakeyaml.constructor.SafeConstructor;
14+
import org.yaml.snakeyaml.nodes.Node;
15+
import org.yaml.snakeyaml.nodes.Tag;
1416
import org.yaml.snakeyaml.representer.Representer;
1517
import org.yaml.snakeyaml.resolver.Resolver;
1618

@@ -44,13 +46,17 @@ class ParsedDockerComposeFile {
4446
LoaderOptions options = new LoaderOptions();
4547
options.setMaxAliasesForCollections(1_000);
4648
DumperOptions dumperOptions = new DumperOptions();
47-
Yaml yaml = new Yaml(
48-
new SafeConstructor(options),
49-
new Representer(dumperOptions),
50-
dumperOptions,
51-
options,
52-
new Resolver()
53-
);
49+
50+
SafeConstructor constructor = new SafeConstructor(options) {
51+
@Override
52+
protected Object constructObject(Node node) {
53+
if (node.getTag().equals(new Tag("!reset"))) {
54+
return null;
55+
}
56+
return super.constructObject(node);
57+
}
58+
};
59+
Yaml yaml = new Yaml(constructor, new Representer(dumperOptions), dumperOptions, options, new Resolver());
5460
try (FileInputStream fileInputStream = FileUtils.openInputStream(composeFile)) {
5561
composeFileContent = yaml.load(fileInputStream);
5662
} catch (Exception e) {
@@ -72,16 +78,16 @@ class ParsedDockerComposeFile {
7278

7379
private void parseAndValidate() {
7480
final Map<String, ?> servicesMap;
75-
if (composeFileContent.containsKey("version")) {
76-
if ("2.0".equals(composeFileContent.get("version"))) {
77-
log.warn(
78-
"Testcontainers may not be able to clean up networks spawned using Docker Compose v2.0 files. " +
79-
"Please see https://github.com/testcontainers/moby-ryuk/issues/2, and specify 'version: \"2.1\"' or " +
80-
"higher in {}",
81-
composeFileName
82-
);
83-
}
81+
if (composeFileContent.containsKey("version") && "2.0".equals(composeFileContent.get("version"))) {
82+
log.warn(
83+
"Testcontainers may not be able to clean up networks spawned using Docker Compose v2.0 files. " +
84+
"Please see https://github.com/testcontainers/moby-ryuk/issues/2, and specify 'version: \"2.1\"' or " +
85+
"higher in {}",
86+
composeFileName
87+
);
88+
}
8489

90+
if (composeFileContent.containsKey("services")) {
8591
final Object servicesElement = composeFileContent.get("services");
8692
if (servicesElement == null) {
8793
log.debug(

core/src/main/java/org/testcontainers/dockerclient/DockerClientProviderStrategy.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.net.InetSocketAddress;
3232
import java.net.Socket;
3333
import java.net.SocketAddress;
34-
import java.net.SocketTimeoutException;
3534
import java.net.URI;
3635
import java.security.KeyManagementException;
3736
import java.security.KeyStoreException;
@@ -207,17 +206,15 @@ protected boolean test() {
207206
}
208207

209208
try (Socket socket = socketProvider.call()) {
210-
Duration timeout = Duration.ofMillis(200);
211209
Awaitility
212210
.await()
213-
.atMost(TestcontainersConfiguration.getInstance().getClientPingTimeout(), TimeUnit.SECONDS)
214-
.pollInterval(timeout)
211+
.atMost(TestcontainersConfiguration.getInstance().getClientPingTimeout(), TimeUnit.SECONDS) // timeout after configured duration
212+
.pollInterval(Duration.ofMillis(200)) // check state every 200ms
215213
.pollDelay(Duration.ofSeconds(0)) // start checking immediately
216-
.ignoreExceptionsInstanceOf(SocketTimeoutException.class)
217-
.untilAsserted(() -> socket.connect(socketAddress, (int) timeout.toMillis()));
214+
.untilAsserted(() -> socket.connect(socketAddress));
218215
return true;
219216
} catch (Exception e) {
220-
log.warn("DOCKER_HOST {} is not listening", dockerHost);
217+
log.warn("DOCKER_HOST {} is not listening", dockerHost, e);
221218
return false;
222219
}
223220
}

core/src/main/java/org/testcontainers/images/RemoteDockerImage.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.testcontainers.utility.DockerLoggerFactory;
2323
import org.testcontainers.utility.ImageNameSubstitutor;
2424
import org.testcontainers.utility.LazyFuture;
25+
import org.testcontainers.utility.TestcontainersConfiguration;
2526

2627
import java.time.Duration;
2728
import java.time.Instant;
@@ -35,7 +36,9 @@
3536
@AllArgsConstructor(access = AccessLevel.PACKAGE)
3637
public class RemoteDockerImage extends LazyFuture<String> {
3738

38-
private static final Duration PULL_RETRY_TIME_LIMIT = Duration.ofMinutes(2);
39+
private static final Duration PULL_RETRY_TIME_LIMIT = Duration.ofSeconds(
40+
TestcontainersConfiguration.getInstance().getImagePullTimeout()
41+
);
3942

4043
@ToString.Exclude
4144
private Future<DockerImageName> imageNameFuture;

0 commit comments

Comments
 (0)