Skip to content

Commit 803db8d

Browse files
committed
redis driver
1 parent 5046d42 commit 803db8d

20 files changed

Lines changed: 756 additions & 4 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ scripts/dockerize/dockerfiles
329329
/jdk_25_maven/cs/rest/jasper/target/
330330
/jdk_25_maven/em/external/rest/jasper/target/
331331
/jdk_25_maven/em/embedded/rest/jasper/target/
332+
/jdk_21_maven/cs/rest/redis-sample/target/
333+
/jdk_21_maven/em/external/rest/redis-sample/target/
334+
/jdk_21_maven/em/embedded/rest/redis-sample/target/
332335
/jdk_11_maven/em/embedded/rest/tracking-system/target/
333336
/jdk_11_maven/em/external/rest/tracking-system/target/
334337
/jdk_17_maven/em/embedded/rest/tiltaksgjennomforing/target/

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ How to setup authentication information, based on the current content of the ini
8585
Auth configuration files can found in the [auth](auth) folder.
8686

8787

88-
### REST: Java/Kotlin (38)
88+
### REST: Java/Kotlin (39)
8989

9090
* **Bibliothek** (MIT), [jdk_17_gradle/cs/rest/bibliothek](jdk_17_gradle/cs/rest/bibliothek), from [https://github.com/PaperMC/bibliothek](https://github.com/PaperMC/bibliothek)
9191

@@ -135,6 +135,8 @@ Auth configuration files can found in the [auth](auth) folder.
135135

136136
* **Quartz Manager** (Apache), [jdk_11_maven/cs/rest-gui/quartz-manager](jdk_11_maven/cs/rest-gui/quartz-manager), from [https://github.com/fabioformosa/quartz-manager](https://github.com/fabioformosa/quartz-manager)
137137

138+
* **Redis Sample** (not-known license), [jdk_21_maven/cs/rest/redis-sample](jdk_21_maven/cs/rest/redis-sample), from [https://github.com/hendisantika/spring-boot-redis-sample](https://github.com/hendisantika/spring-boot-redis-sample)
139+
138140
* **Reservations API** (not-known license), [jdk_11_gradle/cs/rest/reservations-api](jdk_11_gradle/cs/rest/reservations-api), from [https://github.com/cyrilgavala/reservations-api](https://github.com/cyrilgavala/reservations-api)
139141

140142
* **Restcountries** (MPL), [jdk_8_maven/cs/rest/original/restcountries](jdk_8_maven/cs/rest/original/restcountries), from [https://github.com/apilayer/restcountries](https://github.com/apilayer/restcountries)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM amazoncorretto:21-alpine-jdk
2+
3+
COPY ./dist/redis-sample-sut.jar .
4+
COPY ./dist/jacocoagent.jar .
5+
6+
7+
8+
#ENV TOOL="undefined"
9+
#ENV RUN="0"
10+
11+
ENTRYPOINT \
12+
java \
13+
# unfortunately dumponexit is completely unreliable in Docker :(
14+
# -javaagent:jacocoagent.jar=destfile=./jacoco/redis-sample__${TOOL}__${RUN}__jacoco.exec,append=false,dumponexit=true \
15+
-javaagent:jacocoagent.jar=output=tcpserver,address=*,port=6300,append=false,dumponexit=false \
16+
-jar redis-sample-sut.jar \
17+
--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

‎dockerfiles/redis-sample.yaml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
MITM_LOG_FILE: ${MITM_LOG_FILE:-minlog.csv}
8+
command: >
9+
mitmdump
10+
--mode reverse:http://sut-redis-sample:8080
11+
--listen-host 0.0.0.0
12+
--listen-port 8080
13+
--set keep_host_header=true
14+
-s /addons/minlog.py
15+
volumes:
16+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
17+
- ./addons:/addons:ro
18+
ports:
19+
- "${HOST_PORT:-8080}:8080"
20+
depends_on:
21+
- sut-redis-sample
22+
sut-redis-sample:
23+
build:
24+
dockerfile: ./dockerfiles/redis-sample.dockerfile
25+
context: ..
26+
environment:
27+
AUTH_PORT: ${AUTH_PORT:-8081}
28+
ports:
29+
- "${JACOCO_PORT:-6300}:6300"
30+
db:
31+
image: redis:7.4-alpine
32+
command: redis-server --requirepass 53cret

‎experiments/wb-exp.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def __init__(self, name, platform):
201201
Sut("ohsome-api", JDK_17),
202202
Sut("pay-publicapi",JDK_11),
203203
Sut("person-controller",JDK_21),
204+
Sut("redis-sample", JDK_21),
204205
Sut("proxyprint", JDK_8),
205206
Sut("quartz-manager", JDK_11),
206207
Sut("reservations-api", JDK_11),

‎jdk_21_maven/cs/rest/pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<modules>
1616
<module>person-controller</module>
17+
<module>redis-sample</module>
1718
</modules>
1819

1920

‎jdk_21_maven/cs/rest/redis-sample/pom.xml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@
8383
<version>2.2.4</version>
8484
<scope>test</scope>
8585
</dependency>
86+
<!-- MODIFIED-->
87+
<!-- EvoMaster needs an OpenAPI schema; the SUT had none. -->
88+
<dependency>
89+
<groupId>org.springdoc</groupId>
90+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
91+
<version>3.1.0</version>
92+
</dependency>
93+
<!-- MODIFIED-->
8694
</dependencies>
8795

8896
<build>
@@ -107,6 +115,12 @@
107115
<groupId>org.springframework.boot</groupId>
108116
<artifactId>spring-boot-maven-plugin</artifactId>
109117
<configuration>
118+
<!-- MODIFIED-->
119+
<!-- EMB expects a single self-contained "redis-sample-sut.jar". The classifier keeps
120+
the plain jar as the main artifact, which the embedded driver depends on. -->
121+
<finalName>redis-sample</finalName>
122+
<classifier>sut</classifier>
123+
<!-- MODIFIED-->
110124
<excludes>
111125
<exclude>
112126
<groupId>org.projectlombok</groupId>

‎jdk_21_maven/cs/rest/redis-sample/src/main/java/id/my/hendisantika/springbootredissample/boot/CreateBooks.java‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.springframework.core.annotation.Order;
1313
import org.springframework.core.io.Resource;
1414
import org.springframework.core.io.ResourceLoader;
15+
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
1516
import org.springframework.stereotype.Component;
1617

1718
import java.io.File;
@@ -51,9 +52,13 @@ public void run(String... args) throws Exception {
5152
TypeReference<List<Book>> typeReference = new TypeReference<>() {
5253
};
5354

54-
Resource resource = resourceLoader.getResource("classpath:/data/books/");
55-
File directory = resource.getFile();
56-
File[] files = directory.listFiles((dir, name) -> name.endsWith(".json"));
55+
// MODIFIED
56+
// In the packaged jar getFile() throws FileNotFoundException: class path resource
57+
// [data/books/] cannot be resolved to absolute file path -> startup dies.
58+
File[] files = Arrays.stream(new PathMatchingResourcePatternResolver()
59+
.getResources("classpath*:/data/books/*.json"))
60+
.map(r -> new File(r.getFilename())).toArray(File[]::new);
61+
// MODIFIED
5762

5863
if (files == null || files.length == 0) {
5964
log.warn("No JSON files found in /data/books/ directory.");

‎jdk_21_maven/em/embedded/rest/pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
<modules>
1515
<module>person-controller</module>
16+
<module>redis-sample</module>
1617
</modules>
1718

1819
</project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<artifactId>evomaster-benchmark-jdk21-em-embedded-rest-redis-sample</artifactId>
8+
<packaging>jar</packaging>
9+
10+
<parent>
11+
<groupId>org.evomaster</groupId>
12+
<artifactId>evomaster-benchmark-jdk21-em-embedded-rest</artifactId>
13+
<version>4.3.1-SNAPSHOT</version>
14+
</parent>
15+
16+
<!-- Embedded mode puts the SUT and the driver on one classpath, and the SUT's parent pom does
17+
not apply here. Without this import, transitive dependencies win instead (eg testcontainers'
18+
slf4j-api 1.7 replaces the 2.x Spring Boot 4 needs). -->
19+
<dependencyManagement>
20+
<dependencies>
21+
<dependency>
22+
<groupId>org.springframework.boot</groupId>
23+
<artifactId>spring-boot-dependencies</artifactId>
24+
<version>4.1.0</version>
25+
<type>pom</type>
26+
<scope>import</scope>
27+
</dependency>
28+
</dependencies>
29+
</dependencyManagement>
30+
31+
<dependencies>
32+
<!-- The SUT as a library -->
33+
<dependency>
34+
<groupId>id.my.hendisantika</groupId>
35+
<artifactId>spring-boot-redis-sample</artifactId>
36+
<version>0.0.1-SNAPSHOT</version>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.testcontainers</groupId>
41+
<artifactId>testcontainers</artifactId>
42+
<scope>compile</scope>
43+
</dependency>
44+
</dependencies>
45+
46+
</project>

0 commit comments

Comments
 (0)