@@ -13,10 +13,11 @@ import org.evomaster.client.java.controller.api.dto.problem.param.DerivedParamCh
1313import org.evomaster.client.java.controller.api.dto.problem.rpc.ScheduleTaskInvocationsDto
1414import org.evomaster.client.java.controller.api.dto.problem.rpc.ScheduleTaskInvocationsResult
1515import org.evomaster.core.BaseModule
16+ import org.evomaster.core.Main
1617import org.evomaster.core.problem.rest.schema.RestSchema
1718import org.evomaster.core.problem.rest.service.module.BlackBoxRestModule
1819import org.evomaster.core.problem.rest.service.module.ResourceRestModule
19- import org.evomaster.core.problem.rest.service.sampler.ResourceSampler
20+ import org.evomaster.core.problem.rest.service.sampler.AbstractRestSampler
2021import org.evomaster.core.remote.SutProblemException
2122import org.evomaster.core.remote.service.RemoteController
2223import org.evomaster.core.search.Individual
@@ -28,10 +29,17 @@ import java.lang.reflect.InvocationTargetException
2829import java.time.Duration
2930import kotlin.io.path.Path
3031import kotlin.sequences.filter
32+ import kotlin.text.contains
3133
3234
3335class SamplerVerifierTest {
3436
37+ companion object {
38+ init {
39+ Main .applyGlobalJVMSettings()
40+ }
41+ }
42+
3543
3644 @Test
3745 fun testBase () {
@@ -47,7 +55,7 @@ class SamplerVerifierTest {
4755
4856 val injector = getInjector(sutInfo, controllerInfo, false )
4957
50- val sampler = injector.getInstance(ResourceSampler ::class .java)
58+ val sampler = injector.getInstance(AbstractRestSampler ::class .java)
5159
5260 sampler.sample() // should not crash
5361 }
@@ -64,11 +72,8 @@ class SamplerVerifierTest {
6472 )
6573 assertTrue(tests.isNotEmpty())
6674 return tests
67- // FIXME once handling performance issues
68- .filter { ! it.displayName.contains(" adyen" ) }
6975 }
7076
71- @Disabled(" Performance issue" )
7277 @TestFactory
7378 fun testSamplingFromAllSchemasUnderCoreResourcesBlackBox (): Collection <DynamicTest >{
7479 val tests = sampleFromSchemasAndCheckInvariants(
@@ -81,8 +86,6 @@ class SamplerVerifierTest {
8186 }
8287
8388
84- // FIXME need to put back, and investigate performance bug
85- @Disabled(" Major issues with timeouts. Even before, took more than 1 hour. Need refactoring. Maven was not showing the failures (likely bug in Surefire)" )
8689 @TestFactory
8790 fun testSamplingFromAPIsGuru (): Collection <DynamicTest >{
8891 val tests = sampleFromSchemasAndCheckInvariants(
@@ -100,11 +103,22 @@ class SamplerVerifierTest {
100103 blackBox : Boolean
101104 ): Collection <DynamicTest > {
102105
106+ /*
107+ In theory, we should not have such a high timeout for this kind of tests.
108+ On local machine, all those analyses take at most 20s per test.
109+ Maybe performance can be improved, but, considering some files are MBs, it is not
110+ so unexpected. And it happens only for very large files.
111+ Problem though is that CI is much SLOWER, and tests do timeout.
112+ So that is why we have such high timeout, it is for CI.
113+ Still, if it starts to fail there, then we really need to look into performance issues.
114+ */
115+ val timeout = 60L
116+
103117 return scanForSchemas(relativePath, resourceFolder)
104118 .sorted().map {
105119 DynamicTest .dynamicTest(it) {
106120 System .gc()
107- assertTimeoutPreemptively(Duration .ofSeconds(30 ), it) {
121+ assertTimeoutPreemptively(Duration .ofSeconds(timeout ), it) {
108122 runInvariantCheck(it, 100 , blackBox)
109123 }
110124 }
@@ -121,16 +135,15 @@ class SamplerVerifierTest {
121135 .filter { it.isFile }
122136 .filter { ! skipSchema(it.path) }
123137 .map {
124- // val s = it.path.replace("\\", "/")
125- // .replace(relativePath, resourceFolder)
126138 val s = Path (it.absolutePath).toAbsolutePath().normalize().toString()
127139 s
128140 }.toList()
129141 }
130142
131143 private fun skipSchema (path : String ) : Boolean {
132- return skipDueToOldChecks(path) ||
133- skipDueToMissingPath(path)
144+ return skipDueToOldChecks(path)
145+ || skipDueToIssuesStillToInvestigate(path)
146+ || skipDueToMissingPath(path)
134147 || skipDueToHashTag(path)
135148 || skipDueToQuestionMarkInPath(path)
136149 || skipDueToMissingReference(path)
@@ -143,6 +156,29 @@ class SamplerVerifierTest {
143156 || skipDueToInvalidGenes(path)
144157 }
145158
159+ private fun skipDueToIssuesStillToInvestigate (path : String ) : Boolean {
160+ val toSkip = listOf (
161+ " api.video/1/openapi.yaml" ,
162+ " atlassian.com/jira/1001.0.0-SNAPSHOT/openapi.yaml" ,
163+ " cloud-elements.com/ecwid/api-v2/swagger.yaml" ,
164+ " github.com/api.github.com/1.1.4/openapi.yaml" ,
165+ " googleapis.com/discovery/v1/openapi.yaml" ,
166+ " here.com/positioning/2.1.1/openapi.yaml" ,
167+ " maif.local/otoroshi/1.5.0-dev/openapi.yaml" ,
168+ " mashape.com/geodb/1.0.0/swagger.yaml" ,
169+ " microsoft.com/cognitiveservices-Training/1.2/openapi.yaml" ,
170+ " microsoft.com/cognitiveservices-Training/2.0/openapi.yaml" ,
171+ " microsoft.com/cognitiveservices-Training/2.1/openapi.yaml" ,
172+ " microsoft.com/cognitiveservices-Training/2.2/openapi.yaml" ,
173+ " microsoft.com/cognitiveservices-Training/3.0/openapi.yaml" ,
174+ " microsoft.com/cognitiveservices-Training/3.1/openapi.yaml" ,
175+ " neutrinoapi.net/3.5.0/openapi.yaml" ,
176+ " openbankingproject.ch/1.3.8_2020-12-14 - Swiss edition 1.3.8.1-CH/openapi.yaml"
177+ )
178+
179+ return toSkip.any { path.contains(it) }
180+ }
181+
146182 private fun skipDueToOldChecks (path : String ) : Boolean {
147183 return path.endsWith(" features_service_null.json" ) // issue with parser
148184 || path.endsWith(" trace_v2.json" ) // no actions are parsed
@@ -244,7 +280,7 @@ class SamplerVerifierTest {
244280 || (contains(" visualstudio.com" ) && contains(" v1" ))
245281 || (contains(" youneedabudget.com" ) && contains(" 1.0.0" ))
246282 || (contains(" zenoti.com" ) && contains(" 1.0.0" )) // No actions for schema
247- || (contains(" zoom.us" ) && contains(" 2.0.0" )) // The incoming YAML document exceeds the limit: 3145728 code points.
283+ // || (contains("zoom.us") && contains("2.0.0")) // The incoming YAML document exceeds the limit: 3145728 code points.
248284 || (contains(" zuora.com" ) && contains(" 2021-08-20" )) // The incoming YAML document exceeds the limit: 3145728 code points.
249285 }
250286 }
@@ -381,7 +417,7 @@ class SamplerVerifierTest {
381417 throw e
382418 }
383419
384- val sampler = injector.getInstance(ResourceSampler ::class .java)
420+ val sampler = injector.getInstance(AbstractRestSampler ::class .java)
385421
386422 if (sampler.numberOfDistinctActions() == 0 ){
387423 throw IllegalStateException (" No actions for schema" )
0 commit comments