Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ abstract class ApiWsStructureMutator : StructureMutator() {
val oldSqlActions = mutableListOf<EnvironmentAction>().plus(ind.seeInitializingActions())

val failedWhereQueries = evaluatedIndividual.fitness.getViewOfAggregatedFailedWhereQueries()
.filter { it.isNotBlank() }
Comment thread
jgaleotti marked this conversation as resolved.
Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is it possible that a query is empty? or is it possibly a bug where those queries are collected? see below:

Image

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! You are right, I moved the fix to that function

val addedSqlInsertions = handleFailedWhereSQL(ind, fw, failedWhereQueries, mutatedGenes, sampler)

ind.repairInitializationActions(randomness)
Expand Down
35 changes: 35 additions & 0 deletions core/src/test/kotlin/org/evomaster/core/search/FitnessValueTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import org.evomaster.client.java.controller.api.dto.BootTimeInfoDto
import org.evomaster.client.java.controller.api.dto.TargetInfoDto
import org.evomaster.client.java.instrumentation.shared.ObjectiveNaming
import org.evomaster.core.search.service.IdMapper
import org.evomaster.core.sql.DatabaseExecution
import org.evomaster.core.sql.SqlExecutionInfo
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test

Expand Down Expand Up @@ -123,4 +125,37 @@ class FitnessValueTest {
assertEquals(3, linesInfo.searchTime)
}

@Test
fun testAggregatedFailedWhereQueriesExcludesBlankEntries() {
val fv = FitnessValue(1.0)

val execution = DatabaseExecution(
queriedData = emptyMap(),
updatedData = emptyMap(),
insertedData = emptyMap(),
failedWhere = emptyMap(),
deletedData = emptyList(),
numberOfSqlCommands = 3,
sqlParseFailureCount = 0,
executionInfo = listOf(
SqlExecutionInfo("SELECT * FROM foo WHERE id = 1", false, 10L),
SqlExecutionInfo("", false, 5L),
SqlExecutionInfo(" ", false, 5L),
SqlExecutionInfo("SELECT * FROM bar WHERE name = 'x'", false, 8L)
)
)
fv.setDatabaseExecution(0, execution)
fv.aggregateDatabaseData()

val allQueries = fv.getViewOfAggregatedFailedWhereQueries()
assertEquals(4, allQueries.size)

// Simulate the filter applied in ApiWsStructureMutator before sending queries to the solver
val nonBlankQueries = allQueries.filter { it.isNotBlank() }
assertEquals(2, nonBlankQueries.size)
assertTrue(nonBlankQueries.none { it.isBlank() })
assertTrue(nonBlankQueries.contains("SELECT * FROM foo WHERE id = 1"))
assertTrue(nonBlankQueries.contains("SELECT * FROM bar WHERE name = 'x'"))
}

}
Loading