Skip to content

Commit ca99b25

Browse files
committed
more test case for DATA_TOO_MANY_UNMATCHED_ROWS
1 parent 8a38cb7 commit ca99b25

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

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

Lines changed: 4 additions & 3 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(), 5);
87+
assertEquals(tablesReadyToBeDataAnalyzed.size(), 6);
8888
MySQLTableDataComparer tableDataComparer = new MySQLTableDataComparer(masterSchemaReader, slaveSchemaReader);
8989
for(Table table:tablesReadyToBeDataAnalyzed)
9090
tableDataComparer.compareTable(table);
@@ -100,11 +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-
104103
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "bigtable", DifferenceType.DATA_ROW_EXCESS_IN_SLAVE_TABLE, "(uid)=(300000001)")) >= 0);
105104
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "bigtable", DifferenceType.DATA_ROW_DIFFERENT_MD5, "(uid)=(500000001)")) >= 0);
106105
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "bigtable", DifferenceType.DATA_ROW_MISSING_IN_SLAVE_TABLE, "(uid)=(700000001)")) >= 0);
107-
assertEquals(dataDifferences.size(), 14);
106+
assertTrue(dataDifferences.indexOf(new SchemaDifference(Criticality.ERROR, "bigdiff", DifferenceType.DATA_TOO_MANY_UNMATCHED_ROWS, "max rows:100")) >= 0);
107+
108+
assertEquals(dataDifferences.size(), 15);
108109
assertTrue(tableDataComparer.getMasterTotalRetrievedRows() > 900000);
109110
assertTrue(tableDataComparer.getSlaveTotalRetrievedRows() > 900000);
110111
}

src/test/resources/test_schemas.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,28 @@ INSERT INTO schema_B.bigtable ( uid, rndint ) VALUES ( 500000001, 4567);
294294
INSERT INTO schema_A.bigtable ( uid, rndint ) VALUES ( 700000001, 1234);
295295
INSERT INTO schema_B.bigtable ( uid, rndint ) VALUES ( 300000001, 4567);
296296

297+
#######
298+
# Big diff Table with 1,000 rows
299+
300+
create table schema_A.bigdiff(
301+
uid INT,
302+
rndint INT,
303+
PRIMARY KEY ( uid )
304+
);
305+
306+
INSERT IGNORE INTO schema_A.bigdiff ( uid, rndint )
307+
SELECT 2 * round(rand() * 1073741823), 2 * round(rand() * 1073741823)
308+
FROM
309+
(select 0 as i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) as t1,
310+
(select 0 as i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) as t2,
311+
(select 0 as i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) as t3;
312+
313+
create table schema_B.bigdiff(
314+
uid INT,
315+
rndint INT,
316+
PRIMARY KEY ( uid )
317+
);
318+
297319
#######
298320
# View to make sure it has no impact
299321

0 commit comments

Comments
 (0)