Upgrade testcontainers 1.19.0 (fix local issue with upgraded docker version) (#10471)

* add some debug

Signed-off-by: Olivier Lamy <olamy@apache.org>

* force use infinispan.client.hotrod.client_intelligence=BASIC looks to fix issue locally after docker upgrade, use new forListeningPorts to check infinispan start

Signed-off-by: Olivier Lamy <olamy@apache.org>

* use Wait.forListeningPorts to wait docker image start

Signed-off-by: Olivier Lamy <olamy@apache.org>

* cleanup commented code

Signed-off-by: Olivier Lamy <olamy@apache.org>

---------

Signed-off-by: Olivier Lamy <olamy@apache.org>
This commit is contained in:
Olivier Lamy 2023-09-04 13:09:43 +10:00 committed by GitHub
parent 004da47cb5
commit 896a301fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 20 deletions

View File

@ -145,7 +145,7 @@
<spifly.version>1.3.6</spifly.version> <spifly.version>1.3.6</spifly.version>
<taglibs-standard-impl.version>1.2.5</taglibs-standard-impl.version> <taglibs-standard-impl.version>1.2.5</taglibs-standard-impl.version>
<taglibs-standard-spec.version>1.2.5</taglibs-standard-spec.version> <taglibs-standard-spec.version>1.2.5</taglibs-standard-spec.version>
<testcontainers.version>1.18.3</testcontainers.version> <testcontainers.version>1.19.0</testcontainers.version>
<wildfly.common.version>1.6.0.Final</wildfly.common.version> <wildfly.common.version>1.6.0.Final</wildfly.common.version>
<wildfly.elytron.version>2.2.2.Final</wildfly.elytron.version> <wildfly.elytron.version>2.2.2.Final</wildfly.elytron.version>
<xmemcached.version>2.4.7</xmemcached.version> <xmemcached.version>2.4.7</xmemcached.version>
@ -202,7 +202,8 @@
<mongo.docker.version>3.2.20</mongo.docker.version> <mongo.docker.version>3.2.20</mongo.docker.version>
<settingsPath>src/it/settings.xml</settingsPath> <settingsPath>src/it/settings.xml</settingsPath>
<surefire.rerunFailingTestsCount>0</surefire.rerunFailingTestsCount> <surefire.rerunFailingTestsCount>0</surefire.rerunFailingTestsCount>
<!-- if changing this version please update default in RemoteInfinispanTestSupport you will get thanks from Eclipse IDE users --> <!-- if changing this version please update default in RemoteInfinispanTestSupport/InfinispanSessionDistributionTests
you will get thanks from Eclipse IDE users -->
<!-- but hey we have no more strange people?? :P --> <!-- but hey we have no more strange people?? :P -->
<infinispan.docker.image.version>11.0.14.Final</infinispan.docker.image.version> <infinispan.docker.image.version>11.0.14.Final</infinispan.docker.image.version>

View File

@ -69,7 +69,7 @@ public class RemoteInfinispanTestSupport
.withEnv("MGMT_USER", "admin") .withEnv("MGMT_USER", "admin")
.withEnv("MGMT_PASS", "admin") .withEnv("MGMT_PASS", "admin")
.withEnv("CONFIG_PATH", "/user-config/config.yaml") .withEnv("CONFIG_PATH", "/user-config/config.yaml")
.waitingFor(Wait.forLogMessage(".*Infinispan Server.*started in.*\\s", 1)) .waitingFor(Wait.forListeningPorts(11222))
.withExposedPorts(4712, 4713, 8088, 8089, 8443, 9990, 9993, 11211, 11222, 11223, 11224) .withExposedPorts(4712, 4713, 8088, 8089, 8443, 9990, 9993, 11211, 11222, 11223, 11224)
.withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG)) .withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG))
.withClasspathResourceMapping("/config.yaml", "/user-config/config.yaml", BindMode.READ_ONLY) .withClasspathResourceMapping("/config.yaml", "/user-config/config.yaml", BindMode.READ_ONLY)

View File

@ -52,7 +52,7 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
private GenericContainer<?> hazelcast = new GenericContainer<>("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.2.2")) private GenericContainer<?> hazelcast = new GenericContainer<>("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.2.2"))
.withExposedPorts(5701) .withExposedPorts(5701)
.waitingFor(Wait.forLogMessage(".*is STARTED.*", 1)) .waitingFor(Wait.forListeningPorts(5701))
.withLogConsumer(new Slf4jLogConsumer(HAZELCAST_LOG)); .withLogConsumer(new Slf4jLogConsumer(HAZELCAST_LOG));
private Path hazelcastJettyPath; private Path hazelcastJettyPath;
@ -64,7 +64,7 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
{ {
hazelcast.start(); hazelcast.start();
} }
String hazelcastHost = hazelcast.getContainerIpAddress(); String hazelcastHost = hazelcast.getHost();
int hazelcastPort = hazelcast.getMappedPort(5701); int hazelcastPort = hazelcast.getMappedPort(5701);
LOGGER.info("hazelcast started on {}:{}", hazelcastHost, hazelcastPort); LOGGER.info("hazelcast started on {}:{}", hazelcastHost, hazelcastPort);
@ -124,27 +124,23 @@ public class HazelcastSessionDistributionTests extends AbstractSessionDistributi
env.put("JAVA_OPTS", "-Dhazelcast.config=/opt/hazelcast/config_ext/hazelcast.xml"); env.put("JAVA_OPTS", "-Dhazelcast.config=/opt/hazelcast/config_ext/hazelcast.xml");
try (GenericContainer<?> hazelcast = try (GenericContainer<?> hazelcast =
new GenericContainer<>("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.1")) new GenericContainer<>("hazelcast/hazelcast:" + System.getProperty("hazelcast.version", "4.1"))
.withExposedPorts(5701, 5705) .withExposedPorts(5701)
.withEnv(env) .withEnv(env)
.waitingFor(Wait.forLogMessage(".*is STARTED.*", 1)) .waitingFor(Wait.forListeningPorts(5701))
//.withNetworkMode("host")
//.waitingFor(Wait.forListeningPort())
.withClasspathResourceMapping("hazelcast-server.xml", .withClasspathResourceMapping("hazelcast-server.xml",
"/opt/hazelcast/config_ext/hazelcast.xml", "/opt/hazelcast/config_ext/hazelcast.xml",
BindMode.READ_ONLY) BindMode.READ_ONLY)
.withLogConsumer(new Slf4jLogConsumer(HAZELCAST_LOG))) .withLogConsumer(new Slf4jLogConsumer(HAZELCAST_LOG)))
{ {
hazelcast.start(); hazelcast.start();
String hazelcastHost = InetAddress.getByName(hazelcast.getContainerIpAddress()).getHostAddress(); // hazelcast.getContainerIpAddress(); String hazelcastHost = InetAddress.getByName(hazelcast.getHost()).getHostAddress();
int hazelcastPort = hazelcast.getMappedPort(5701); int hazelcastPort = hazelcast.getMappedPort(5701);
// int hazelcastMultiCastPort = hazelcast.getMappedPort(54327);
LOGGER.info("hazelcast started on {}:{}", hazelcastHost, hazelcastPort); LOGGER.info("hazelcast started on {}:{}", hazelcastHost, hazelcastPort);
Map<String, String> tokenValues = new HashMap<>(); Map<String, String> tokenValues = new HashMap<>();
tokenValues.put("hazelcast_ip", hazelcastHost); tokenValues.put("hazelcast_ip", hazelcastHost);
tokenValues.put("hazelcast_port", Integer.toString(hazelcastPort)); tokenValues.put("hazelcast_port", Integer.toString(hazelcastPort));
// tokenValues.put("hazelcast_multicast_port", Integer.toString(hazelcastMultiCastPort));
Path hazelcastJettyPath = Paths.get("target/hazelcast-jetty.xml"); Path hazelcastJettyPath = Paths.get("target/hazelcast-jetty.xml");
transformFileWithHostAndPort(Paths.get("src/test/resources/hazelcast-jetty.xml"), transformFileWithHostAndPort(Paths.get("src/test/resources/hazelcast-jetty.xml"),
hazelcastJettyPath, hazelcastJettyPath,

View File

@ -28,6 +28,7 @@ import java.util.Properties;
import org.eclipse.jetty.session.infinispan.InfinispanSerializationContextInitializer; import org.eclipse.jetty.session.infinispan.InfinispanSerializationContextInitializer;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.infinispan.client.hotrod.RemoteCacheManager; import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.configuration.ClientIntelligence;
import org.infinispan.client.hotrod.configuration.Configuration; import org.infinispan.client.hotrod.configuration.Configuration;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.commons.configuration.XMLStringConfiguration; import org.infinispan.commons.configuration.XMLStringConfiguration;
@ -38,6 +39,7 @@ import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer; import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
/** /**
* *
@ -49,7 +51,7 @@ public class InfinispanSessionDistributionTests extends AbstractSessionDistribut
private static final Logger INFINISPAN_LOG = LoggerFactory.getLogger("org.eclipse.jetty.tests.distribution.session.infinispan"); private static final Logger INFINISPAN_LOG = LoggerFactory.getLogger("org.eclipse.jetty.tests.distribution.session.infinispan");
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private GenericContainer infinispan; private GenericContainer<?> infinispan;
private String host; private String host;
private int port; private int port;
@ -59,20 +61,19 @@ public class InfinispanSessionDistributionTests extends AbstractSessionDistribut
{ {
String infinispanVersion = System.getProperty("infinispan.docker.image.version", "11.0.14.Final"); String infinispanVersion = System.getProperty("infinispan.docker.image.version", "11.0.14.Final");
infinispan = infinispan =
new GenericContainer(System.getProperty("infinispan.docker.image.name", "infinispan/server") + new GenericContainer<>(System.getProperty("infinispan.docker.image.name", "infinispan/server") +
":" + infinispanVersion) ":" + infinispanVersion)
.withEnv("USER", "theuser") .withEnv("USER", "theuser")
.withEnv("PASS", "foobar") .withEnv("PASS", "foobar")
.withEnv("MGMT_USER", "admin") .withEnv("MGMT_USER", "admin")
.withEnv("MGMT_PASS", "admin") .withEnv("MGMT_PASS", "admin")
.withEnv("CONFIG_PATH", "/user-config/config.yaml") .withEnv("CONFIG_PATH", "/user-config/config.yaml")
.waitingFor(new LogMessageWaitStrategy() .waitingFor(Wait.forListeningPorts(11222))
.withRegEx(".*Infinispan Server.*started in.*\\s"))
.withExposedPorts(4712, 4713, 8088, 8089, 8443, 9990, 9993, 11211, 11222, 11223, 11224) .withExposedPorts(4712, 4713, 8088, 8089, 8443, 9990, 9993, 11211, 11222, 11223, 11224)
.withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG)) .withLogConsumer(new Slf4jLogConsumer(INFINISPAN_LOG))
.withClasspathResourceMapping("/config.yaml", "/user-config/config.yaml", BindMode.READ_ONLY); .withClasspathResourceMapping("/config.yaml", "/user-config/config.yaml", BindMode.READ_ONLY);
infinispan.start(); infinispan.start();
host = infinispan.getContainerIpAddress(); host = infinispan.getHost();
port = infinispan.getMappedPort(11222); port = infinispan.getMappedPort(11222);
Path resourcesDirectory = Path.of(jettyHomeTester.getJettyBase().toString(), "resources/"); Path resourcesDirectory = Path.of(jettyHomeTester.getJettyBase().toString(), "resources/");
@ -88,7 +89,7 @@ public class InfinispanSessionDistributionTests extends AbstractSessionDistribut
properties.put("infinispan.client.hotrod.sasl_mechanism", "DIGEST-MD5"); properties.put("infinispan.client.hotrod.sasl_mechanism", "DIGEST-MD5");
properties.put("infinispan.client.hotrod.auth_username", "theuser"); properties.put("infinispan.client.hotrod.auth_username", "theuser");
properties.put("infinispan.client.hotrod.auth_password", "foobar"); properties.put("infinispan.client.hotrod.auth_password", "foobar");
properties.put("infinispan.client.hotrod.client_intelligence", "BASIC");
Path hotrod = Path.of(resourcesDirectory.toString(), "hotrod-client.properties"); Path hotrod = Path.of(resourcesDirectory.toString(), "hotrod-client.properties");
Files.deleteIfExists(hotrod); Files.deleteIfExists(hotrod);
@ -104,6 +105,7 @@ public class InfinispanSessionDistributionTests extends AbstractSessionDistribut
.addContextInitializer(new InfinispanSerializationContextInitializer()) .addContextInitializer(new InfinispanSerializationContextInitializer())
.security().authentication().saslMechanism("DIGEST-MD5") .security().authentication().saslMechanism("DIGEST-MD5")
.username("theuser").password("foobar") .username("theuser").password("foobar")
.clientIntelligence(ClientIntelligence.BASIC)
.build(); .build();
RemoteCacheManager remoteCacheManager = new RemoteCacheManager(configuration); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(configuration);
@ -140,7 +142,7 @@ public class InfinispanSessionDistributionTests extends AbstractSessionDistribut
@Override @Override
public List<String> getFirstStartExtraArgs() public List<String> getFirstStartExtraArgs()
{ {
return Arrays.asList(); return List.of();
} }
@Override @Override
@ -152,7 +154,7 @@ public class InfinispanSessionDistributionTests extends AbstractSessionDistribut
@Override @Override
public List<String> getSecondStartExtraArgs() public List<String> getSecondStartExtraArgs()
{ {
return Arrays.asList(); return List.of();
} }
@Override @Override
@ -172,6 +174,8 @@ public class InfinispanSessionDistributionTests extends AbstractSessionDistribut
writer.newLine(); writer.newLine();
writer.write("infinispan.client.hotrod.auth_password=foobar"); writer.write("infinispan.client.hotrod.auth_password=foobar");
writer.newLine(); writer.newLine();
writer.write("infinispan.client.hotrod.client_intelligence=BASIC");
writer.newLine();
} }
} }
} }