Skip to content

Commit 4ec6322

Browse files
committed
created new use cae with big table
1 parent 38be518 commit 4ec6322

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

src/main/java/com/geckotechnology/mySqlDataCompare/MySQLTableDataComparer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void compareTable(Table table) throws Exception {
7676
slaveResultSet.close();
7777
slaveStatement.close();
7878
masterResultSet.close();
79-
masterStatement.close();
79+
masterStatement.close();
8080
}
8181

8282
private void processOneRow(Table table, String pkColumnsTuple, boolean isSourceMaster,

src/test/java/com/geckotechnology/mySqlDataCompare/AppTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void testCompareSchemaAndData() throws Exception
8484
assertEquals(schemaDifferences.size(), 27);
8585

8686
ArrayList<Table> tablesReadyToBeDataAnalyzed = mySQLSchemaComparer.getMasterTablesReadyToBeDataAnalyzed();
87-
assertEquals(tablesReadyToBeDataAnalyzed.size(), 4);
87+
assertEquals(tablesReadyToBeDataAnalyzed.size(), 5);
8888
MySQLTableDataComparer tableDataComparer = new MySQLTableDataComparer(masterSchemaReader, slaveSchemaReader);
8989
for(Table table:tablesReadyToBeDataAnalyzed)
9090
tableDataComparer.compareTable(table);
@@ -100,8 +100,12 @@ public void testCompareSchemaAndData() throws Exception
100100
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "tab3", DifferenceType.DATA_ROW_MISSING_IN_SLAVE_TABLE, "(uid,sometext2)=(4,d2)")) >= 0);
101101
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "tab3", DifferenceType.DATA_ROW_EXCESS_IN_SLAVE_TABLE, "(uid,sometext2)=(4,d3)")) >= 0);
102102
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "tab3", DifferenceType.DATA_ROW_EXCESS_IN_SLAVE_TABLE, "(uid,sometext2)=(6,e2)")) >= 0);
103-
assertEquals(dataDifferences.size(), 11);
104-
assertEquals(tableDataComparer.getMasterTotalRetrievedRows(), 19);
105-
assertEquals(tableDataComparer.getSlaveTotalRetrievedRows(), 20);
103+
104+
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "bigtable", DifferenceType.DATA_ROW_EXCESS_IN_SLAVE_TABLE, "(uid)=(300000000)")) >= 0);
105+
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "bigtable", DifferenceType.DATA_ROW_DIFFERENT_MD5, "(uid)=(500000000)")) >= 0);
106+
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "bigtable", DifferenceType.DATA_ROW_MISSING_IN_SLAVE_TABLE, "(uid)=(700000000)")) >= 0);
107+
assertEquals(dataDifferences.size(), 14);
108+
assertTrue(tableDataComparer.getMasterTotalRetrievedRows() > 100000);
109+
assertTrue(tableDataComparer.getSlaveTotalRetrievedRows() > 100000);
106110
}
107111
}

src/test/resources/test_schemas.sql

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,47 @@ insert into schema_a.tab5 (uid,sometext1,sometext2) values (2, 'b1', 'b2');
262262
insert into schema_b.tab5 (uid,sometext1,sometext2) values (2, 'b1', 'b2');
263263
insert into schema_b.tab5 (uid,sometext1,sometext2) values (1, 'a1', 'a2');
264264

265+
#######
266+
# Big Table with 128 rows
267+
268+
create table schema_A.bigtable(
269+
uid INT,
270+
rndint INT,
271+
PRIMARY KEY ( uid )
272+
);
273+
274+
INSERT INTO schema_A.bigtable ( uid, rndint ) VALUES ( 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823));
275+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
276+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
277+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
278+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
279+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
280+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
281+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
282+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
283+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
284+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
285+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
286+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
287+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
288+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
289+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
290+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
291+
INSERT IGNORE INTO schema_A.bigtable ( uid, rndint ) select 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823) from schema_A.bigtable;
292+
293+
create table schema_B.bigtable(
294+
uid INT,
295+
rndint INT,
296+
PRIMARY KEY ( uid )
297+
);
298+
299+
INSERT IGNORE INTO schema_B.bigtable ( uid, rndint ) select uid, rndint from schema_A.bigtable;
300+
301+
INSERT INTO schema_A.bigtable ( uid, rndint ) VALUES ( 500000000, 1234);
302+
INSERT INTO schema_B.bigtable ( uid, rndint ) VALUES ( 500000000, 4567);
303+
INSERT INTO schema_A.bigtable ( uid, rndint ) VALUES ( 700000000, 1234);
304+
INSERT INTO schema_B.bigtable ( uid, rndint ) VALUES ( 300000000, 4567);
305+
265306
#######
266307
# View to make sure it has no impact
267308

0 commit comments

Comments
 (0)