Skip to content

Commit 5613bf4

Browse files
mattyb149MikeThomsen
authored andcommitted
NIFI-5202: Fixed timing issue in TestListDatabaseTables
This closes #2709 Signed-off-by: Mike Thomsen <mikerthomsen@gmail.com>
1 parent 807e1e5 commit 5613bf4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard

nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListDatabaseTables.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public void testListTablesMultipleRefresh() throws Exception {
206206
runner.setProperty(ListDatabaseTables.INCLUDE_COUNT, "true");
207207
runner.setProperty(ListDatabaseTables.REFRESH_INTERVAL, "200 millis");
208208
runner.run();
209+
long startTimer = System.currentTimeMillis();
209210
runner.assertTransferCount(ListDatabaseTables.REL_SUCCESS, 1);
210211
List<MockFlowFile> results = runner.getFlowFilesForRelationship(ListDatabaseTables.REL_SUCCESS);
211212
assertEquals("2", results.get(0).getAttribute(ListDatabaseTables.DB_TABLE_COUNT));
@@ -215,9 +216,11 @@ public void testListTablesMultipleRefresh() throws Exception {
215216
stmt.execute("create table TEST_TABLE2 (id integer not null, val1 integer, val2 integer, constraint my_pk2 primary key (id))");
216217
stmt.close();
217218
runner.run();
218-
runner.assertTransferCount(ListDatabaseTables.REL_SUCCESS, 1);
219+
long endTimer = System.currentTimeMillis();
220+
// Expect 1 or 2 tables (whether execution has taken longer than the refresh time)
221+
runner.assertTransferCount(ListDatabaseTables.REL_SUCCESS, (endTimer - startTimer > 200) ? 2 : 1);
219222
results = runner.getFlowFilesForRelationship(ListDatabaseTables.REL_SUCCESS);
220-
assertEquals("0", results.get(0).getAttribute(ListDatabaseTables.DB_TABLE_COUNT));
223+
assertEquals((endTimer - startTimer > 200) ? "2": "0", results.get(0).getAttribute(ListDatabaseTables.DB_TABLE_COUNT));
221224
runner.clearTransferState();
222225

223226
// Now wait longer than the refresh interval and assert the refresh has happened (i.e. the two tables are re-listed)

0 commit comments

Comments
 (0)