-
Notifications
You must be signed in to change notification settings - Fork 29
redis-sample drivers #177
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
redis-sample drivers #177
Changes from 1 commit
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,17 @@ | ||
| FROM amazoncorretto:21-alpine-jdk | ||
|
|
||
| COPY ./dist/redis-sample-sut.jar . | ||
| COPY ./dist/jacocoagent.jar . | ||
|
|
||
|
|
||
|
|
||
| #ENV TOOL="undefined" | ||
| #ENV RUN="0" | ||
|
|
||
| ENTRYPOINT \ | ||
| java \ | ||
| # unfortunately dumponexit is completely unreliable in Docker :( | ||
| # -javaagent:jacocoagent.jar=destfile=./jacoco/redis-sample__${TOOL}__${RUN}__jacoco.exec,append=false,dumponexit=true \ | ||
| -javaagent:jacocoagent.jar=output=tcpserver,address=*,port=6300,append=false,dumponexit=false \ | ||
| -jar redis-sample-sut.jar \ | ||
| --server.port=8080 --spring.data.redis.host=db --spring.data.redis.port=6379 --spring.data.redis.password=53cret --spring.autoconfigure.exclude=org.springframework.boot.security.autoconfigure.web.servlet.ServletWebSecurityAutoConfiguration --app.numberOfRatings=5000 --app.ratingStars=5 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| services: | ||
| mitmproxy: | ||
| image: mitmproxy/mitmproxy:10.2.4 | ||
| user: "0:0" | ||
| environment: | ||
| MITM_LOG_DIR: /custom-logs | ||
| MITM_LOG_FILE: ${MITM_LOG_FILE:-minlog.csv} | ||
| command: > | ||
| mitmdump | ||
| --mode reverse:http://sut-redis-sample:8080 | ||
| --listen-host 0.0.0.0 | ||
| --listen-port 8080 | ||
| --set keep_host_header=true | ||
| -s /addons/minlog.py | ||
| volumes: | ||
| - ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs | ||
| - ./addons:/addons:ro | ||
| ports: | ||
| - "${HOST_PORT:-8080}:8080" | ||
| depends_on: | ||
| - sut-redis-sample | ||
| sut-redis-sample: | ||
| build: | ||
| dockerfile: ./dockerfiles/redis-sample.dockerfile | ||
| context: .. | ||
| environment: | ||
| AUTH_PORT: ${AUTH_PORT:-8081} | ||
| ports: | ||
| - "${JACOCO_PORT:-6300}:6300" | ||
| db: | ||
| image: redis:7.4-alpine | ||
| command: redis-server --requirepass 53cret |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
|
|
||
| <modules> | ||
| <module>person-controller</module> | ||
| <module>redis-sample</module> | ||
| </modules> | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,14 @@ | |
| <version>2.2.4</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <!-- MODIFIED--> | ||
| <!-- EvoMaster needs an OpenAPI schema; the SUT had none. --> | ||
| <dependency> | ||
| <groupId>org.springdoc</groupId> | ||
| <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> | ||
| <version>3.1.0</version> | ||
| </dependency> | ||
| <!-- MODIFIED--> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
|
|
@@ -107,6 +115,12 @@ | |
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-maven-plugin</artifactId> | ||
| <configuration> | ||
| <!-- MODIFIED--> | ||
| <!-- EMB expects a single self-contained "redis-sample-sut.jar". The classifier keeps | ||
|
Contributor
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. EMB? it is WFD now :) |
||
| the plain jar as the main artifact, which the embedded driver depends on. --> | ||
| <finalName>redis-sample</finalName> | ||
| <classifier>sut</classifier> | ||
| <!-- MODIFIED--> | ||
| <excludes> | ||
| <exclude> | ||
| <groupId>org.projectlombok</groupId> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
|
|
||
| <modules> | ||
| <module>person-controller</module> | ||
| <module>redis-sample</module> | ||
| </modules> | ||
|
|
||
| </project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>evomaster-benchmark-jdk21-em-embedded-rest-redis-sample</artifactId> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <parent> | ||
| <groupId>org.evomaster</groupId> | ||
| <artifactId>evomaster-benchmark-jdk21-em-embedded-rest</artifactId> | ||
| <version>4.3.1-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <!-- Embedded mode puts the SUT and the driver on one classpath, and the SUT's parent pom does | ||
| not apply here. Without this import, transitive dependencies win instead (eg testcontainers' | ||
| slf4j-api 1.7 replaces the 2.x Spring Boot 4 needs). --> | ||
| <dependencyManagement> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-dependencies</artifactId> | ||
| <version>4.1.0</version> | ||
| <type>pom</type> | ||
| <scope>import</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </dependencyManagement> | ||
|
|
||
| <dependencies> | ||
| <!-- The SUT as a library --> | ||
| <dependency> | ||
| <groupId>id.my.hendisantika</groupId> | ||
| <artifactId>spring-boot-redis-sample</artifactId> | ||
| <version>0.0.1-SNAPSHOT</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>testcontainers</artifactId> | ||
| <scope>compile</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| </project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| package em.embedded.redis.sample; | ||
|
|
||
| import id.my.hendisantika.springbootredissample.SpringBootRedisSampleApplication; | ||
| import org.evomaster.client.java.controller.EmbeddedSutController; | ||
| import org.evomaster.client.java.controller.InstrumentedSutStarter; | ||
| import org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto; | ||
| import org.evomaster.client.java.controller.api.dto.SutInfoDto; | ||
| 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.springframework.boot.SpringApplication; | ||
| import org.springframework.context.ConfigurableApplicationContext; | ||
| import org.testcontainers.containers.GenericContainer; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Class used to start/stop the SUT. This will be controller by the EvoMaster process | ||
| */ | ||
| public class EmbeddedEvoMasterController extends EmbeddedSutController { | ||
|
|
||
| private static final String REDIS_VERSION = "7.4-alpine"; | ||
|
|
||
| private static final int REDIS_PORT = 6379; | ||
|
|
||
| private static final String REDIS_PASSWORD = "53cret"; | ||
|
|
||
| private static final String SECURITY_EXCLUDE = | ||
| "org.springframework.boot.security.autoconfigure.web.servlet.ServletWebSecurityAutoConfiguration"; | ||
|
|
||
| private static final int NUMBER_OF_RATINGS = 5000; | ||
|
|
||
| private static final int RATING_STARS = 5; | ||
|
|
||
| private static final GenericContainer redis = new GenericContainer("redis:" + REDIS_VERSION) | ||
| .withCommand("redis-server", "--requirepass", REDIS_PASSWORD) | ||
| .withExposedPorts(REDIS_PORT); | ||
|
|
||
|
|
||
| public static void main(String[] args) { | ||
|
|
||
| int port = 40100; | ||
| if (args.length > 0) { | ||
| port = Integer.parseInt(args[0]); | ||
| } | ||
|
|
||
| EmbeddedEvoMasterController controller = new EmbeddedEvoMasterController(port); | ||
| InstrumentedSutStarter starter = new InstrumentedSutStarter(controller); | ||
|
|
||
| starter.start(); | ||
| } | ||
|
|
||
|
|
||
| private ConfigurableApplicationContext ctx; | ||
|
|
||
| public EmbeddedEvoMasterController() { | ||
| this(0); | ||
| } | ||
|
|
||
| public EmbeddedEvoMasterController(int port) { | ||
| setControllerPort(port); | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public String startSut() { | ||
|
|
||
| redis.start(); | ||
|
|
||
| ctx = SpringApplication.run(SpringBootRedisSampleApplication.class, new String[]{ | ||
| "--server.port=0", | ||
| "--spring.data.redis.host=" + redis.getHost(), | ||
| "--spring.data.redis.port=" + redis.getMappedPort(REDIS_PORT), | ||
| "--spring.data.redis.password=" + REDIS_PASSWORD, | ||
| "--spring.autoconfigure.exclude=" + SECURITY_EXCLUDE, | ||
| "--app.numberOfRatings=" + NUMBER_OF_RATINGS, | ||
| "--app.ratingStars=" + RATING_STARS | ||
| }); | ||
|
|
||
| return "http://localhost:" + getSutPort(); | ||
| } | ||
|
|
||
| protected int getSutPort() { | ||
| return (Integer) ((Map) ctx.getEnvironment() | ||
| .getPropertySources().get("server.ports").getSource()) | ||
| .get("local.server.port"); | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public boolean isSutRunning() { | ||
| return ctx != null && ctx.isRunning(); | ||
| } | ||
|
|
||
| @Override | ||
| public void stopSut() { | ||
|
|
||
| if (ctx != null) { | ||
| ctx.stop(); | ||
| ctx.close(); | ||
| ctx = null; | ||
| } | ||
|
|
||
| redis.stop(); | ||
| } | ||
|
|
||
| @Override | ||
| public String getPackagePrefixesToCover() { | ||
| return "id.my.hendisantika.springbootredissample."; | ||
| } | ||
|
|
||
| @Override | ||
| public void resetStateOfSUT() { | ||
| } | ||
|
Contributor
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. how are we resetting the state of Redis after each test execution? for SQL it is automated inside EvoMaster, but i don't think it is the case for any of the other DBs |
||
|
|
||
|
|
||
| @Override | ||
| public List<DbSpecification> getDbSpecifications() { | ||
| return null; | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public List<AuthenticationDto> getInfoForAuthentication() { | ||
| return null; | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public ProblemInfo getProblemInfo() { | ||
| return new RestProblem( | ||
| "http://localhost:" + getSutPort() + "/v3/api-docs", | ||
| null | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public SutInfoDto.OutputFormat getPreferredOutputFormat() { | ||
| return SutInfoDto.OutputFormat.JAVA_JUNIT_5; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
|
|
||
| <modules> | ||
| <module>person-controller</module> | ||
| <module>redis-sample</module> | ||
| </modules> | ||
|
|
||
| </project> | ||
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.
when editing code under
cs, remove any reference to EvoMaster, as WFD is of general use