Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aWY2zoX5] Replaced testTerminatePeriodicQuery with testTerminateWithCommand #672

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading