Skip to content

Commit afe69d3

Browse files
committed
investigating GA deadlock
1 parent 0f7da1f commit afe69d3

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

  • core-tests/integration-tests/core-it/src/test/kotlin/org/evomaster/core/problem/rest
  • core/src/main/kotlin/org/evomaster/core/search/gene/collection

core-tests/integration-tests/core-it/src/test/kotlin/org/evomaster/core/problem/rest/SamplerVerifierTest.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.evomaster.core.remote.SutProblemException
2222
import org.evomaster.core.remote.service.RemoteController
2323
import org.evomaster.core.search.Individual
2424
import org.evomaster.core.search.gene.Gene
25+
import org.evomaster.core.search.gene.collection.EnumGene
2526
import org.junit.jupiter.api.*
2627
import org.junit.jupiter.api.Assertions.assertTrue
2728
import java.io.File
@@ -43,7 +44,7 @@ class SamplerVerifierTest {
4344
fun debugIssue(): Collection<DynamicTest>{
4445
val tests = sampleFromSchemasAndCheckInvariants(
4546
//NOTE: can replace with a folder to debug
46-
"./src/test/resources/APIs_guru/asuarez.dev/searchly/1.0",
47+
"./src/test/resources/APIs_guru/asana.com/1.0",
4748
"APIs_guru",
4849
false)
4950
assertTrue(tests.isNotEmpty())
@@ -134,6 +135,9 @@ class SamplerVerifierTest {
134135
so we had to remove it
135136
*/
136137
//System.gc()
138+
139+
EnumGene.cleanCache() //due to this, these tests cannot be run in parallel
140+
137141
println("RUNNING: $it") // Surefire sucks at providing info for @TestFactory
138142
assertTimeoutPreemptively(Duration.ofSeconds(timeout), it) {
139143
runInvariantCheck(it, 100, blackBox)

core/src/main/kotlin/org/evomaster/core/search/gene/collection/EnumGene.kt

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ class EnumGene<T : Comparable<T>>(
5555

5656
private val log: Logger = LoggerFactory.getLogger(EnumGene::class.java)
5757

58+
/**
59+
* This was potential issue in IT where we parse thousands of specs...
60+
*/
61+
fun cleanCache(){
62+
synchronized(cache){
63+
cache.clear()
64+
}
65+
}
5866
}
5967

6068
val values: List<T>
@@ -83,23 +91,23 @@ class EnumGene<T : Comparable<T>>(
8391
val list = elements
8492
.toList() // need ordering to specify index of selection, so Set would not do
8593
.map { if (it is String) it.intern() as T else it } //if strings, make sure to intern them
86-
.sorted() //FIXME replace. only for debugging
87-
// .run {
88-
// if(valueNames == null){
89-
// sorted() // sort, to make meaningful list comparisons, but only if examples are not named.
90-
// // otherwise we lose vector alignment
91-
// } else {
92-
// this
93-
// }
94-
// }
94+
.run {
95+
if(valueNames == null){
96+
sorted() // sort, to make meaningful list comparisons, but only if examples are not named.
97+
// otherwise we lose vector alignment
98+
} else {
99+
this
100+
}
101+
}
95102

96103
/*
97104
we need to make sure that, if we are adding a list that has content equal to
98105
an already present list in the cache, we only use this latter
99106
*/
100107
synchronized(cache) {
101-
values = if (cache.contains(list)) {
102-
cache.find { it == list }!! as List<T> // equality based on content, not reference
108+
val x = cache.find { it == list } // equality based on content, not reference
109+
values = if (x != null) {
110+
x as List<T>
103111
} else {
104112
cache.add(list)
105113
list

0 commit comments

Comments
 (0)