Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql-multidb-v3 #1140

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8d271a6
starting preparing E2E tests
arcuri82 Dec 3, 2024
fe202e6
trying to get rid off JPA in new E2E
arcuri82 Dec 4, 2024
82e2f87
refactoring and cleaning
arcuri82 Dec 16, 2024
258a639
more refactoring
arcuri82 Dec 16, 2024
949f268
moe fixes
arcuri82 Dec 16, 2024
effb4c0
refactoring package location
arcuri82 Dec 16, 2024
506e417
more cleaning and refactoring for DbCleaner
arcuri82 Dec 16, 2024
fa9fee1
fix for failing test
arcuri82 Dec 16, 2024
5c5a4e4
more fixes related to schema in table ids
arcuri82 Dec 17, 2024
a572f05
more cleaning and fixing
arcuri82 Dec 18, 2024
5707132
add calculateStringSimilarityScoreWithTableName
man-zhang Jan 2, 2025
434bef4
fix
man-zhang Jan 2, 2025
26da911
Merge branch 'master' into sql-multidb-v3
man-zhang Jan 2, 2025
507defb
fix due to merge
man-zhang Jan 2, 2025
db7fd1f
Merge branch 'master' of https://github.com/WebFuzzing/EvoMaster into…
arcuri82 Jan 7, 2025
04d66bd
refactoring table id in dto
arcuri82 Jan 8, 2025
ba60dfc
fix for some tests
arcuri82 Jan 8, 2025
cd98db9
introducing TableId
arcuri82 Jan 8, 2025
cdb2a64
starting refactoring for TableId
arcuri82 Jan 8, 2025
ec43583
more on TableId
arcuri82 Jan 15, 2025
392023d
Merge branch 'master' of https://github.com/WebFuzzing/EvoMaster into…
arcuri82 Jan 15, 2025
dbd2e90
more refactoring
arcuri82 Jan 17, 2025
3483d4c
yet on the journey to refactor TableId
arcuri82 Jan 17, 2025
0f6c787
some more refactoring
arcuri82 Jan 20, 2025
9bfb18e
Merge branch 'master' of https://github.com/EMResearch/EvoMaster into…
arcuri82 Feb 19, 2025
f47182e
resolve issues in SimpleDeriveR2T.kt due to updates
man-zhang Feb 19, 2025
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 @@ -24,6 +24,7 @@
import org.evomaster.client.java.controller.api.dto.database.schema.DbInfoDto;
import org.evomaster.client.java.controller.api.dto.database.schema.ExtraConstraintsDto;
import org.evomaster.client.java.controller.api.dto.MockDatabaseDto;
import org.evomaster.client.java.controller.api.dto.database.schema.TableIdDto;
import org.evomaster.client.java.controller.api.dto.problem.RPCProblemDto;
import org.evomaster.client.java.controller.api.dto.problem.rpc.*;
import org.evomaster.client.java.sql.DbCleaner;
Expand Down Expand Up @@ -374,9 +375,11 @@ private void computeSQLHeuristics(ExtraHeuristicsDto dto, List<AdditionalInfo> a
if (!additionalInfoList.isEmpty()) {
AdditionalInfo last = additionalInfoList.get(additionalInfoList.size() - 1);
last.getSqlInfoData().stream().forEach(it -> {
// String sql = it.getCommand();
try {
final SqlExecutionLogDto sqlExecutionLogDto = new SqlExecutionLogDto(it.getSqlCommand(), it.hasThrownSqlException(), it.getExecutionTime());
SqlExecutionLogDto sqlExecutionLogDto = new SqlExecutionLogDto(
it.getSqlCommand(),
it.hasThrownSqlException(),
it.getExecutionTime());
sqlHandler.handle(sqlExecutionLogDto);
} catch (Exception e) {
SimpleLogger.error("FAILED TO HANDLE SQL COMMAND: " + it.getSqlCommand());
Expand Down Expand Up @@ -406,7 +409,6 @@ private void computeSQLHeuristics(ExtraHeuristicsDto dto, List<AdditionalInfo> a
accessedTables.addAll(sqlExecutionsDto.deletedData);
accessedTables.addAll(sqlExecutionsDto.insertedData.keySet());
//accessedTables.addAll(executionDto.queriedData.keySet());
// accessedTables.addAll(sqlExecutionsDto.insertedData.keySet());
accessedTables.addAll(sqlExecutionsDto.updatedData.keySet());
}
}
Expand Down Expand Up @@ -495,13 +497,13 @@ public final void cleanAccessedTables(){
// clean accessed tables
Set<String> tableDataToInit = null;
if (!accessedTables.isEmpty()){
List<String> tablesToClean = new ArrayList<>();
getTableToClean(accessedTables, tablesToClean);
List<String> tablesToClean = getTablesToClean(accessedTables);
if (!tablesToClean.isEmpty()){
if (emDbClean.schemaNames != null && !emDbClean.schemaNames.isEmpty()){
emDbClean.schemaNames.forEach(sch-> DbCleaner.clearDatabase(getConnectionIfExist(), sch, null, tablesToClean, emDbClean.dbType));
}else
DbCleaner.clearDatabase(getConnectionIfExist(), null, null, tablesToClean, emDbClean.dbType);
emDbClean.schemaNames.forEach(sch-> DbCleaner.clearDatabase(getConnectionIfExist(), sch, null, tablesToClean, emDbClean.dbType, true));
} else {
DbCleaner.clearDatabase(getConnectionIfExist(), null, null, tablesToClean, emDbClean.dbType, true);
}
tableDataToInit = tablesToClean.stream().filter(a-> tableInitSqlMap.keySet().stream().anyMatch(t-> t.equalsIgnoreCase(a))).collect(Collectors.toSet());
}
}
Expand Down Expand Up @@ -582,7 +584,13 @@ public void addSuccessfulInitSqlInsertion(InsertionDto insertionDto){
successfulInitSqlInsertions.add(insertionDto);
}

private void getTableToClean(List<String> accessedTables, List<String> tablesToClean){
private List<String> getTablesToClean(List<String> accessedTables) {
List<String> tablesToClean = new ArrayList<>();
fillTablesToClean(accessedTables,tablesToClean);
return tablesToClean;
}

private void fillTablesToClean(List<String> accessedTables, List<String> tablesToClean){
for (String t: accessedTables){
if (!findInCollectionIgnoreCase(t, tablesToClean).isPresent()){
if (findInMapIgnoreCase(t, fkMap).isPresent()){
Expand All @@ -591,7 +599,7 @@ private void getTableToClean(List<String> accessedTables, List<String> tablesToC
findInCollectionIgnoreCase(t, e.getValue()).isPresent()
&& !findInCollectionIgnoreCase(e.getKey(), tablesToClean).isPresent()).map(Map.Entry::getKey).collect(Collectors.toList());
if (!fk.isEmpty())
getTableToClean(fk, tablesToClean);
fillTablesToClean(fk, tablesToClean);
}else {
SimpleLogger.uniqueWarn("Cannot find the table "+t+" in ["+String.join(",", fkMap.keySet())+"]");
}
Expand Down Expand Up @@ -644,12 +652,6 @@ private boolean registerInitSqlCommands(Connection connection, DbSpecification d
return false;
}

private void cleanDataInDbConnection(Connection connection, DbSpecification dbSpecification){
if (dbSpecification.schemaNames != null && !dbSpecification.schemaNames.isEmpty()){
dbSpecification.schemaNames.forEach(sch-> DbCleaner.clearDatabase(connection, sch, null, dbSpecification.dbType));
}else
DbCleaner.clearDatabase(connection, null, dbSpecification.dbType);
}

/**
* Extra information about the SQL Database Schema, if any is present.
Expand Down Expand Up @@ -679,10 +681,10 @@ public final DbInfoDto getSqlDatabaseSchema() {

if (fkMap.isEmpty()){
schemaDto.tables.forEach(t->{
fkMap.putIfAbsent(t.name, new ArrayList<>());
fkMap.putIfAbsent(t.id.name, new ArrayList<>());
if (t.foreignKeys!=null && !t.foreignKeys.isEmpty()){
t.foreignKeys.forEach(f->{
fkMap.get(t.name).add(f.targetTable.toUpperCase());
fkMap.get(t.id.name).add(f.targetTable.toUpperCase());
});
}
});
Expand Down Expand Up @@ -1454,7 +1456,10 @@ protected UnitsInfoDto getUnitsInfoDto(UnitsInfoRecorder recorder){
ec.digitsInteger = c.getDigitsInteger();
ec.enumValuesAsStrings = c.getEnumValuesAsStrings() == null ? null : new ArrayList<>(c.getEnumValuesAsStrings());
ExtraConstraintsDto jpa = new ExtraConstraintsDto();
jpa.tableName = c.getTableName();
jpa.tableId = new TableIdDto();
jpa.tableId.name = c.getTableName();
jpa.tableId.schema = null; //TODO
jpa.tableId.catalog = null; //TODO
jpa.columnName = c.getColumnName();
jpa.constraints = ec;
return jpa;
Expand Down Expand Up @@ -1521,7 +1526,7 @@ public void resetDatabase(List<String> tablesToClean) {

if(tablesToClean == null){
// all data will be reset
DbCleaner.clearDatabase(spec.connection, null, null, null, spec.dbType);
DbCleaner.clearDatabase(spec.connection, null, null, null, spec.dbType, true);
try {
reAddAllInitSql();
} catch (SQLException e) {
Expand All @@ -1532,10 +1537,12 @@ public void resetDatabase(List<String> tablesToClean) {

if (tablesToClean.isEmpty()) return;

if (spec.schemaNames == null || spec.schemaNames.isEmpty())
DbCleaner.clearDatabase(spec.connection, null, null, tablesToClean, spec.dbType);
else
spec.schemaNames.forEach(sp-> DbCleaner.clearDatabase(spec.connection, sp, null, tablesToClean, spec.dbType));
DbCleaner.clearTables(spec.connection, tablesToClean, spec.dbType);

// if (spec.schemaNames == null || spec.schemaNames.isEmpty())
// DbCleaner.clearDatabase(spec.connection, null, null, tablesToClean, spec.dbType);
// else
// spec.schemaNames.forEach(sp-> DbCleaner.clearDatabase(spec.connection, sp, null, tablesToClean, spec.dbType));

try {
handleInitSqlInDbClean(tablesToClean, spec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public SutInfoDto.OutputFormat getPreferredOutputFormat() {
@Override
public String startSut() {
running = true;
DbCleaner.clearDatabase(sqlConnection, null, DatabaseType.H2);
DbCleaner.clearDatabase_H2(sqlConnection, null, null);
return "foo";
}

Expand Down
Loading
Loading