Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.evomaster.client.java.sql.DbSpecification;
import org.evomaster.client.java.controller.problem.ProblemInfo;
import org.evomaster.client.java.controller.problem.RestProblem;
import org.evomaster.client.java.controller.redis.ReflectionBasedRedisClient;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.testcontainers.containers.GenericContainer;
Expand Down Expand Up @@ -95,6 +96,12 @@ public static void main(String[] args) {

private UnifiedJedis redisClient;

/**
* Separate from {@link #redisClient}: this is the connection EvoMaster itself uses to compute
* Redis heuristics and to insert data satisfying failed FT.SEARCH/FT.AGGREGATE commands.
*/
private ReflectionBasedRedisClient redisHeuristicsClient;

public EmbeddedEvoMasterController() {
this(0);
}
Expand All @@ -113,6 +120,8 @@ public String startSut() {
initCassandraSchema();
redisClient = new JedisPooled("redis://:" + REDIS_PASSWORD + "@"
+ redis.getHost() + ":" + redis.getMappedPort(REDIS_PORT));
redisHeuristicsClient = new ReflectionBasedRedisClient(
redis.getHost(), redis.getMappedPort(REDIS_PORT), 0, REDIS_PASSWORD);

ctx = SpringApplication.run(DemoApplication.class, new String[]{
"--server.port=0",
Expand Down Expand Up @@ -167,6 +176,11 @@ public void stopSut() {
redisClient = null;
}

if (redisHeuristicsClient != null) {
redisHeuristicsClient.close();
redisHeuristicsClient = null;
}

cassandra.stop();
kafka.stop();
redis.stop();
Expand All @@ -177,6 +191,11 @@ public String getPackagePrefixesToCover() {
return "com.jphaugla.";
}

@Override
public ReflectionBasedRedisClient getRedisConnection() {
return redisHeuristicsClient;
}

/*
Redis is the only store that keeps state across tests. FLUSHALL would drop the
RediSearch indexes, which the SUT creates only at startup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.evomaster.client.java.sql.DbSpecification;
import org.evomaster.client.java.controller.problem.ProblemInfo;
import org.evomaster.client.java.controller.problem.RestProblem;
import org.evomaster.client.java.controller.redis.ReflectionBasedRedisClient;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.kafka.KafkaContainer;
Expand Down Expand Up @@ -122,6 +123,12 @@ public static void main(String[] args) {

private UnifiedJedis redisClient;

/**
* Separate from {@link #redisClient}: this is the connection EvoMaster itself uses to compute
* Redis heuristics and to insert data satisfying failed FT.SEARCH/FT.AGGREGATE commands.
*/
private ReflectionBasedRedisClient redisHeuristicsClient;

public ExternalEvoMasterController() {
this(DEFAULT_CONTROLLER_PORT, "../target/digitalbanking-sut.jar", DEFAULT_SUT_PORT, 120, "java");
}
Expand Down Expand Up @@ -197,6 +204,8 @@ public void preStart() {
initCassandraSchema();
redisClient = new JedisPooled("redis://:" + REDIS_PASSWORD + "@"
+ redis.getHost() + ":" + redis.getMappedPort(REDIS_PORT));
redisHeuristicsClient = new ReflectionBasedRedisClient(
redis.getHost(), redis.getMappedPort(REDIS_PORT), 0, REDIS_PASSWORD);
}

private void initCassandraSchema() {
Expand All @@ -221,6 +230,10 @@ public void postStop() {
redisClient.close();
redisClient = null;
}
if (redisHeuristicsClient != null) {
redisHeuristicsClient.close();
redisHeuristicsClient = null;
}
cassandra.stop();
kafka.stop();
redis.stop();
Expand All @@ -231,6 +244,11 @@ public String getPackagePrefixesToCover() {
return "com.jphaugla.";
}

@Override
public ReflectionBasedRedisClient getRedisConnection() {
return redisHeuristicsClient;
}

@Override
public ProblemInfo getProblemInfo() {
return new RestProblem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.evomaster.client.java.sql.DbSpecification;
import org.evomaster.client.java.controller.problem.ProblemInfo;
import org.evomaster.client.java.controller.problem.RestProblem;
import org.evomaster.client.java.controller.redis.ReflectionBasedRedisClient;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.testcontainers.containers.GenericContainer;
Expand Down Expand Up @@ -62,6 +63,12 @@ public static void main(String[] args) {

private StatefulRedisConnection<String, String> redisConnection;

/**
* Separate from {@link #redisConnection}: this is the connection EvoMaster itself uses to compute
* Redis heuristics and to insert data satisfying failed Redis commands.
*/
private ReflectionBasedRedisClient redisHeuristicsClient;

public EmbeddedEvoMasterController() {
this(0);
}
Expand All @@ -78,6 +85,8 @@ public String startSut() {
redisClient = RedisClient.create("redis://:" + REDIS_PASSWORD + "@"
+ redis.getHost() + ":" + redis.getMappedPort(REDIS_PORT));
redisConnection = redisClient.connect();
redisHeuristicsClient = new ReflectionBasedRedisClient(
redis.getHost(), redis.getMappedPort(REDIS_PORT), 0, REDIS_PASSWORD);

ctx = SpringApplication.run(SpringBootRedisSampleApplication.class, new String[]{
"--server.port=0",
Expand Down Expand Up @@ -120,6 +129,11 @@ public void stopSut() {
redisClient = null;
}

if (redisHeuristicsClient != null) {
redisHeuristicsClient.close();
redisHeuristicsClient = null;
}

redis.stop();
}

Expand All @@ -128,6 +142,11 @@ public String getPackagePrefixesToCover() {
return "id.my.hendisantika.springbootredissample.";
}

@Override
public ReflectionBasedRedisClient getRedisConnection() {
return redisHeuristicsClient;
}

/*
Only the Spring Cache entries accumulate: the API is read-only, and the seeded data is
written once at startup by runners guarded on an empty repository, so it must survive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.evomaster.client.java.sql.DbSpecification;
import org.evomaster.client.java.controller.problem.ProblemInfo;
import org.evomaster.client.java.controller.problem.RestProblem;
import org.evomaster.client.java.controller.redis.ReflectionBasedRedisClient;
import org.testcontainers.containers.GenericContainer;
import io.lettuce.core.RedisClient;
import io.lettuce.core.api.StatefulRedisConnection;
Expand Down Expand Up @@ -89,6 +90,12 @@ public static void main(String[] args) {

private StatefulRedisConnection<String, String> redisConnection;

/**
* Separate from {@link #redisConnection}: this is the connection EvoMaster itself uses to compute
* Redis heuristics and to insert data satisfying failed Redis commands.
*/
private ReflectionBasedRedisClient redisHeuristicsClient;

public ExternalEvoMasterController() {
this(DEFAULT_CONTROLLER_PORT, "../target/redis-sample-sut.jar", DEFAULT_SUT_PORT, 120, "java");
}
Expand Down Expand Up @@ -157,6 +164,8 @@ public void preStart() {
redisClient = RedisClient.create("redis://:" + REDIS_PASSWORD + "@"
+ redis.getHost() + ":" + redis.getMappedPort(REDIS_PORT));
redisConnection = redisClient.connect();
redisHeuristicsClient = new ReflectionBasedRedisClient(
redis.getHost(), redis.getMappedPort(REDIS_PORT), 0, REDIS_PASSWORD);
}

@Override
Expand All @@ -176,6 +185,11 @@ public void postStop() {
redisClient = null;
}

if (redisHeuristicsClient != null) {
redisHeuristicsClient.close();
redisHeuristicsClient = null;
}

redis.stop();
}

Expand All @@ -184,6 +198,11 @@ public String getPackagePrefixesToCover() {
return "id.my.hendisantika.springbootredissample.";
}

@Override
public ReflectionBasedRedisClient getRedisConnection() {
return redisHeuristicsClient;
}

@Override
public ProblemInfo getProblemInfo() {
return new RestProblem(
Expand Down