Permalink
Browse files

config parameters for DSE and Search for SQL

  • Loading branch information...
arcuri82 committed Aug 24, 2018
1 parent 65aa440 commit e5291d79a00f30f28495cf2a804129faa111286b
@@ -223,12 +223,15 @@ class EMConfig {
}
}
if(generateSqlData && ! heuristicsForSQL){
if(shouldGenerateSqlData() && ! heuristicsForSQL){
throw IllegalArgumentException("Cannot generate SQL data if you not enable " +
"collecting heuristics with 'heuristicsForSQL'")
}
}
fun shouldGenerateSqlData() = generateSqlDataWithDSE || generateSqlDataWithSearch
//------------------------------------------------------------------------
//--- custom annotations
@@ -417,8 +420,11 @@ class EMConfig {
@Cfg("Tracking of SQL commands to improve test generation")
var heuristicsForSQL = false
@Cfg("Enable EvoMaster to generate SQL data with direct accesses to the database")
var generateSqlData = false
@Cfg("Enable EvoMaster to generate SQL data with direct accesses to the database. Use Dynamic Symbolic Execution")
var generateSqlDataWithDSE = false
@Cfg("Enable EvoMaster to generate SQL data with direct accesses to the database. Use a search algorithm")
var generateSqlDataWithSearch = false
@Cfg("When generating SQL data, how many new rows (max) to generate for each specific SQL Select")
@Min(1.0)
@@ -25,10 +25,14 @@ class RestIndividual(val actions: MutableList<RestAction>,
}
override fun seeGenes(): List<out Gene> {
override fun seeGenes(filter: GENE_FILTER): List<out Gene> {
return dbInitialization.flatMap(DbAction::seeGenes)
.plus(actions.flatMap(RestAction::seeGenes))
return when(filter){
GENE_FILTER.ALL -> dbInitialization.flatMap(DbAction::seeGenes)
.plus(actions.flatMap(RestAction::seeGenes))
GENE_FILTER.NO_SQL -> actions.flatMap(RestAction::seeGenes)
}
}
/*
@@ -1,7 +1,6 @@
package org.evomaster.core.problem.rest.service
import com.google.inject.Inject
import org.evomaster.core.EMConfig
import org.evomaster.core.database.EmptySelects
import org.evomaster.core.problem.rest.HttpVerb
import org.evomaster.core.problem.rest.RestCallAction
@@ -19,7 +18,7 @@ class RestStructureMutator : StructureMutator() {
override fun addInitializingActions(individual: EvaluatedIndividual<*>) {
if(! config.generateSqlData){
if(! config.shouldGenerateSqlData()){
return
}
@@ -57,6 +56,10 @@ class RestStructureMutator : StructureMutator() {
*/
missing = findMissing(es, ind)
}
if(config.generateSqlDataWithDSE){
//TODO DSE could be plugged in here
}
}
private fun findMissing(es: EmptySelects, ind: RestIndividual): Map<String, Set<String>> {
@@ -71,7 +74,6 @@ class RestStructureMutator : StructureMutator() {
}) // or we want all, and existing action has all columns
|| (c == "*" && a.table.columns.map { it.name.toLowerCase() }
.containsAll(a.selectedColumns.map { it.name.toLowerCase() }))
}
}
}
@@ -16,10 +16,12 @@ abstract class Individual{
*/
abstract fun copy() : Individual
enum class GENE_FILTER{ALL, NO_SQL}
/**
* Return a view of all the Genes in this chromosome/individual
*/
abstract fun seeGenes() : List<out Gene>
abstract fun seeGenes(filter: GENE_FILTER = GENE_FILTER.ALL) : List<out Gene>
/**
* An estimation of the "size" of this individual.
@@ -25,7 +25,10 @@ class StandardMutator<T> : Mutator<T>() where T : Individual {
return copy
}
val genesToMutate = copy.seeGenes().filter(Gene::isMutable)
val filter = if(config.generateSqlDataWithSearch) Individual.GENE_FILTER.ALL
else Individual.GENE_FILTER.NO_SQL
val genesToMutate = copy.seeGenes(filter).filter(Gene::isMutable)
val allGenes = copy.seeGenes().flatMap { it.flatView() }
if (genesToMutate.isEmpty()) {
@@ -15,7 +15,7 @@ class ConstantIndividual(val gene: IntegerGene) : Individual() {
return ConstantIndividual(gene.copy() as IntegerGene)
}
override fun seeGenes(): List<out Gene> {
override fun seeGenes(filter: GENE_FILTER): List<out Gene> {
return listOf(gene)
}
@@ -43,7 +43,7 @@ class OneMaxIndividual(val n: Int) : Individual() {
}
}
override fun seeGenes(): List<out Gene> {
override fun seeGenes(filter: GENE_FILTER): List<out Gene> {
return list
}
@@ -21,7 +21,7 @@ public void testRunEM() {
"--maxActionEvaluations", "10000",
"--stoppingCriterion", "FITNESS_EVALUATIONS",
"--heuristicsForSQL", "true",
"--generateSqlData", "false"
"--generateSqlDataWithSearch", "false"
};
Solution<RestIndividual> solution = (Solution<RestIndividual>) Main.initAndRun(args);
@@ -22,7 +22,7 @@ public void testRunEM() throws Throwable {
"--maxActionEvaluations", "3000",
"--stoppingCriterion", "FITNESS_EVALUATIONS",
"--heuristicsForSQL", "true",
"--generateSqlData", "false"
"--generateSqlDataWithSearch", "false"
};
Solution<RestIndividual> solution = (Solution<RestIndividual>) Main.initAndRun(args);
@@ -40,7 +40,7 @@ public void testRunEM() {
"--maxActionEvaluations", "20000",
"--stoppingCriterion", "FITNESS_EVALUATIONS",
"--heuristicsForSQL", "true",
"--generateSqlData", "true",
"--generateSqlDataWithSearch", "true",
"--maxTestSize", "1", //TODO Remove?
"--maxSqlInitActionsPerMissingData", "1" //TODO Remove?
};
@@ -68,7 +68,7 @@ public void testSteps() {
"--maxActionEvaluations", "1",
"--stoppingCriterion", "FITNESS_EVALUATIONS",
"--heuristicsForSQL", "true",
"--generateSqlData", "true",
"--generateSqlDataWithSearch", "true",
"--maxTestSize", "1"
};
@@ -13,7 +13,7 @@ class LinearIndividual(val id: DisruptiveGene<IntegerGene>, val k: IntegerGene)
return LinearIndividual(id.copy() as DisruptiveGene<IntegerGene>, k.copy() as IntegerGene)
}
override fun seeGenes(): List<out Gene> {
override fun seeGenes(filter: GENE_FILTER): List<out Gene> {
return listOf(id, k)
}
@@ -12,7 +12,7 @@ class PairIndividual(val x: IntegerGene, val y: IntegerGene) : Individual() {
return PairIndividual(x.copy() as IntegerGene, y.copy() as IntegerGene)
}
override fun seeGenes(): List<out Gene> {
override fun seeGenes(filter: GENE_FILTER): List<out Gene> {
return listOf(x,y)
}

0 comments on commit e5291d7

Please sign in to comment.