88import org .evomaster .client .java .controller .problem .RestProblem ;
99import org .evomaster .client .java .sql .DbSpecification ;
1010import org .testcontainers .containers .GenericContainer ;
11+ import org .testcontainers .utility .DockerImageName ;
12+ import org .testcontainers .utility .MountableFile ;
1113import org .whispersystems .textsecuregcm .WhisperServerService ;
1214import redis .clients .jedis .Jedis ;
1315import redis .clients .jedis .JedisPool ;
@@ -25,12 +27,16 @@ public class EmbeddedEvoMasterController extends EmbeddedSutController {
2527
2628 private static final int REDIS_PORT = 6379 ;
2729
28- private static final String REDIS_VERSION = "7.0.14 " ;
30+ private static final String REDIS_VERSION = "7.2.3 " ;
2931
30- private static final GenericContainer redisClusterContainer = new GenericContainer ("bitnami/redis-cluster:" + REDIS_VERSION )
31- .withExposedPorts (REDIS_PORT ).withCommand ();
32+ private static final DockerImageName REDIS_IMAGE = DockerImageName .parse ("redis:" + REDIS_VERSION );
3233
33- private static final JedisPool jedisPool = new JedisPool ("localhost" , REDIS_PORT );
34+ private static final GenericContainer redisContainer = new GenericContainer (REDIS_IMAGE )
35+ .withExposedPorts (REDIS_PORT )
36+ .withEnv ("ALLOW_EMPTY_PASSWORD" , "yes" )
37+ .withEnv ("REDIS_NODES" , "redis-cluster-01" )
38+ .withCopyFileToContainer (MountableFile .forHostPath ("src/main/resources/redis.conf" ), "/usr/local/etc/redis/redis.conf" )
39+ .withCommand ("redis-server /usr/local/etc/redis/redis.conf" );
3440
3541 public static void main (String [] args ) {
3642
@@ -91,19 +97,23 @@ public SutInfoDto.OutputFormat getPreferredOutputFormat() {
9197 public String startSut () {
9298 System .setProperty ("aws.region" , "us-west-2" );
9399
94- redisClusterContainer .start ();
100+ redisContainer .start ();
101+
95102 dynamoDBContainer .start ();
96103
97104 application = new WhisperServerService ();
98105
99106 //Dirty hack for DW...
100107 System .setProperty ("dw.server.applicationConnectors[0].port" , "0" );
101- // System.setProperty("dw.server.adminConnectors[0].port", "0");
102- System .setProperty ("dw.cacheCluster.configurationUri" , "redis://localhost:" + REDIS_PORT + "/" );
103- System .setProperty ("dw.clientPresenceCluster.configurationUri" , "redis://localhost:" + REDIS_PORT + "/" );
104- System .setProperty ("dw.pubsub.uri" , "redis://localhost:" + REDIS_PORT + "/" );
105- System .setProperty ("dw.pushSchedulerCluster.configurationUri" , "redis://localhost:" + REDIS_PORT + "/" );
106- System .setProperty ("dw.rateLimitersCluster.configurationUri" , "redis://localhost:" + REDIS_PORT + "/" );
108+ System .setProperty ("dw.server.adminConnectors[0].port" , "0" );
109+
110+ System .setProperty ("dw.cacheCluster.configurationUri" , "redis://0.0.0.0:" + redisContainer .getFirstMappedPort () + "/" );
111+ System .setProperty ("dw.clientPresenceCluster.configurationUri" , "redis://0.0.0.0:" + redisContainer .getFirstMappedPort () + "/" );
112+ System .setProperty ("dw.pubsub.uri" , "redis://0.0.0.0:" + redisContainer .getFirstMappedPort () + "/" );
113+ System .setProperty ("dw.pushSchedulerCluster.configurationUri" , "redis://0.0.0.0:" + redisContainer .getFirstMappedPort () + "/" );
114+ System .setProperty ("dw.rateLimitersCluster.configurationUri" , "redis://0.0.0.0:" + redisContainer .getFirstMappedPort () + "/" );
115+ System .setProperty ("dw.messageCache.cluster.configurationUri" , "redis://0.0.0.0:" + redisContainer .getFirstMappedPort () + "/" );
116+ System .setProperty ("dw.metricsCluster.configurationUri" , "redis://0.0.0.0:" + redisContainer .getFirstMappedPort () + "/" );
107117
108118 try {
109119 application .run ("server" , "src/main/resources/em-sample.yml" );
@@ -139,12 +149,14 @@ public void stopSut() {
139149 }
140150 }
141151
142- redisClusterContainer .stop ();
152+ redisContainer .stop ();
143153 dynamoDBContainer .stop ();
144154 }
145155
146156 @ Override
147157 public void resetStateOfSUT () {
158+ JedisPool jedisPool = new JedisPool ("0.0.0.0" , redisContainer .getFirstMappedPort ());
159+
148160 try (Jedis jedis = jedisPool .getResource ()) {
149161 jedis .flushAll ();
150162 }
0 commit comments