Skip to content

Commit 866137c

Browse files
committed
Merge remote-tracking branch 'origin/master' into regex-java-flag-x
2 parents 0f045f3 + 5cf86a8 commit 866137c

154 files changed

Lines changed: 2732 additions & 378 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ on:
3232
# - "**"
3333

3434
env:
35-
evomaster-version: 6.0.1
35+
evomaster-version: 6.1.2
3636
# Unfortunately, to use JPackage we need JDK 17 or above :(
3737
# Which is really bad due to the madness of --add-opens.
3838
# Even if hunt down all cases of reflections in EM, there is still the problem of

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- "v*"
99

1010
env:
11-
evomaster-version: 6.0.1
11+
evomaster-version: 6.1.2
1212
jdk-jar: 17
1313
jdk-jpackage: 21
1414
java-distribution: temurin

client-java/ci-utils/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<parent>
1414
<artifactId>evomaster-client-java</artifactId>
1515
<groupId>org.evomaster</groupId>
16-
<version>6.0.1-SNAPSHOT</version>
16+
<version>6.1.2-SNAPSHOT</version>
1717
</parent>
1818

1919
<artifactId>evomaster-ci-utils</artifactId>

client-java/client-util/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.evomaster</groupId>
77
<artifactId>evomaster-client-java</artifactId>
8-
<version>6.0.1-SNAPSHOT</version>
8+
<version>6.1.2-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>evomaster-client-java-util</artifactId>

client-java/controller-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.evomaster</groupId>
77
<artifactId>evomaster-client-java</artifactId>
8-
<version>6.0.1-SNAPSHOT</version>
8+
<version>6.1.2-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>evomaster-client-java-controller-api</artifactId>

client-java/controller-api/src/main/java/org/evomaster/client/java/controller/api/dto/database/execution/RedisFailedCommand.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.evomaster.client.java.controller.api.dto.database.execution;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
/**
47
* Each time a Redis command is executed and returns no data, we keep track of which keys were involved,
58
* as well as relevant information such as the command type.
@@ -12,9 +15,9 @@ public class RedisFailedCommand {
1215
public String command;
1316

1417
/**
15-
* Key involved. Could be null if the command does not have a key in the arguments. For example: KEYS (pattern).
18+
* Keys involved. Could be null if the command does not have any key in the arguments. For example: KEYS (pattern).
1619
*/
17-
public String key;
20+
public List<String> keys;
1821

1922
/**
2023
* Pattern involved. It'd only apply to commands with pattern like KEYS.
@@ -28,9 +31,9 @@ public class RedisFailedCommand {
2831

2932
public RedisFailedCommand() {}
3033

31-
public RedisFailedCommand(String command, String key, String pattern, String field) {
34+
public RedisFailedCommand(String command, List<String> keys, String pattern, String field) {
3235
this.command = command;
33-
this.key = key;
36+
this.keys = new ArrayList<>(keys);
3437
this.pattern = pattern;
3538
this.field = field;
3639
}

client-java/controller/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.evomaster</groupId>
77
<artifactId>evomaster-client-java</artifactId>
8-
<version>6.0.1-SNAPSHOT</version>
8+
<version>6.1.2-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>evomaster-client-java-controller</artifactId>

client-java/controller/src/main/java/org/evomaster/client/java/controller/internal/db/redis/RedisHandler.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,15 @@ public List<RedisCommandEvaluation> getEvaluatedRedisCommands() {
105105

106106
private void registerFailedCommand(RedisCommand redisCommand, double distance) {
107107
RedisCommand.RedisCommandType type = redisCommand.getType();
108-
if (distance > 0 &&
109-
type.equals(GET) || type.equals(KEYS) || type.equals(HGET) || type.equals(HGETALL)) {
110-
//For this first iteration we'll only work on GET commands.
108+
if (distance > 0 && (
109+
type.equals(GET) ||
110+
type.equals(HGET) ||
111+
type.equals(HGETALL) ||
112+
type.equals(KEYS) ||
113+
type.equals(SINTER) ||
114+
type.equals(SMEMBERS))
115+
) {
116+
// Further commands will be registered in future iterations.
111117
failedCommands.add(createFailedCommand(redisCommand));
112118
}
113119
}
@@ -117,13 +123,15 @@ private RedisFailedCommand createFailedCommand(RedisCommand redisCommand) {
117123
List<String> args = redisCommand.extractArgs();
118124
switch (type) {
119125
case GET:
120-
case HGETALL: {
126+
case HGETALL:
127+
case SINTER:
128+
case SMEMBERS: {
121129
if (args.isEmpty()) {
122130
throw new IllegalArgumentException("Command " + type.getLabel() + " has invalid arguments.");
123131
}
124132
return new RedisFailedCommand(
125133
type.getLabel().toUpperCase(),
126-
args.get(0),
134+
args,
127135
null,
128136
null);
129137
}
@@ -134,7 +142,7 @@ private RedisFailedCommand createFailedCommand(RedisCommand redisCommand) {
134142
}
135143
return new RedisFailedCommand(
136144
type.getLabel().toUpperCase(),
137-
null,
145+
Collections.emptyList(),
138146
RedisUtils.redisPatternToRegex(args.get(0)),
139147
null);
140148
}
@@ -145,7 +153,7 @@ private RedisFailedCommand createFailedCommand(RedisCommand redisCommand) {
145153
}
146154
return new RedisFailedCommand(
147155
type.getLabel().toUpperCase(),
148-
args.get(0),
156+
Collections.singletonList((args.get(0))),
149157
null,
150158
args.get(1));
151159
}
@@ -207,8 +215,7 @@ private RedisKeyValueStore createRedisInfoForIntersection(List<String> commandKe
207215
//The value for each one, since each key represents a SET, correspond to the members of that given set.
208216
Map<String, RedisValueData> redisData = new HashMap<>();
209217
keySet.forEach(
210-
key -> redisData.put(key, new RedisValueData(redisClient.getSetMembers(key))
211-
));
218+
key -> redisData.put(key, new RedisValueData(redisClient.getSetMembers(key))));
212219
return new RedisKeyValueStore(redisData);
213220
}
214221

@@ -219,8 +226,7 @@ private RedisKeyValueStore createRedisInfoForAllKeys(ReflectionBasedRedisClient
219226
//No value is needed in this case.
220227
Map<String, RedisValueData> redisData = new HashMap<>();
221228
keys.forEach(
222-
key -> redisData.put(key, null)
223-
);
229+
key -> redisData.put(key, null));
224230
return new RedisKeyValueStore(redisData);
225231
}
226232

@@ -230,7 +236,8 @@ private RedisKeyValueStore createRedisInfoForKeysByType(String type, ReflectionB
230236
//A Map structure is introduced here using the same keys that are stored in REDIS.
231237
//No value is needed in this case.
232238
Map<String, RedisValueData> redisData = new HashMap<>();
233-
keys.forEach(key -> redisData.put(key, null));
239+
keys.forEach(
240+
key -> redisData.put(key, null));
234241
return new RedisKeyValueStore(redisData);
235242
}
236243

@@ -240,7 +247,8 @@ private RedisKeyValueStore createRedisInfoForKeysByField(ReflectionBasedRedisCli
240247
//A Map structure is introduced here using the same keys that are stored in REDIS.
241248
//The value for each one, since each key is of type HASH, correspond to the fields stored for that given key.
242249
Map<String, RedisValueData> redisData = new HashMap<>();
243-
keys.forEach(key -> redisData.put(key, new RedisValueData(redisClient.getHashFields(key))));
250+
keys.forEach(
251+
key -> redisData.put(key, new RedisValueData(redisClient.getHashFields(key))));
244252
return new RedisKeyValueStore(redisData);
245253
}
246254

client-java/controller/src/main/java/org/evomaster/client/java/controller/redis/RedisCommandExecutor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public static RedisInsertionResultsDto executeInsert(
3737
case "HSET":
3838
client.hashSet(dto.key, dto.field, dto.value);
3939
break;
40+
case "SADD":
41+
client.addMember(dto.key, dto.value);
42+
break;
4043
default:
4144
throw new IllegalArgumentException(
4245
"Unsupported Redis command: " + dto.command);

client-java/controller/src/main/java/org/evomaster/client/java/controller/redis/ReflectionBasedRedisClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class ReflectionBasedRedisClient {
2323
private static final String HGETALL_METHOD = "hgetall";
2424
private static final String HSET_METHOD = "hset";
2525
private static final String KEYS_METHOD = "keys";
26+
private static final String SADD_METHOD = "sadd";
2627
private static final String SELECT_METHOD = "select";
2728
private static final String SET_METHOD = "set";
2829
private static final String SHUTDOWN_METHOD = "shutdown";
@@ -117,6 +118,11 @@ public void hashSet(String key, String field, String value) {
117118
invoke(HSET_METHOD, key, field, value);
118119
}
119120

121+
/** SADD key */
122+
public void addMember(String key, String member) {
123+
invoke(SADD_METHOD, key, new String[]{member});
124+
}
125+
120126
/** SMEMBERS key */
121127
public Set<String> getSetMembers(String key) {
122128
Object result = invoke(SMEMBERS_METHOD, key);

0 commit comments

Comments
 (0)