Skip to content

Commit

Permalink
Added missing testconsistency test case
Browse files Browse the repository at this point in the history
  • Loading branch information
suarezgpablo committed Dec 16, 2024
1 parent 997ea12 commit 220b5fd
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ public void testCustomV7SplitTable() throws IOException {
projectionAfterEvo.put("table1copied2", "SELECT DISTINCT author.id AS idauthor FROM author INNER JOIN authorbook ON author.id = authorbook.idauthor INNER JOIN book ON book.id = authorbook.idbook ORDER BY author.id DESC;");
testConsistency(name.getMethodName(), projectionAfterEvo, "custom", projectionBeforeEvo);
}
@Test
public void testCustomV8JoinColumn() throws IOException {
Map<String, String> projectionAfterEvo = new HashMap<String, String>();
Map<String, String> projectionBeforeEvo = new HashMap<String, String>();
projectionBeforeEvo.put("table1", "SELECT author.id AS idauthor, book.id AS idbook, book.title as title, book.subtitle AS subtitle FROM author INNER JOIN authorbook ON author.id = authorbook.idauthor INNER JOIN book ON book.id = authorbook.idbook;");
projectionAfterEvo.put("table1", "SELECT author.id AS idauthor, book.id AS idbook, CONCAT(book.title, book.subtitle) AS completetitle, book.subtitle AS subtitle, book.title as title FROM author INNER JOIN authorbook ON author.id = authorbook.idauthor INNER JOIN book ON book.id = authorbook.idbook ORDER BY author.id DESC, book.id DESC;");
testConsistency(name.getMethodName(), projectionAfterEvo, "custom", projectionBeforeEvo);
}
@Test
public void testCustomV9RemovePK() throws IOException {
Map<String, String> projectionAfterEvo = new HashMap<String, String>();
Map<String, String> projectionBeforeEvo = new HashMap<String, String>();
projectionBeforeEvo.put("table1beforechange", "SELECT author.id AS idauthor, book.id AS idbook, book.title as title FROM author INNER JOIN authorbook ON author.id = authorbook.idauthor INNER JOIN book ON book.id = authorbook.idbook;");
projectionAfterEvo.put("table1", "SELECT author.id AS idauthor, book.id AS idbook FROM author INNER JOIN authorbook ON author.id = authorbook.idauthor INNER JOIN book ON book.id = authorbook.idbook ORDER BY author.id DESC, book.id DESC;");
testConsistency(name.getMethodName(), projectionAfterEvo, "custom", projectionBeforeEvo);
}

@Test
public void testMindsV10NewTableMigrationFromOneTable() throws IOException {
Map<String, String> projectionAfterEvo = new HashMap<String, String>();
Expand Down Expand Up @@ -154,6 +171,15 @@ public void testWireV2NewTableMigrationFromOneTable() throws IOException {
testConsistency(name.getMethodName(), projectionAfterEvo, "wire", projectionBeforeEvo);
}
@Test
public void testWireV8NewTableMigrationFromPreviousVersion() throws IOException {
Map<String, String> projectionAfterEvo = new HashMap<String, String>();
Map<String, String> projectionBeforeEvo = new HashMap<String, String>();
projectionBeforeEvo.put("scim_user", "SELECT scim.id AS id FROM scim;");
projectionAfterEvo.put("scim_user", "SELECT scim.id AS id FROM scim ORDER BY scim.id DESC;");
projectionAfterEvo.put("scim_user_times", "SELECT scim.id AS id FROM scim ORDER BY scim.id DESC;");
testConsistency(name.getMethodName(), projectionAfterEvo, "wire", projectionBeforeEvo);
}
@Test
public void testWireV91NewTableMigrationFromOneTable() throws IOException {
Map<String, String> projectionAfterEvo = new HashMap<String, String>();
Map<String, String> projectionBeforeEvo = new HashMap<String, String>();
Expand Down Expand Up @@ -220,6 +246,7 @@ private void testConsistency (String testName, Map<String, String> tableQueryCom
* Sets up the Cassandra by populating it with all the data required from the SQL database using the queries specified in tableProjection
*/
private void setUpCassandraDatabase(String testName, String keyspace, Map<String, String> tableProjection) {
resetDatabaseCassandraUnitTesting (testName);
OracleCsv oc = new OracleCsv();
Map<String, List<String>> tableColumnsMap = oc.namesTablesColumnsKeyspace(testName, connection, tableProjection); //Map of the names of tables and its columns
Map <String, PreparedStatement> preparedStatementsTable = new HashMap <>();
Expand All @@ -232,6 +259,19 @@ private void setUpCassandraDatabase(String testName, String keyspace, Map<String
}
migrateSqlToCassandra (preparedStatementsTable, keyspace, tableProjection); //Migrates data from the SQL database to each Cassandra table
}
/**
* Empties the database of data
*/
private void resetDatabaseCassandraUnitTesting(String keyspace) {
String cql = "SELECT table_name FROM system_schema.tables WHERE keyspace_name = '"+keyspace+"';";
com.datastax.oss.driver.api.core.cql.ResultSet results = connection.executeStatement(cql);
for (com.datastax.oss.driver.api.core.cql.Row row : results) {
String nameTable = row.getString(0);
String delete = "";
delete = "TRUNCATE \""+keyspace+"\"."+nameTable+";";
connection.executeStatement(delete);
}
}

/**
* Builds a PreparedStatement to insert data to all columns of a Cassandra table
Expand Down
6 changes: 3 additions & 3 deletions modevo-script/dat/bmk/testMindsV3SplitColumn-script.cql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FOR $1,$2 = SELECT parent_guid, id FROM comments WHERE parent_guid>'f' ALLOW FILTERING
FOR $3,$4 = SELECT parent_guid, id FROM comments WHERE parent_guid>'p' ALLOW FILTERING
FOR $5,$6 = SELECT parent_guid, id FROM comments WHERE parent_guid<'p' ALLOW FILTERING
FOR $1,$2 = SELECT parent_guid, id FROM comments WHERE parent_guid<'F' ALLOW FILTERING
FOR $3,$4 = SELECT parent_guid, id FROM comments WHERE parent_guid<'P' ALLOW FILTERING
FOR $5,$6 = SELECT parent_guid, id FROM comments WHERE parent_guid>'P' ALLOW FILTERING
INSERT INTO comments(parent_guid_c1, id) VALUES ($1, $2);
INSERT INTO comments(parent_guid_c2, id) VALUES ($3, $4);
INSERT INTO comments(parent_guid_c3, id) VALUES ($5, $6);
12 changes: 6 additions & 6 deletions modevo-transform/dat/inp/testMindsV3SplitColumn-schemaChange.xmi
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
<CriteriaSplit
xmi:id="cs1"
column="c1"
value="f"
operator="g"/>
value="F"
operator="l"/>
<CriteriaSplit
xmi:id="cs2"
column="c2"
value="p"
operator="g"/>
value="P"
operator="l"/>
<CriteriaSplit
xmi:id="cs3"
column="c3"
value="p"
operator="l"/>
value="P"
operator="g"/>
</xmi:XMI>
Loading

0 comments on commit 220b5fd

Please sign in to comment.