-
Notifications
You must be signed in to change notification settings - Fork 106
Redis data generation. #1487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Redis data generation. #1487
Changes from all commits
bbd0b8d
283c947
0ffc9ee
bbf4c03
22ad83d
8611b5a
7d65fb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.evomaster.client.java.controller.api.dto.database.execution; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Each time a Redis command is executed, we keep track of those that have a positive heuristic value associated. | ||
| * This class summarizes every failed command in a given execution. | ||
| */ | ||
| public class RedisExecutionsDto { | ||
|
|
||
| public RedisExecutionsDto() {} | ||
|
|
||
| public List<RedisFailedCommand> failedCommands = new ArrayList<>(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package org.evomaster.client.java.controller.api.dto.database.execution; | ||
|
|
||
| /** | ||
| * Each time a Redis command is executed, we keep track of which keys were involved, | ||
| * as well as relevant information such as the command type. | ||
| */ | ||
| public class RedisFailedCommand { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add class javadoc |
||
|
|
||
| /** | ||
| * Command keyword. Corresponds to a RedisCommandType label. | ||
| */ | ||
| public String command; | ||
|
|
||
| /** | ||
| * Command type. Corresponds to a RedisCommandType dataType. | ||
| */ | ||
| public String type; | ||
|
|
||
| /** | ||
| * Key involved. Could be null if the command does not have a key in the arguments. For example: KEYS (pattern). | ||
| */ | ||
| public String key; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add javadoc for fields |
||
|
|
||
| public RedisFailedCommand() {} | ||
|
|
||
| public RedisFailedCommand(String command, String key, String type) { | ||
| this.command = command; | ||
| this.key = key; | ||
| this.type = type; | ||
| } | ||
|
|
||
| public String getType() { | ||
| return type; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package org.evomaster.client.java.controller.api.dto.database.operations; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Class used to execute Redis commands. | ||
| * Each item in the insertions list corresponds to a command to be executed. | ||
| */ | ||
| public class RedisDatabaseCommandsDto { | ||
| public List<RedisInsertionDto> insertions = new ArrayList<>(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package org.evomaster.client.java.controller.api.dto.database.operations; | ||
|
|
||
| /** | ||
| * Contains data to be inserted into Redis. | ||
| */ | ||
| public class RedisInsertionDto { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Javadoc |
||
|
|
||
| /** The Redis key.*/ | ||
| public String key; | ||
|
|
||
| /** The serialized value to set for that key. */ | ||
| public String value; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package org.evomaster.client.java.controller.api.dto.database.operations; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class RedisInsertionResultsDto { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add class javadoc |
||
|
|
||
| public RedisInsertionResultsDto() {} | ||
|
|
||
| public List<Boolean> executionResults; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,7 @@ | |
| import org.evomaster.client.java.controller.api.ControllerConstants; | ||
| import org.evomaster.client.java.controller.api.Formats; | ||
| import org.evomaster.client.java.controller.api.dto.*; | ||
| import org.evomaster.client.java.controller.api.dto.database.operations.DatabaseCommandDto; | ||
| import org.evomaster.client.java.controller.api.dto.database.operations.InsertionResultsDto; | ||
| import org.evomaster.client.java.controller.api.dto.database.operations.MongoDatabaseCommandDto; | ||
| import org.evomaster.client.java.controller.api.dto.database.operations.MongoInsertionResultsDto; | ||
| import org.evomaster.client.java.controller.api.dto.database.operations.*; | ||
| import org.evomaster.client.java.controller.api.dto.problem.*; | ||
| import org.evomaster.client.java.controller.api.dto.problem.param.DeriveParamResponseDto; | ||
| import org.evomaster.client.java.controller.api.dto.problem.param.DerivedParamChangeReqDto; | ||
|
|
@@ -15,6 +12,8 @@ | |
| import org.evomaster.client.java.controller.api.dto.problem.rpc.ScheduleTaskInvocationsResult; | ||
| import org.evomaster.client.java.controller.mongo.MongoScriptRunner; | ||
| import org.evomaster.client.java.controller.problem.*; | ||
| import org.evomaster.client.java.controller.redis.RedisCommandExecutor; | ||
| import org.evomaster.client.java.controller.redis.ReflectionBasedRedisClient; | ||
| import org.evomaster.client.java.sql.QueryResult; | ||
| import org.evomaster.client.java.sql.SqlScriptRunner; | ||
| import org.evomaster.client.java.controller.problem.rpc.schema.LocalAuthSetupSchema; | ||
|
|
@@ -928,4 +927,57 @@ public Response executeMongoInsertion(MongoDatabaseCommandDto dto, @Context Http | |
| sutController.setExecutingInitMongo(false); | ||
| } | ||
| } | ||
|
|
||
| @Path(ControllerConstants.REDIS_INSERTION) | ||
| @Consumes(Formats.JSON_V1) | ||
| @POST | ||
| public Response executeRedisInsertion( | ||
| RedisDatabaseCommandsDto dto, | ||
| @Context HttpServletRequest httpServletRequest) { | ||
|
|
||
| assert trackRequestSource(httpServletRequest); | ||
|
|
||
| try { | ||
| sutController.setExecutingInitRedis(true); | ||
|
|
||
| ReflectionBasedRedisClient connection = | ||
| noKillSwitch(sutController::getRedisConnection); | ||
|
|
||
| if (connection == null) { | ||
| String msg = "No active Redis connection"; | ||
| SimpleLogger.warn(msg); | ||
| return Response.status(400) | ||
| .entity(WrappedResponseDto.withError(msg)).build(); | ||
| } | ||
|
|
||
| if (dto.insertions == null || dto.insertions.isEmpty()) { | ||
| String msg = "No input command"; | ||
| SimpleLogger.warn(msg); | ||
| return Response.status(400) | ||
| .entity(WrappedResponseDto.withError(msg)).build(); | ||
| } | ||
|
|
||
| RedisInsertionResultsDto redisResultsDto; | ||
| try { | ||
| redisResultsDto = RedisCommandExecutor.executeInsert( | ||
| connection, dto.insertions); | ||
| } catch (Exception e) { | ||
| String msg = "Failed to execute Redis command: " + e.getMessage(); | ||
| SimpleLogger.warn(msg); | ||
| return Response.status(400) | ||
| .entity(WrappedResponseDto.withError(msg)).build(); | ||
| } | ||
|
|
||
| return Response.status(200) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could redisResultsDto==null? |
||
| .entity(WrappedResponseDto.withData(redisResultsDto)).build(); | ||
|
|
||
| } catch (RuntimeException e) { | ||
| String msg = "Thrown exception: " + e.getMessage(); | ||
| SimpleLogger.error(msg, e); | ||
| return Response.status(500) | ||
| .entity(WrappedResponseDto.withError(msg)).build(); | ||
| } finally { | ||
| sutController.setExecutingInitRedis(false); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add class javadoc