Skip to content

Commit f10a54a

Browse files
authored
Merge pull request #1375 from WebFuzzing/core-driver-it
fixed and re-enabled core-driver-it tests
2 parents bdad980 + 30fbbda commit f10a54a

File tree

6 files changed

+100
-48
lines changed

6 files changed

+100
-48
lines changed

.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/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

pom.xml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
<springboot.version>2.5.4</springboot.version>
125125
<springboot3.version>3.1.5</springboot3.version>
126126
<springfox.version>3.0.0</springfox.version>
127-
<springdoc.version>1.6.9</springdoc.version>
128127
<jetty.version>9.4.29.v20200521</jetty.version>
129128
<slf4j.version>1.7.24</slf4j.version>
130129
<jersey.version>2.33</jersey.version>
@@ -929,24 +928,27 @@
929928
https://bugs.openjdk.java.net/browse/JDK-8266851
930929
-->
931930
<argLine>@{argLine} -ea -Xms1024m -Xmx4096m -Xss4m -Dfile.encoding=UTF-8 -Djdk.attach.allowAttachSelf=true -Duser.language=en -Duser.country=GB ${addOpens}</argLine>
932-
<!-- Needed for some weird bug in JDK used in CircleCI-->
933-
<!-- Commented out, as no longer using CircleCI-->
934-
<!-- <useSystemClassLoader>false</useSystemClassLoader>-->
935931
<runOrder>alphabetical</runOrder>
932+
<excludes>
933+
<!-- Do NOT run integration tests with surefire... use failsafe!!!-->
934+
<exclude>**/*IT.java</exclude>
935+
<exclude>**/*IT.kt</exclude>
936+
</excludes>
936937
</configuration>
937938
</plugin>
938939

939940
<!-- To run integration tests -->
940941
<plugin>
941942
<groupId>org.apache.maven.plugins</groupId>
942943
<artifactId>maven-failsafe-plugin</artifactId>
943-
<version>3.0.0-M4</version>
944+
<version>3.5.4</version>
944945
<configuration>
945946
<forkCount>1</forkCount>
946-
<redirectTestOutputToFile>true</redirectTestOutputToFile>
947+
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
947948
<rerunFailingTestsCount>2</rerunFailingTestsCount>
948-
<argLine>@{argLine} -ea -Xms1024m -Xmx4096m -Djdk.attach.allowAttachSelf=true ${addOpens}</argLine>
949-
<useSystemClassLoader>false</useSystemClassLoader>
949+
<trimStackTrace>false</trimStackTrace>
950+
<argLine>@{argLine} -ea -Xms1024m -Xmx4096m -Djdk.attach.allowAttachSelf=true -Duser.language=en -Duser.country=GB ${addOpens}</argLine>
951+
<runOrder>alphabetical</runOrder>
950952
</configuration>
951953
<executions>
952954
<execution>

0 commit comments

Comments
 (0)