Skip to content

Commit

Permalink
[aWY2zoX5] Replaced testTerminatePeriodicQuery with testTerminateWith…
Browse files Browse the repository at this point in the history
…Command (#672)
  • Loading branch information
JoelBergstrand authored Oct 24, 2024
1 parent 4234bb2 commit 8dc2a91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
20 changes: 12 additions & 8 deletions core/src/test/java/apoc/periodic/PeriodicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,10 @@ public void testSlottedRuntime() {

@Test
public void testTerminateCommit() {
PeriodicTestUtils.testTerminatePeriodicQuery(
PeriodicTestUtils.testTerminateWithCommand(
db,
"CALL apoc.periodic.commit('UNWIND range(0,1000) as id WITH id CREATE (n:Foo {id: id}) WITH n limit 1000 RETURN COUNT(n)', {})");
"CALL apoc.periodic.commit('UNWIND range(0,1000) as id WITH id CREATE (n:Foo {id: id}) WITH n limit 1000 RETURN COUNT(n)', {})",
"UNWIND range(0,1000) as id WITH id CREATE (n:Foo {id: id}) WITH n limit 1000 RETURN COUNT(n)");
}

@Test
Expand Down Expand Up @@ -350,15 +351,18 @@ private void assertError(Map<String, Long> errors, String expectedPattern, Long

@Test
public void testTerminateIterate() {
PeriodicTestUtils.testTerminatePeriodicQuery(
PeriodicTestUtils.testTerminateWithCommand(
db,
"CALL apoc.periodic.iterate('UNWIND range(0,1000) as id RETURN id', 'WITH $id as id CREATE (:Foo {id: $id})', {batchSize:1,parallel:true})");
PeriodicTestUtils.testTerminatePeriodicQuery(
"CALL apoc.periodic.iterate('UNWIND range(0,1000) as id RETURN id', 'WITH $id as id CREATE (:Foo {id: $id})', {batchSize:1,parallel:true})",
"UNWIND range(0,1000) as id RETURN id");
PeriodicTestUtils.testTerminateWithCommand(
db,
"CALL apoc.periodic.iterate('UNWIND range(0,1000) as id RETURN id', 'WITH $id as id CREATE (:Foo {id: $id})', {batchSize:10,iterateList:true})");
PeriodicTestUtils.testTerminatePeriodicQuery(
"CALL apoc.periodic.iterate('UNWIND range(0,1000) as id RETURN id', 'WITH $id as id CREATE (:Foo {id: $id})', {batchSize:10,iterateList:true})",
"UNWIND range(0,1000) as id RETURN id");
PeriodicTestUtils.testTerminateWithCommand(
db,
"CALL apoc.periodic.iterate('UNWIND range(0,1000) as id RETURN id', 'WITH $id as id CREATE (:Foo {id: $id})', {batchSize:10,iterateList:false})");
"CALL apoc.periodic.iterate('UNWIND range(0,1000) as id RETURN id', 'WITH $id as id CREATE (:Foo {id: $id})', {batchSize:10,iterateList:false})",
"UNWIND range(0,1000) as id RETURN id");
}

@Test
Expand Down
5 changes: 0 additions & 5 deletions test-utils/src/main/java/apoc/periodic/PeriodicTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ public static boolean terminateQuery(String pattern, GraphDatabaseAPI db) {
return numberOfKilledTransactions > 0;
}

public static void testTerminatePeriodicQuery(DbmsRule db, String periodicQuery) {
killPeriodicQueryAsync(db);
checkPeriodicTerminated(db, periodicQuery);
}

public static void testTerminateWithCommand(DbmsRule db, String periodicQuery, String iterateQuery) {
long timeBefore = System.currentTimeMillis();
TransactionTestUtil.terminateTransactionAsync(db, 10L, iterateQuery);
Expand Down

0 comments on commit 8dc2a91

Please sign in to comment.