Skip to content

Commit 1305fee

Browse files
Fix LocalStack legacy mode detection for "latest" tag variations (#8774)
Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
1 parent 0264499 commit 1305fee

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

modules/localstack/src/main/java/org/testcontainers/containers/localstack/LocalStackContainer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ private static boolean isServicesEnvVarRequired(String version) {
147147
return true;
148148
}
149149

150-
private static boolean shouldRunInLegacyMode(String version) {
151-
if (version.equals("latest")) {
150+
static boolean shouldRunInLegacyMode(String version) {
151+
// assume that the latest images are up-to-date
152+
// also consider images with extra packages (like latest-bigdata) and service-specific images (like s3-latest)
153+
if (version.equals("latest") || version.startsWith("latest-") || version.endsWith("-latest")) {
152154
return false;
153155
}
154156

modules/localstack/src/test/java/org/testcontainers/containers/localstack/LegacyModeTest.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,39 @@ public void differentPortsAreExposed() {
139139
}
140140
}
141141
}
142+
143+
@RunWith(Parameterized.class)
144+
@AllArgsConstructor
145+
public static class LegacyModeUnitTest {
146+
147+
private final String version;
148+
149+
private final boolean shouldUseLegacyMode;
150+
151+
@Parameterized.Parameters(name = "{0} - {1}")
152+
public static Iterable<Object[]> constructors() {
153+
return Arrays.asList(
154+
new Object[][] {
155+
{ "latest", false },
156+
{ "s3-latest", false },
157+
{ "latest-bigdata", false },
158+
{ "3.4.0-bigdata", false },
159+
{ "3.4.0@sha256:54fcf172f6ff70909e1e26652c3bb4587282890aff0d02c20aa7695469476ac0", false },
160+
{ "1.4@sha256:7badf31c550f81151c485980e17542592942d7f05acc09723c5f276d41b5927d", false },
161+
{ "3.4.0", false },
162+
{ "0.12", false },
163+
{ "0.11", false },
164+
{ "sha256:8bf0d744fea26603f2b11ef7206edb38375ef954258afaeda96532a6c9c1ab8b", false },
165+
{ "0.10.7@sha256:45ef287e29af7285c6e4013fafea1e3567c167cd22d12282f0a5f9c7894b1c5f", true },
166+
{ "0.10.7", true },
167+
{ "0.9.6", true },
168+
}
169+
);
170+
}
171+
172+
@Test
173+
public void samePortIsExposedForAllServices() {
174+
assertThat(LocalStackContainer.shouldRunInLegacyMode(version)).isEqualTo(shouldUseLegacyMode);
175+
}
176+
}
142177
}

0 commit comments

Comments
 (0)