From 8dc2a9188ee5b5a4a4702ca6cf709e20a9139356 Mon Sep 17 00:00:00 2001 From: JoelBergstrand Date: Thu, 24 Oct 2024 09:23:38 +0200 Subject: [PATCH] [aWY2zoX5] Replaced testTerminatePeriodicQuery with testTerminateWithCommand (#672) --- .../test/java/apoc/periodic/PeriodicTest.java | 20 +++++++++++-------- .../java/apoc/periodic/PeriodicTestUtils.java | 5 ----- 2 files changed, 12 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..8b03421e2 100644 --- a/core/src/test/java/apoc/periodic/PeriodicTest.java +++ b/core/src/test/java/apoc/periodic/PeriodicTest.java @@ -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 @@ -350,15 +351,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);