Skip to content

Commit d49eef6

Browse files
committed
Merge branch 'master' of https://github.com/WebFuzzing/EvoMaster into finalize-taintable-gene
2 parents 20b7cdf + f10a54a commit d49eef6

16 files changed

Lines changed: 435 additions & 137 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ env:
4040
# https://github.com/WebFuzzing/EvoMaster/issues/447
4141
release-jdk: 21
4242
build-jdk: 17
43-
# latest-jdk: 21
4443
retention-days: 5
4544
debug: false # put to true if need to debug a specific test
46-
debugTestName: "org.evomaster.e2etests.spring.graphql.db.tree.DbTreeEMTest" # replace with test to debug
45+
debugTestName: "com.foo.base.BaseIT" # replace with test to debug
4746

4847
# This build is quite expensive (some hours), so we run it whole only on some JVM versions and OSs.
4948
# For the moment, we need to support JVM 8 and all following LTS versions (e.g, 11 and 17).
@@ -84,7 +83,7 @@ jobs:
8483
- name: Debug Test Case
8584
env:
8685
CI_env: GithubAction
87-
run: mvn test -Dtest=${{env.debugTestName}} -Dsurefire.failIfNoSpecifiedTests=false -DredirectTestOutputToFile=false
86+
run: mvn -B install -Dtest=${{env.debugTestName}} -Dsurefire.failIfNoSpecifiedTests=false -DredirectTestOutputToFile=false
8887

8988
full-build-base:
9089
runs-on: ubuntu-latest
@@ -122,7 +121,7 @@ jobs:
122121
env:
123122
NODE_OPTIONS: "--max_old_space_size=8000"
124123
with:
125-
report_paths: '**/target/surefire-reports/TEST-*.xml'
124+
report_paths: '**/target/*-reports/TEST-*.xml'
126125
# Upload coverage results
127126
# As of 2024, looks like a rate limiter is breaking the build.
128127
# As such, now we only upload from master branch, hoping it is enough.

client-java/controller/src/main/java/org/evomaster/client/java/controller/ExternalSutController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ public final void setupForGeneratedTest(){
9393
//In the past, we configured P6Spy here
9494
}
9595

96-
public void setNeedsJdk17Options(boolean needsJdk17Options) {
96+
/**
97+
* Unfortunately, the use of --add-opens in JDK 17+ has broken many things... :(
98+
* If you are using JDK 17 or above, you must set this to true
99+
* @param needsJdk17Options
100+
*/
101+
public final void setNeedsJdk17Options(boolean needsJdk17Options) {
97102
this.needsJdk17Options = needsJdk17Options;
98103
}
99104

core-tests/e2e-tests/spring-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/dtoreflectiveassert/DtoReflectiveAssertRest.kt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@ class DtoReflectiveAssertRest {
1414
return ResponseEntity.ok("OK")
1515
}
1616

17-
// TODO: Restore when support for ChoiceGene has been added
18-
// @PostMapping(path = ["/anyof"], consumes = [MediaType.APPLICATION_JSON_VALUE])
19-
// open fun anyof(@RequestBody body: AnyOfDto) : ResponseEntity<String>{
20-
// return ResponseEntity.ok("OK")
21-
// }
22-
23-
// TODO: Restore when support for ChoiceGene has been added
24-
// @PostMapping(path = ["/oneof"], consumes = [MediaType.APPLICATION_JSON_VALUE])
25-
// open fun oneof(@RequestBody body: OneOfDto) : ResponseEntity<String>{
26-
// return ResponseEntity.ok("OK")
27-
// }
17+
@PostMapping(path = ["/anyof"], consumes = [MediaType.APPLICATION_JSON_VALUE])
18+
open fun anyof(@RequestBody body: AnyOfDto) : ResponseEntity<String>{
19+
return ResponseEntity.ok("OK")
20+
}
21+
22+
@PostMapping(path = ["/oneof"], consumes = [MediaType.APPLICATION_JSON_VALUE])
23+
open fun oneof(@RequestBody body: OneOfDto) : ResponseEntity<String>{
24+
return ResponseEntity.ok("OK")
25+
}
2826

2927
@PostMapping(path = ["/primitiveTypes"], consumes = [MediaType.APPLICATION_JSON_VALUE])
3028
open fun primitiveTypes(@RequestBody body: PrimitiveTypesDto) : ResponseEntity<String>{

core-tests/e2e-tests/spring-rest-openapi-v3/src/main/resources/static/openapi-dto-reflective-assert.yaml

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapi: 3.0.3
22
info:
3-
title: allOf with Component Schemas
3+
title: Schema for E2E DTO Testing
44
version: 1.0.0
55

66
paths:
@@ -126,47 +126,46 @@ paths:
126126
responses:
127127
'200':
128128
description: OK
129-
# TODO: Restore when support for ChoiceGene has been added
130-
# /anyof:
131-
# post:
132-
# summary: Accepts either an email (component) or phone (inline)
133-
# requestBody:
134-
# required: true
135-
# content:
136-
# application/json:
137-
# schema:
138-
# anyOf:
139-
# - $ref: '#/components/schemas/EmailPayload'
140-
# - type: object
141-
# required: [phone]
142-
# properties:
143-
# phone:
144-
# type: string
145-
# responses:
146-
# '200':
147-
# description: OK
148-
# /oneof:
149-
# post:
150-
# summary: Accepts either cat or dog object (but not both)
151-
# requestBody:
152-
# required: true
153-
# content:
154-
# application/json:
155-
# schema:
156-
# oneOf:
157-
# - type: object
158-
# required: [cat]
159-
# properties:
160-
# cat:
161-
# type: string
162-
# - type: object
163-
# required: [mouse]
164-
# properties:
165-
# mouse:
166-
# type: string
167-
# responses:
168-
# '200':
169-
# description: OK
129+
/anyof:
130+
post:
131+
summary: Accepts either an email (component) or phone (inline)
132+
requestBody:
133+
required: true
134+
content:
135+
application/json:
136+
schema:
137+
anyOf:
138+
- $ref: '#/components/schemas/EmailPayload'
139+
- type: object
140+
required: [phone]
141+
properties:
142+
phone:
143+
type: string
144+
responses:
145+
'200':
146+
description: OK
147+
/oneof:
148+
post:
149+
summary: Accepts either cat or mouse object (but not both)
150+
requestBody:
151+
required: true
152+
content:
153+
application/json:
154+
schema:
155+
oneOf:
156+
- type: object
157+
required: [cat]
158+
properties:
159+
cat:
160+
type: string
161+
- type: object
162+
required: [mouse]
163+
properties:
164+
mouse:
165+
type: string
166+
responses:
167+
'200':
168+
description: OK
170169

171170
components:
172171
schemas:

core-tests/e2e-tests/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/dtoreflectiveassert/DtoReflectiveAssertEMTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class DtoReflectiveAssertEMTest: SpringTestBase() {
3737

3838
Assertions.assertTrue(solution.individuals.size >= 1)
3939
assertHasAtLeastOne(solution, HttpVerb.POST, 200, "/allof", "OK")
40+
assertHasAtLeastOne(solution, HttpVerb.POST, 200, "/anyof", "OK")
41+
assertHasAtLeastOne(solution, HttpVerb.POST, 200, "/oneof", "OK")
4042
assertHasAtLeastOne(solution, HttpVerb.POST, 200, "/primitiveTypes", "OK")
4143
assertHasAtLeastOne(solution, HttpVerb.POST, 200, "/parent", "OK")
4244
assertHasAtLeastOne(solution, HttpVerb.POST, 200, "/items-inline", "OK")
@@ -47,9 +49,8 @@ class DtoReflectiveAssertEMTest: SpringTestBase() {
4749
assertParentAndChildDtosCreated()
4850
assertAllOfDtoCreated()
4951
assertItemsInlineDtoCreated()
50-
// TODO: Restore when support for ChoiceGene has been added
51-
// assertAnyOfDtoCreated()
52-
// assertOneOfDtoCreated()
52+
assertAnyOfDtoCreated()
53+
assertOneOfDtoCreated()
5354
}
5455

5556
private fun assertPrimitiveTypeDtoCreated() {

core-tests/integration-tests/core-driver-it/pom.xml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
<groupId>org.springdoc</groupId>
3232
<artifactId>springdoc-openapi-ui</artifactId>
3333
</dependency>
34-
<dependency>
35-
<groupId>org.springdoc</groupId>
36-
<artifactId>springdoc-openapi-security</artifactId>
37-
</dependency>
34+
<!-- <dependency>-->
35+
<!-- <groupId>org.springdoc</groupId>-->
36+
<!-- <artifactId>springdoc-openapi-security</artifactId>-->
37+
<!-- </dependency>-->
3838
<dependency>
3939
<groupId>org.springdoc</groupId>
4040
<artifactId>springdoc-openapi-kotlin</artifactId>
@@ -46,6 +46,12 @@
4646
<artifactId>evomaster-client-java-controller</artifactId>
4747
<scope>test</scope>
4848
</dependency>
49+
<dependency>
50+
<groupId>org.evomaster</groupId>
51+
<artifactId>evomaster-client-java-instrumentation</artifactId>
52+
<version>${project.version}</version>
53+
<scope>test</scope>
54+
</dependency>
4955

5056
<dependency>
5157
<groupId>org.evomaster</groupId>
@@ -97,6 +103,14 @@
97103
<finalName>base</finalName>
98104
</configuration>
99105
</plugin>
106+
<plugin>
107+
<groupId>org.apache.maven.plugins</groupId>
108+
<artifactId>maven-surefire-plugin</artifactId>
109+
<configuration>
110+
<!-- Fucking surefire is running the IT tests for some fucking reasons... -->
111+
<skip>true</skip>
112+
</configuration>
113+
</plugin>
100114
<plugin>
101115
<groupId>org.apache.maven.plugins</groupId>
102116
<artifactId>maven-failsafe-plugin</artifactId>

core-tests/integration-tests/core-driver-it/src/test/kotlin/com/foo/base/BaseIT.kt

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ package com.foo.base
33
import org.evomaster.client.java.controller.InstrumentedSutStarter
44
import org.evomaster.client.java.controller.api.dto.ActionDto
55
import org.evomaster.core.remote.service.RemoteController
6-
import org.evomaster.ci.utils.CIUtils
76
import org.evomaster.core.remote.service.RemoteControllerImplementation
87
import org.junit.jupiter.api.*
98
import org.junit.jupiter.api.Assertions.*
109
import java.io.File
1110

1211

13-
@Disabled("No CI (Travis, CircleCI and GitHub) likes this test... :( ")
1412
class BaseIT {
1513

1614

@@ -19,26 +17,35 @@ class BaseIT {
1917
private val starter = InstrumentedSutStarter(driver)
2018
private lateinit var remote: RemoteController
2119

20+
2221
private fun setupJarAgent(){
2322

24-
val path = File("../client-java/instrumentation/target").walk()
23+
val folder = File("../../../client-java/instrumentation/target").absoluteFile
24+
if(!folder.exists()){
25+
throw IllegalStateException("Target folder does not exist: ${folder.absolutePath}")
26+
}
27+
28+
val files = folder.listFiles()
29+
30+
val path = files
2531
.filter { it.name.endsWith(".jar") }
2632
.find {
2733
it.name.matches(Regex("evomaster-client-java-instrumentation-\\d+\\.\\d+\\.\\d+(-SNAPSHOT)?\\.jar"))
28-
}!!
29-
.absolutePath
34+
}?.absolutePath
35+
if(path == null) {
36+
val names = files.map { it.name }
37+
throw IllegalStateException("evomaster-client-java-instrumentation jar file not found in target folder: ${folder.absolutePath}." +
38+
" | Content: ${names.joinToString(", ")}")
39+
}
3040

3141
System.setProperty("evomaster.instrumentation.jar.path", path)
3242
}
3343

3444
@JvmStatic
3545
@BeforeAll
3646
fun beforeAll() {
37-
//Travis and CircleCI do not like this test...
38-
CIUtils.skipIfOnTravis()
39-
CIUtils.skipIfOnCircleCI()
40-
4147
setupJarAgent()
48+
driver.setNeedsJdk17Options(true)
4249
driver.controllerPort = 0
4350
starter.start()
4451
remote = RemoteControllerImplementation("localhost", driver.controllerServerPort, false, false)
@@ -58,45 +65,66 @@ class BaseIT {
5865

5966
@Test
6067
fun testSearchCommands(){
61-
remote.startANewSearch()
62-
remote.startSUT()
68+
val startedNewSearch = remote.startANewSearch()
69+
assertTrue(startedNewSearch, "Failed to start new search")
70+
71+
val startedSUT = remote.startSUT()
72+
assertTrue(startedSUT, "Failed to start SUT")
6373

64-
remote.registerNewAction(ActionDto().apply { index = 0 })
74+
val actionRegistered = remote.registerNewAction(ActionDto().apply { index = 0 })
75+
assertTrue(actionRegistered, "Failed to register action")
6576

6677
val results = remote.getTestResults()
67-
assertNotNull(results)
78+
assertNotNull(results, "Failed to get results")
6879
assertEquals(0, results!!.targets.size)
6980
}
7081

7182
@Test
7283
fun testRestart(){
7384

7485
//make sure it is started
75-
assertTrue(remote.startSUT())
86+
assertTrue(remote.startSUT(), "Failed to start SUT")
7687
var info = remote.getSutInfo()
77-
assertNotNull(info)
88+
assertNotNull(info, "Failed to get SUT info")
7889

7990
//stop it
80-
assertTrue(remote.stopSUT())
91+
assertTrue(remote.stopSUT(), "Failed to stop SUT")
8192
info = remote.getSutInfo()
82-
assertNull(info)
93+
assertNull(info, "Failed to get SUT info after stop")
8394

95+
val n = 3
96+
for(i in 0 until n){
97+
driver.sutPort++
8498

85-
//start it again
86-
driver.sutPort++ //let's try to avoid issue with TCP port taking too long to be released
87-
assertTrue(remote.startSUT())
88-
info = remote.getSutInfo()
89-
assertNotNull(info)
99+
val started = remote.startSUT()
100+
val before = remote.getSutInfo()
101+
val stopped = remote.stopSUT()
102+
val after = remote.getSutInfo()
90103

91-
//stop it
92-
assertTrue(remote.stopSUT())
93-
info = remote.getSutInfo()
94-
assertNull(info)
104+
if(started && stopped && before != null && after == null) {
105+
//all good
106+
return
107+
}
108+
}
95109

96-
//start it again
97-
driver.sutPort++
98-
assertTrue(remote.startSUT())
99-
info = remote.getSutInfo()
100-
assertNotNull(info)
110+
fail<Any>("Failed to start/stop SUT with $n attempts")
111+
112+
//REFACTORED due to possible issues with port collisions
113+
// //start it again
114+
// driver.sutPort++ //let's try to avoid issue with TCP port taking too long to be released
115+
// assertTrue(remote.startSUT(), "Failed to re-start SUT on port ${driver.sutPort}")
116+
// info = remote.getSutInfo()
117+
// assertNotNull(info, "Failed to get SUT info after re-start")
118+
//
119+
// //stop it
120+
// assertTrue(remote.stopSUT(), "Failed to re-stop SUT")
121+
// info = remote.getSutInfo()
122+
// assertNull(info, "Failed to get SUT info after re-stop")
123+
//
124+
// //start it again
125+
// driver.sutPort++
126+
// assertTrue(remote.startSUT(), "Failed to re-start SUT in 3rd time on port ${driver.sutPort}")
127+
// info = remote.getSutInfo()
128+
// assertNotNull(info)
101129
}
102130
}

core-tests/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
<module>integration-tests</module>
1818
</modules>
1919

20+
<properties>
21+
<springdoc.version>1.6.9</springdoc.version>
22+
</properties>
23+
2024

2125

2226

0 commit comments

Comments
 (0)