From 60d8813a5c78550bacc4fc30e0c211b15c6f8f25 Mon Sep 17 00:00:00 2001 From: Marcin Lewandowski Date: Wed, 11 Oct 2023 12:48:15 +0200 Subject: [PATCH 1/3] env test --- .../client/infrastructure/DisableOnPullRequestCondition.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/ravendb/client/infrastructure/DisableOnPullRequestCondition.java b/src/test/java/net/ravendb/client/infrastructure/DisableOnPullRequestCondition.java index dd274859..ce3a0fd8 100644 --- a/src/test/java/net/ravendb/client/infrastructure/DisableOnPullRequestCondition.java +++ b/src/test/java/net/ravendb/client/infrastructure/DisableOnPullRequestCondition.java @@ -7,7 +7,7 @@ public class DisableOnPullRequestCondition implements ExecutionCondition { - public static final String ENV_RAVEN_LICENSE = "RAVEN_LICENSE"; + public static final String ENV_RAVEN_LICENSE = "RAVEN_License"; @Override public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) { From a5ad532334342c8893de4454f5a4705c479df48b Mon Sep 17 00:00:00 2001 From: Marcin Lewandowski Date: Thu, 12 Oct 2023 10:02:25 +0200 Subject: [PATCH 2/3] fixed fastest node timer --- src/main/java/net/ravendb/client/http/NodeSelector.java | 2 +- src/main/java/net/ravendb/client/primitives/Timer.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/ravendb/client/http/NodeSelector.java b/src/main/java/net/ravendb/client/http/NodeSelector.java index 31160bed..310c1339 100644 --- a/src/main/java/net/ravendb/client/http/NodeSelector.java +++ b/src/main/java/net/ravendb/client/http/NodeSelector.java @@ -251,7 +251,7 @@ public void scheduleSpeedTest() { private void ensureFastestNodeTimerExists() { if (_updateFastestNodeTimer == null) { - _updateFastestNodeTimer = new Timer(this::switchToSpeedTestPhase, null, executorService); + _updateFastestNodeTimer = new Timer(this::switchToSpeedTestPhase, null, null, executorService); } } diff --git a/src/main/java/net/ravendb/client/primitives/Timer.java b/src/main/java/net/ravendb/client/primitives/Timer.java index 3e86eed7..f8a0e80a 100644 --- a/src/main/java/net/ravendb/client/primitives/Timer.java +++ b/src/main/java/net/ravendb/client/primitives/Timer.java @@ -20,7 +20,9 @@ public Timer(Runnable action, Duration dueTime, Duration period, ExecutorService this.executorService = executorService; this.action = action; this.period = period; - schedule(dueTime); + if (dueTime != null) { + schedule(dueTime); + } } public void change(Duration dueTime) { From a282db6232749d4f21aa9c65063be1ee5145d388 Mon Sep 17 00:00:00 2001 From: Marcin Lewandowski Date: Thu, 12 Oct 2023 10:21:57 +0200 Subject: [PATCH 3/3] better WaitForIndexing impl --- .../java/net/ravendb/client/ClusterTestBase.java | 2 +- .../java/net/ravendb/client/IndexesTestBase.java | 2 +- .../operations/indexes/IndexOperationsTest.java | 2 +- .../net/ravendb/client/driver/RavenTestDriver.java | 14 +++++++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/test/java/net/ravendb/client/ClusterTestBase.java b/src/test/java/net/ravendb/client/ClusterTestBase.java index dd9c71d8..7581ab27 100644 --- a/src/test/java/net/ravendb/client/ClusterTestBase.java +++ b/src/test/java/net/ravendb/client/ClusterTestBase.java @@ -325,7 +325,7 @@ public static void waitForIndexingInTheCluster(IDocumentStore store, String dbNa new GetDatabaseRecordOperation(ObjectUtils.firstNonNull(dbName, store.getDatabase()))); for (String nodeTag : record.getTopology().getAllNodes()) { - waitForIndexing(store, dbName, timeout, nodeTag); + waitForIndexing(store, dbName, timeout, false, nodeTag); } } diff --git a/src/test/java/net/ravendb/client/IndexesTestBase.java b/src/test/java/net/ravendb/client/IndexesTestBase.java index f19b1b76..a4d5b93a 100644 --- a/src/test/java/net/ravendb/client/IndexesTestBase.java +++ b/src/test/java/net/ravendb/client/IndexesTestBase.java @@ -26,7 +26,7 @@ public void waitForIndexing(IDocumentStore store, String database, Duration time } public void waitForIndexing(IDocumentStore store, String database, Duration timeout, String nodeTag) { - RemoteTestBase.waitForIndexing(store, database, timeout, nodeTag); + RemoteTestBase.waitForIndexing(store, database, timeout, false, nodeTag); } public IndexErrors[] waitForIndexingErrors(IDocumentStore store, Duration timeout, String... indexNames) throws InterruptedException { diff --git a/src/test/java/net/ravendb/client/documents/operations/indexes/IndexOperationsTest.java b/src/test/java/net/ravendb/client/documents/operations/indexes/IndexOperationsTest.java index ff22c429..c32e6d9d 100644 --- a/src/test/java/net/ravendb/client/documents/operations/indexes/IndexOperationsTest.java +++ b/src/test/java/net/ravendb/client/documents/operations/indexes/IndexOperationsTest.java @@ -229,7 +229,7 @@ public void canListErrors() throws Exception { session.saveChanges(); } - waitForIndexing(store, store.getDatabase()); + waitForIndexing(store, store.getDatabase(), null, true, null); waitForValue(() -> store.maintenance().send(new GetIndexErrorsOperation())[0].getErrors().length, 1); waitForValue(() -> store.maintenance().send(new GetIndexErrorsOperation(new String[] { indexDef.getName() }))[0].getErrors().length, 1); diff --git a/src/test/java/net/ravendb/client/driver/RavenTestDriver.java b/src/test/java/net/ravendb/client/driver/RavenTestDriver.java index c28753e2..ac6ff910 100644 --- a/src/test/java/net/ravendb/client/driver/RavenTestDriver.java +++ b/src/test/java/net/ravendb/client/driver/RavenTestDriver.java @@ -188,10 +188,10 @@ public static void waitForIndexing(IDocumentStore store, String database) { } public static void waitForIndexing(IDocumentStore store, String database, Duration timeout) { - waitForIndexing(store, database, timeout, null); + waitForIndexing(store, database, timeout, false, null); } - public static void waitForIndexing(IDocumentStore store, String database, Duration timeout, String nodeTag) { + public static void waitForIndexing(IDocumentStore store, String database, Duration timeout, boolean allowErrors, String nodeTag) { MaintenanceOperationExecutor admin = store.maintenance().forDatabase(database); if (timeout == null) { @@ -212,7 +212,11 @@ public static void waitForIndexing(IDocumentStore store, String database, Durati return; } - if (Arrays.stream(databaseStatistics.getIndexes()).anyMatch(x -> IndexState.ERROR.equals(x.getState()))) { + long erroredIndexesCount = Arrays.stream(databaseStatistics.getIndexes()).filter(x -> IndexState.ERROR.equals(x.getState())).count(); + if (allowErrors) { + // wait for all indexes to become non stale + } else if (erroredIndexesCount > 0) { + // have at least some errors break; } @@ -223,6 +227,10 @@ public static void waitForIndexing(IDocumentStore store, String database, Durati } } + if (allowErrors) { + return; + } + IndexErrors[] errors = admin.send(new GetIndexErrorsOperation()); String allIndexErrorsText = "";