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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ scripts/dockerize/dockerfiles
/jdk_25_maven/cs/rest/jasper/target/
/jdk_25_maven/em/external/rest/jasper/target/
/jdk_25_maven/em/embedded/rest/jasper/target/
/jdk_21_maven/cs/rest/redis-sample/target/
/jdk_21_maven/em/external/rest/redis-sample/target/
/jdk_21_maven/em/embedded/rest/redis-sample/target/
/jdk_11_maven/em/embedded/rest/tracking-system/target/
/jdk_11_maven/em/external/rest/tracking-system/target/
/jdk_17_maven/em/embedded/rest/tiltaksgjennomforing/target/
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ How to setup authentication information, based on the current content of the ini
Auth configuration files can found in the [auth](auth) folder.


### REST: Java/Kotlin (38)
### REST: Java/Kotlin (39)

* **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)

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

* **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)

* **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)

* **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)

* **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)
Expand Down
17 changes: 17 additions & 0 deletions dockerfiles/redis-sample.dockerfile
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
32 changes: 32 additions & 0 deletions dockerfiles/redis-sample.yaml
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
1 change: 1 addition & 0 deletions experiments/wb-exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def __init__(self, name, platform):
Sut("ohsome-api", JDK_17),
Sut("pay-publicapi",JDK_11),
Sut("person-controller",JDK_21),
Sut("redis-sample", JDK_21),
Sut("proxyprint", JDK_8),
Sut("quartz-manager", JDK_11),
Sut("reservations-api", JDK_11),
Expand Down
1 change: 1 addition & 0 deletions jdk_21_maven/cs/rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<modules>
<module>person-controller</module>
<module>redis-sample</module>
</modules>


Expand Down
14 changes: 14 additions & 0 deletions jdk_21_maven/cs/rest/redis-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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
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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.core.annotation.Order;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.stereotype.Component;

import java.io.File;
Expand Down Expand Up @@ -51,9 +52,13 @@
TypeReference<List<Book>> typeReference = new TypeReference<>() {
};

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

if (files == null || files.length == 0) {
log.warn("No JSON files found in /data/books/ directory.");
Expand All @@ -61,7 +66,7 @@
}

Map<String, Category> categories = new HashMap<>();
log.info("files -> {}", files);

Check warning on line 69 in jdk_21_maven/cs/rest/redis-sample/src/main/java/id/my/hendisantika/springbootredissample/boot/CreateBooks.java

View workflow job for this annotation

GitHub Actions / direct-builds (ubuntu-latest, jdk_21_maven)

non-varargs call of varargs method with inexact argument type for last parameter;

Check warning on line 69 in jdk_21_maven/cs/rest/redis-sample/src/main/java/id/my/hendisantika/springbootredissample/boot/CreateBooks.java

View workflow job for this annotation

GitHub Actions / direct-builds (macos-latest, jdk_21_maven)

non-varargs call of varargs method with inexact argument type for last parameter;

Arrays.stream(files).forEach(file -> {
try {
Expand Down
1 change: 1 addition & 0 deletions jdk_21_maven/em/embedded/rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<modules>
<module>person-controller</module>
<module>redis-sample</module>
</modules>

</project>
46 changes: 46 additions & 0 deletions jdk_21_maven/em/embedded/rest/redis-sample/pom.xml
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() {
}


@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;
}
}
1 change: 1 addition & 0 deletions jdk_21_maven/em/external/rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<modules>
<module>person-controller</module>
<module>redis-sample</module>
</modules>

</project>
Loading
Loading