From fb21cafcfb894710c9e4a28420bdfadd1b34835a Mon Sep 17 00:00:00 2001 From: Joel Bergstrand Date: Tue, 22 Oct 2024 11:20:00 +0200 Subject: [PATCH 1/2] [aWY2zoX5] Replaced testTerminatePeriodicQuery with testTerminateWithCommand --- .../test/java/apoc/periodic/PeriodicTest.java | 21 ++++++++++++------- .../java/apoc/periodic/PeriodicTestUtils.java | 5 ----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/core/src/test/java/apoc/periodic/PeriodicTest.java b/core/src/test/java/apoc/periodic/PeriodicTest.java index 546ec2738..79e41ad48 100644 --- a/core/src/test/java/apoc/periodic/PeriodicTest.java +++ b/core/src/test/java/apoc/periodic/PeriodicTest.java @@ -279,9 +279,11 @@ 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 @@ -350,15 +352,18 @@ private void assertError(Map 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 diff --git a/test-utils/src/main/java/apoc/periodic/PeriodicTestUtils.java b/test-utils/src/main/java/apoc/periodic/PeriodicTestUtils.java index 7988e21ca..7af765836 100644 --- a/test-utils/src/main/java/apoc/periodic/PeriodicTestUtils.java +++ b/test-utils/src/main/java/apoc/periodic/PeriodicTestUtils.java @@ -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); From c2b3cc8b5c3013492309690bd0ba2083cd1c1bdb Mon Sep 17 00:00:00 2001 From: Joel Bergstrand Date: Tue, 22 Oct 2024 11:27:32 +0200 Subject: [PATCH 2/2] [aWY2zoX5] Spotless --- core/src/test/java/apoc/periodic/PeriodicTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/test/java/apoc/periodic/PeriodicTest.java b/core/src/test/java/apoc/periodic/PeriodicTest.java index 79e41ad48..8b03421e2 100644 --- a/core/src/test/java/apoc/periodic/PeriodicTest.java +++ b/core/src/test/java/apoc/periodic/PeriodicTest.java @@ -282,8 +282,7 @@ public void testTerminateCommit() { 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)', {})", - "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