Skip to content

Commit e4c87e2

Browse files
committed
external driver
1 parent 1e12cbc commit e4c87e2

6 files changed

Lines changed: 263 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,5 @@ scripts/dockerize/dockerfiles
328328
/jdk_17_maven/em/external/rest/tiltaksgjennomforing-api/target/
329329

330330
jdk_17_maven/cs/rest/ohsome-api/target/
331+
jdk_17_maven/em/embedded/rest/ohsome-api/target/
332+
jdk_17_maven/em/external/rest/ohsome-api/target/
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
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+
<parent>
7+
<groupId>org.evomaster</groupId>
8+
<artifactId>evomaster-benchmark-jdk17-em-external-rest</artifactId>
9+
<version>3.4.1-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>evomaster-benchmark-jdk17-em-external-rest-ohsome-api</artifactId>
13+
<packaging>jar</packaging>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.testcontainers</groupId>
18+
<artifactId>testcontainers</artifactId>
19+
<scope>compile</scope>
20+
</dependency>
21+
</dependencies>
22+
23+
<build>
24+
<plugins>
25+
<plugin>
26+
<groupId>org.apache.maven.plugins</groupId>
27+
<artifactId>maven-shade-plugin</artifactId>
28+
<executions>
29+
<execution>
30+
<phase>package</phase>
31+
<goals>
32+
<goal>shade</goal>
33+
</goals>
34+
<configuration>
35+
<finalName>ohsome-api-evomaster-runner</finalName>
36+
<transformers>
37+
<transformer
38+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
39+
<manifestEntries>
40+
<Main-Class>em.external.ohsome.ExternalEvoMasterController
41+
</Main-Class>
42+
<Premain-Class>org.evomaster.client.java.instrumentation.InstrumentingAgent
43+
</Premain-Class>
44+
<Agent-Class>org.evomaster.client.java.instrumentation.InstrumentingAgent
45+
</Agent-Class>
46+
<Can-Redefine-Classes>true</Can-Redefine-Classes>
47+
<Can-Retransform-Classes>true</Can-Retransform-Classes>
48+
</manifestEntries>
49+
</transformer>
50+
</transformers>
51+
<filters>
52+
<filter>
53+
<!-- to deal with signed jars -->
54+
<artifact>*:*</artifact>
55+
<excludes>
56+
<exclude>META-INF/*.SF</exclude>
57+
<exclude>META-INF/*.DSA</exclude>
58+
<exclude>META-INF/*.RSA</exclude>
59+
</excludes>
60+
</filter>
61+
</filters>
62+
</configuration>
63+
</execution>
64+
</executions>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
69+
70+
</project>
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
package em.external.ohsome;
2+
3+
import org.evomaster.client.java.controller.ExternalSutController;
4+
import org.evomaster.client.java.controller.InstrumentedSutStarter;
5+
import org.evomaster.client.java.controller.api.dto.SutInfoDto;
6+
import org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto;
7+
import org.evomaster.client.java.controller.problem.ProblemInfo;
8+
import org.evomaster.client.java.controller.problem.RestProblem;
9+
import org.evomaster.client.java.sql.DbSpecification;
10+
11+
import java.io.File;
12+
import java.io.InputStream;
13+
import java.nio.file.Files;
14+
import java.nio.file.Path;
15+
import java.nio.file.Paths;
16+
import java.nio.file.StandardCopyOption;
17+
import java.sql.Connection;
18+
import java.util.*;
19+
20+
public class ExternalEvoMasterController extends ExternalSutController {
21+
22+
public static void main(String[] args) {
23+
24+
int controllerPort = 40100;
25+
if (args.length > 0) {
26+
controllerPort = Integer.parseInt(args[0]);
27+
}
28+
int sutPort = 12345;
29+
if (args.length > 1) {
30+
sutPort = Integer.parseInt(args[1]);
31+
}
32+
String jarLocation = "cs/rest/ohsome-api/target";
33+
if (args.length > 2) {
34+
jarLocation = args[2];
35+
}
36+
if(! jarLocation.endsWith(".jar")) {
37+
jarLocation += "/ohsome-api-sut.jar";
38+
}
39+
40+
int timeoutSeconds = 120;
41+
if(args.length > 3){
42+
timeoutSeconds = Integer.parseInt(args[3]);
43+
}
44+
String command = "java";
45+
if(args.length > 4){
46+
command = args[4];
47+
}
48+
49+
50+
ExternalEvoMasterController controller =
51+
new ExternalEvoMasterController(controllerPort, jarLocation,
52+
sutPort, timeoutSeconds, command);
53+
controller.setNeedsJdk17Options(true);
54+
InstrumentedSutStarter starter = new InstrumentedSutStarter(controller);
55+
56+
starter.start();
57+
}
58+
59+
private final int timeoutSeconds;
60+
private final int sutPort;
61+
private String jarLocation;
62+
private final String tmpDir;
63+
private Connection sqlConnection;
64+
private final String DB_FILE = "heidelberg.mv.db";
65+
66+
private List<DbSpecification> dbSpecification;
67+
68+
public ExternalEvoMasterController(){
69+
this(40100, "../core/target", 12345, 120, "java");
70+
}
71+
72+
public ExternalEvoMasterController(String jarLocation) {
73+
this();
74+
this.jarLocation = jarLocation;
75+
}
76+
77+
public ExternalEvoMasterController(
78+
int controllerPort, String jarLocation, int sutPort, int timeoutSeconds, String command
79+
) {
80+
81+
if(jarLocation==null || jarLocation.isEmpty()){
82+
throw new IllegalArgumentException("Missing jar location");
83+
}
84+
85+
this.sutPort = sutPort;
86+
this.jarLocation = jarLocation;
87+
this.timeoutSeconds = timeoutSeconds;
88+
setControllerPort(controllerPort);
89+
setJavaCommand(command);
90+
String base = Paths.get(jarLocation).toAbsolutePath().getParent().normalize().toString();
91+
tmpDir = base + "/temp/tmp_ohsome_api/temp_"+sutPort;
92+
createDBFile();
93+
}
94+
95+
private void createDBFile() {
96+
try{
97+
if(!Files.exists(Path.of(tmpDir))) {
98+
Files.createDirectories(Path.of(tmpDir));
99+
}
100+
Files.copy(getClass().getClassLoader().getResourceAsStream(DB_FILE), Path.of(tmpDir,DB_FILE), StandardCopyOption.REPLACE_EXISTING);
101+
} catch (Exception e){
102+
throw new RuntimeException(e);
103+
}
104+
}
105+
106+
@Override
107+
public String[] getInputParameters() {
108+
return new String[]{
109+
"--server.port=" + sutPort,
110+
"--management.server.port=-1",
111+
"--logging.level.root=OFF",
112+
"--logging.level.org.springframework=INFO",
113+
"--database.db=" + tmpDir + "/heidelberg",
114+
};
115+
}
116+
117+
public String[] getJVMParameters() {
118+
return new String[]{};
119+
}
120+
121+
@Override
122+
public String getBaseURL() {
123+
return "http://localhost:" + sutPort;
124+
}
125+
126+
@Override
127+
public String getPathToExecutableJar() {
128+
return jarLocation;
129+
}
130+
131+
@Override
132+
public String getLogMessageOfInitializedServer() {
133+
return "Tomcat started on port";
134+
}
135+
136+
@Override
137+
public long getMaxAwaitForInitializationInSeconds() {
138+
return timeoutSeconds;
139+
}
140+
141+
@Override
142+
public void preStart() {
143+
}
144+
145+
@Override
146+
public void postStart() {
147+
}
148+
149+
@Override
150+
public void preStop() {
151+
152+
}
153+
154+
@Override
155+
public void postStop() {
156+
}
157+
158+
@Override
159+
public String getPackagePrefixesToCover() {
160+
return "org.heigit.ohsome.ohsomeapi.";
161+
}
162+
163+
@Override
164+
public ProblemInfo getProblemInfo() {
165+
return new RestProblem(
166+
"http://localhost:" + sutPort + "/docs?group=Data%20Aggregation",
167+
null
168+
);
169+
}
170+
171+
@Override
172+
public SutInfoDto.OutputFormat getPreferredOutputFormat() {
173+
return SutInfoDto.OutputFormat.JAVA_JUNIT_5;
174+
}
175+
176+
@Override
177+
public List<AuthenticationDto> getInfoForAuthentication() {
178+
return null;
179+
}
180+
181+
@Override
182+
public List<DbSpecification> getDbSpecifications() {
183+
return dbSpecification;
184+
}
185+
186+
@Override
187+
public void resetStateOfSUT() {
188+
}
189+
}
Binary file not shown.

jdk_17_maven/em/external/rest/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<modules>
1616
<module>familie-ba-sak</module>
1717
<module>tiltaksgjennomforing-api</module>
18+
<module>ohsome-api</module>
1819
</modules>
1920

2021
</project>

statistics/data.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ TRUE,features-service,REST,Java,JDK 8,Maven,39,2275,H2,Apache,18,FALSE,https://g
1616
TRUE,gestaohospital,REST,Java,JDK 8,Maven,33,3506,MongoDB,UNDEFINED,20,FALSE,https://github.com/ValchanOficial/GestaoHospital
1717
TRUE,languagetool,REST,Java,JDK 8,Maven,1385,174781,,LGPL,2,FALSE,https://github.com/languagetool-org/languagetool
1818
TRUE,ocvn,REST,Java,JDK 8,Maven,526,45521,H2;MongoDB,MIT,258,TRUE,https://github.com/devgateway/ocvn
19+
TRUE,ohsome-api,REST,Java,JDK 17,Maven,87,14166,OSHDB,AGPL-3.0,134,FALSE,https://github.com/GIScience/ohsome-api
1920
TRUE,proxyprint,REST,Java,JDK 8,Maven,73,8338,H2,Apache,74,TRUE,https://github.com/ProxyPrint/proxyprint-kitchen
2021
TRUE,rest-ncs,REST,Java,JDK 8,Maven,9,605,,UNDEFINED,6,FALSE,UNDEFINED
2122
TRUE,rest-news,REST,Kotlin,JDK 8,Maven,11,857,H2,LGPL,7,FALSE,https://github.com/arcuri82/testing_security_development_enterprise_systems

0 commit comments

Comments
 (0)