You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by tk...@apache.org on 2023/03/23 15:20:37 UTC
[ignite-3] branch main updated: IGNITE-19110 Cleanup CompletableFutureMatcher (#1835)
This is an automated email from the ASF dual-hosted git repository.
tkalkirill pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new afec53604a IGNITE-19110 Cleanup CompletableFutureMatcher (#1835)
afec53604a is described below
commit afec53604afe19ce530fce2443d1f77a9c727870
Author: Alexander Polovtcev <al...@gmail.com>
AuthorDate: Thu Mar 23 17:20:31 2023 +0200
IGNITE-19110 Cleanup CompletableFutureMatcher (#1835)
---
.../causality/CompletableVersionedValueTest.java | 4 +-
.../CompletableFutureExceptionMatcher.java | 47 ++++++++--
.../matchers/CompletableFutureMatcher.java | 100 +--------------------
.../impl/ItMetaStorageManagerImplTest.java | 7 +-
.../metastorage/impl/ItMetaStorageServiceTest.java | 8 +-
.../metastorage/impl/CursorPublisherTest.java | 8 +-
.../DelegatingAuthenticationProviderTest.java | 6 +-
.../storage/ItRebalanceDistributedTest.java | 4 +-
.../org/apache/ignite/internal/ssl/ItSslTest.java | 2 +-
.../storage/util/MvPartitionStoragesTest.java | 38 ++++----
.../storage/util/ReentrantLockByRowIdTest.java | 2 +-
.../storage/AbstractMvTableStorageTest.java | 8 +-
.../internal/table/distributed/gc/MvGcTest.java | 10 +--
.../incoming/IncomingSnapshotCopierTest.java | 4 +-
.../replication/PartitionReplicaListenerTest.java | 4 +-
.../internal/tx/NoWaitDeadlockPreventionTest.java | 10 +--
.../internal/tx/TimeoutDeadlockPreventionTest.java | 14 +--
17 files changed, 107 insertions(+), 169 deletions(-)
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/causality/CompletableVersionedValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/causality/CompletableVersionedValueTest.java
index 7e7521eb47..26483afcb3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/causality/CompletableVersionedValueTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/causality/CompletableVersionedValueTest.java
@@ -18,8 +18,8 @@
package org.apache.ignite.internal.causality;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.runRace;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrow;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -113,7 +113,7 @@ public class CompletableVersionedValueTest {
assertThrows(Exception.class, fut::get);
- assertThat(intVersionedValue.get(token), willFailFast(TEST_EXCEPTION.getClass()));
+ assertThat(intVersionedValue.get(token), willThrow(TEST_EXCEPTION.getClass()));
});
}
diff --git a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/matchers/CompletableFutureExceptionMatcher.java b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/matchers/CompletableFutureExceptionMatcher.java
index 7fdf4617d4..931eb9c1ea 100644
--- a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/matchers/CompletableFutureExceptionMatcher.java
+++ b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/matchers/CompletableFutureExceptionMatcher.java
@@ -25,6 +25,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
@@ -67,8 +68,8 @@ public class CompletableFutureExceptionMatcher extends TypeSafeMatcher<Completab
item.get(timeout, timeUnit);
return false;
- } catch (Exception e) {
- Throwable unwrapped = unwrapException(e);
+ } catch (Throwable e) {
+ Throwable unwrapped = unwrapThrowable(e);
return inspectCause ? matchesWithCause(unwrapped) : matcher.matches(unwrapped);
}
@@ -85,7 +86,7 @@ public class CompletableFutureExceptionMatcher extends TypeSafeMatcher<Completab
try {
item.join();
} catch (Exception e) {
- mismatchDescription.appendText("was completed exceptionally with ").appendValue(unwrapException(e));
+ mismatchDescription.appendText("was completed exceptionally with ").appendValue(unwrapThrowable(e));
}
} else if (item.isDone()) {
mismatchDescription.appendText("was completed successfully");
@@ -94,12 +95,12 @@ public class CompletableFutureExceptionMatcher extends TypeSafeMatcher<Completab
}
}
- private static Throwable unwrapException(Exception e) {
- if (e instanceof ExecutionException || e instanceof CompletionException) {
- return e.getCause();
- } else {
- return e;
+ private static Throwable unwrapThrowable(Throwable e) {
+ while (e instanceof ExecutionException || e instanceof CompletionException) {
+ e = e.getCause();
}
+
+ return e;
}
private boolean matchesWithCause(Throwable e) {
@@ -144,10 +145,40 @@ public class CompletableFutureExceptionMatcher extends TypeSafeMatcher<Completab
return willThrow(is(instanceOf(cls)), timeout, timeUnit);
}
+ /**
+ * Creates a matcher that matches a future that completes exceptionally and decently fast.
+ *
+ * @param cls The class of cause throwable.
+ * @return matcher.
+ */
+ public static CompletableFutureExceptionMatcher willThrowFast(Class<? extends Exception> cls) {
+ return willThrow(cls, 1, TimeUnit.SECONDS);
+ }
+
/**
* Creates a matcher that matches a future that completes with an exception that has a given {@code cause} in the exception stacktrace.
*/
public static CompletableFutureExceptionMatcher willThrowWithCauseOrSuppressed(Class<? extends Exception> cause) {
return new CompletableFutureExceptionMatcher(is(instanceOf(cause)), true, TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
+
+ /**
+ * Creates a matcher that matches a future that never completes within a predefined time period.
+ *
+ * @return matcher.
+ */
+ public static CompletableFutureExceptionMatcher willTimeoutFast() {
+ return willTimeoutIn(250, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * Creates a matcher that matches a future that never completes within the given time period.
+ *
+ * @param time Timeout.
+ * @param timeUnit Time unit for timeout.
+ * @return matcher.
+ */
+ public static CompletableFutureExceptionMatcher willTimeoutIn(int time, TimeUnit timeUnit) {
+ return willThrow(TimeoutException.class, time, timeUnit);
+ }
}
diff --git a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/matchers/CompletableFutureMatcher.java b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/matchers/CompletableFutureMatcher.java
index 3c9333e18c..3022bcd640 100644
--- a/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/matchers/CompletableFutureMatcher.java
+++ b/modules/core/src/testFixtures/java/org/apache/ignite/internal/testframework/matchers/CompletableFutureMatcher.java
@@ -17,11 +17,8 @@
package org.apache.ignite.internal.testframework.matchers;
-import static org.apache.ignite.internal.testframework.IgniteTestUtils.hasCause;
import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.equalTo;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
@@ -31,7 +28,6 @@ import java.util.concurrent.TimeoutException;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
-import org.jetbrains.annotations.Nullable;
/**
* {@link Matcher} that awaits for the given future to complete and then forwards the result to the nested {@code matcher}.
@@ -49,19 +45,13 @@ public class CompletableFutureMatcher<T> extends TypeSafeMatcher<CompletableFutu
/** Time unit for timeout. */
private final TimeUnit timeoutTimeUnit;
- /**
- * Class of throwable that should be the cause of fail if the future should fail. If {@code null}, the future should be completed
- * successfully.
- */
- private final Class<? extends Throwable> causeOfFail;
-
/**
* Constructor.
*
* @param matcher Matcher to forward the result of the completable future.
*/
private CompletableFutureMatcher(Matcher<T> matcher) {
- this(matcher, DEFAULT_TIMEOUT_SECONDS, TimeUnit.SECONDS, null);
+ this(matcher, DEFAULT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
/**
@@ -70,19 +60,11 @@ public class CompletableFutureMatcher<T> extends TypeSafeMatcher<CompletableFutu
* @param matcher Matcher to forward the result of the completable future.
* @param timeout Timeout.
* @param timeoutTimeUnit {@link TimeUnit} for timeout.
- * @param causeOfFail If {@code null}, the future should be completed successfully, otherwise it specifies the class of cause
- * throwable.
*/
- private CompletableFutureMatcher(
- Matcher<T> matcher,
- int timeout,
- TimeUnit timeoutTimeUnit,
- @Nullable Class<? extends Throwable> causeOfFail
- ) {
+ private CompletableFutureMatcher(Matcher<T> matcher, int timeout, TimeUnit timeoutTimeUnit) {
this.matcher = matcher;
this.timeout = timeout;
this.timeoutTimeUnit = timeoutTimeUnit;
- this.causeOfFail = causeOfFail;
}
/** {@inheritDoc} */
@@ -91,19 +73,9 @@ public class CompletableFutureMatcher<T> extends TypeSafeMatcher<CompletableFutu
try {
T res = item.get(timeout, timeoutTimeUnit);
- if (causeOfFail != null) {
- fail("The future was supposed to fail, but it completed successfully.");
- }
-
return matcher.matches(res);
} catch (InterruptedException | ExecutionException | TimeoutException | CancellationException e) {
- if (causeOfFail != null) {
- assertTrue(hasCause(e, causeOfFail, null));
-
- return true;
- } else {
- throw new AssertionError(e);
- }
+ throw new AssertionError(e);
}
}
@@ -147,71 +119,7 @@ public class CompletableFutureMatcher<T> extends TypeSafeMatcher<CompletableFutu
* @return matcher.
*/
public static CompletableFutureMatcher<Object> willSucceedIn(int time, TimeUnit timeUnit) {
- return new CompletableFutureMatcher<>(anything(), time, timeUnit, null);
- }
-
- /**
- * Creates a matcher that matches a future that completes exceptionally and decently fast.
- *
- * @param cause The class of cause throwable.
- * @return matcher.
- */
- public static CompletableFutureMatcher<Object> willFailFast(Class<? extends Throwable> cause) {
- return willFailIn(1, TimeUnit.SECONDS, cause);
- }
-
- /**
- * Creates a matcher that matches a future that completes exceptionally within the given timeout.
- *
- * @param time Timeout.
- * @param timeUnit Time unit for timeout.
- * @param cause The class of cause throwable.
- * @return matcher.
- */
- public static CompletableFutureMatcher<Object> willFailIn(int time, TimeUnit timeUnit, Class<? extends Throwable> cause) {
- assert cause != null;
-
- return new CompletableFutureMatcher<>(anything(), time, timeUnit, cause);
- }
-
- /**
- * Creates a matcher that matches a future that <strong>not</strong> completes decently fast.
- *
- * @return matcher.
- */
- public static CompletableFutureMatcher<Object> willTimeoutFast() {
- return willTimeoutIn(250, TimeUnit.MILLISECONDS);
- }
-
- /**
- * Creates a matcher that matches a future that <strong>not</strong> completes within the given timeout.
- *
- * @param time Timeout.
- * @param timeUnit Time unit for timeout.
- * @return matcher.
- */
- public static CompletableFutureMatcher<Object> willTimeoutIn(int time, TimeUnit timeUnit) {
- return new CompletableFutureMatcher<>(anything(), time, timeUnit, TimeoutException.class);
- }
-
- /**
- * Creates a matcher that matches a future that will be cancelled and decently fast.
- *
- * @return matcher.
- */
- public static CompletableFutureMatcher<Object> willBeCancelledFast() {
- return willBeCancelledIn(1, TimeUnit.SECONDS);
- }
-
- /**
- * Creates a matcher that matches a future that will be cancelled within the given timeout.
- *
- * @param time Timeout.
- * @param timeUnit Time unit for timeout.
- * @return matcher.
- */
- public static CompletableFutureMatcher<Object> willBeCancelledIn(int time, TimeUnit timeUnit) {
- return new CompletableFutureMatcher<>(anything(), time, timeUnit, CancellationException.class);
+ return new CompletableFutureMatcher<>(anything(), time, timeUnit);
}
/**
diff --git a/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageManagerImplTest.java b/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageManagerImplTest.java
index e07995cb97..c37073a221 100644
--- a/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageManagerImplTest.java
+++ b/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageManagerImplTest.java
@@ -21,9 +21,9 @@ import static java.util.concurrent.CompletableFuture.completedFuture;
import static java.util.stream.Collectors.toList;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition;
import static org.apache.ignite.internal.testframework.flow.TestFlowUtils.subscribeToList;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.will;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBeCancelledFast;
import static org.apache.ignite.utils.ClusterServiceTestUtils.clusterService;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.when;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;
import org.apache.ignite.internal.cluster.management.ClusterManagementGroupManager;
@@ -261,7 +262,7 @@ public class ItMetaStorageManagerImplTest extends IgniteAbstractTest {
CompletableFuture<Entry> fut = svc.get(ByteArray.fromString("ignored"));
- assertThat(fut, willBeCancelledFast());
+ assertThat(fut, willThrowFast(CancellationException.class));
}
@Test
@@ -290,6 +291,6 @@ public class ItMetaStorageManagerImplTest extends IgniteAbstractTest {
// stop method.
cmgFut.complete(msNodes);
- assertThat(metaStorageManager.metaStorageServiceFuture(), willBeCancelledFast());
+ assertThat(metaStorageManager.metaStorageServiceFuture(), willThrowFast(CancellationException.class));
}
}
diff --git a/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java b/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java
index 2b25b4f2de..4b27d01123 100644
--- a/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java
+++ b/modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageServiceTest.java
@@ -30,9 +30,9 @@ import static org.apache.ignite.internal.metastorage.dsl.Statements.iif;
import static org.apache.ignite.internal.metastorage.impl.ItMetaStorageServiceTest.ServerConditionMatcher.cond;
import static org.apache.ignite.internal.testframework.flow.TestFlowUtils.subscribeToList;
import static org.apache.ignite.internal.testframework.flow.TestFlowUtils.subscribeToValue;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
import static org.apache.ignite.utils.ClusterServiceTestUtils.findLocalAddresses;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@@ -670,7 +670,7 @@ public class ItMetaStorageServiceTest {
CompletableFuture<List<Entry>> future =
subscribeToList(node.metaStorageService.range(new ByteArray(EXPECTED_RESULT_ENTRY.key()), null));
- assertThat(future, willFailFast(NoSuchElementException.class));
+ assertThat(future, willThrowFast(NoSuchElementException.class));
}
/**
@@ -929,8 +929,8 @@ public class ItMetaStorageServiceTest {
closeCursorLatch.countDown();
- assertThat(node0Subscriber0.result, willFailFast(NoSuchElementException.class));
- assertThat(node0Subscriber1.result, willFailFast(NoSuchElementException.class));
+ assertThat(node0Subscriber0.result, willThrowFast(NoSuchElementException.class));
+ assertThat(node0Subscriber1.result, willThrowFast(NoSuchElementException.class));
assertThat(node1Subscriber0.result, willBe(EXPECTED_RESULT_ENTRY));
}
diff --git a/modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/impl/CursorPublisherTest.java b/modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/impl/CursorPublisherTest.java
index f58e2e34d4..b197ae24fe 100644
--- a/modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/impl/CursorPublisherTest.java
+++ b/modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/impl/CursorPublisherTest.java
@@ -21,10 +21,10 @@ import static java.util.Collections.nCopies;
import static java.util.concurrent.CompletableFuture.completedFuture;
import static java.util.concurrent.CompletableFuture.failedFuture;
import static java.util.concurrent.CompletableFuture.supplyAsync;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrow;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.will;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailIn;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -154,7 +154,7 @@ public class CursorPublisherTest {
publisher.subscribe(subscriber);
- assertThat(awaitFuture, willFailFast(IllegalStateException.class));
+ assertThat(awaitFuture, willThrowFast(IllegalStateException.class));
}
@Test
@@ -188,7 +188,7 @@ public class CursorPublisherTest {
publisher.subscribe(subscriber);
- assertThat(awaitFuture, willFailIn(10, TimeUnit.SECONDS, IllegalStateException.class));
+ assertThat(awaitFuture, willThrow(IllegalStateException.class, 10, TimeUnit.SECONDS));
verify(raftService, times(2)).run(any(NextBatchCommand.class));
verify(subscriber, times(5)).onNext(any());
diff --git a/modules/rest/src/test/java/org/apache/ignite/internal/rest/authentication/DelegatingAuthenticationProviderTest.java b/modules/rest/src/test/java/org/apache/ignite/internal/rest/authentication/DelegatingAuthenticationProviderTest.java
index 16f26fc5c7..83372a1803 100644
--- a/modules/rest/src/test/java/org/apache/ignite/internal/rest/authentication/DelegatingAuthenticationProviderTest.java
+++ b/modules/rest/src/test/java/org/apache/ignite/internal/rest/authentication/DelegatingAuthenticationProviderTest.java
@@ -18,8 +18,8 @@
package org.apache.ignite.internal.rest.authentication;
import static org.apache.ignite.internal.testframework.flow.TestFlowUtils.subscribeToValue;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertAll;
@@ -81,7 +81,7 @@ class DelegatingAuthenticationProviderTest {
// unsuccessful authentication with invalid credentials
UsernamePasswordCredentials invalidCredentials = new UsernamePasswordCredentials("admin", "wrong-password");
- assertThat(authenticate(provider, invalidCredentials), willFailFast(AuthenticationException.class));
+ assertThat(authenticate(provider, invalidCredentials), willThrowFast(AuthenticationException.class));
}
@@ -245,7 +245,7 @@ class DelegatingAuthenticationProviderTest {
provider.onUpdate(new StubAuthenticationViewEvent(adminPasswordAuthView, adminNewPasswordAuthView)).join();
- assertThat(authenticate(provider, adminPasswordCredentials), willFailFast(AuthenticationException.class));
+ assertThat(authenticate(provider, adminPasswordCredentials), willThrowFast(AuthenticationException.class));
// then
// successful authentication with the new password
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/configuration/storage/ItRebalanceDistributedTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/configuration/storage/ItRebalanceDistributedTest.java
index 933592c6ea..a5ffa5a198 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/configuration/storage/ItRebalanceDistributedTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/configuration/storage/ItRebalanceDistributedTest.java
@@ -19,8 +19,8 @@ package org.apache.ignite.internal.configuration.storage;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.await;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willSucceedIn;
import static org.apache.ignite.internal.util.CollectionUtils.first;
import static org.apache.ignite.internal.utils.RebalanceUtil.STABLE_ASSIGNMENTS_PREFIX;
@@ -508,7 +508,7 @@ public class ItRebalanceDistributedTest {
TablePartitionId tablePartitionId = evictedNode.getTablePartitionId(TABLE_1_NAME, 0);
- assertThat(evictedNode.finishHandleChangeStableAssignmentEventFutures.get(tablePartitionId), willFailFast(Exception.class));
+ assertThat(evictedNode.finishHandleChangeStableAssignmentEventFutures.get(tablePartitionId), willThrowFast(Exception.class));
// Restart evicted node.
int evictedNodeIndex = findNodeIndexByConsistentId(evictedAssignment.consistentId());
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ssl/ItSslTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ssl/ItSslTest.java
index 7db38f70af..1319d39028 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ssl/ItSslTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ssl/ItSslTest.java
@@ -21,8 +21,8 @@ import static org.apache.ignite.client.ClientAuthenticationMode.REQUIRE;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.escapeWindowsPath;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.getResourcePath;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willTimeoutIn;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willTimeoutIn;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
diff --git a/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/util/MvPartitionStoragesTest.java b/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/util/MvPartitionStoragesTest.java
index 345c070f1e..40cc6f50b7 100644
--- a/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/util/MvPartitionStoragesTest.java
+++ b/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/util/MvPartitionStoragesTest.java
@@ -20,9 +20,9 @@ package org.apache.ignite.internal.storage.util;
import static java.util.concurrent.CompletableFuture.completedFuture;
import static java.util.concurrent.CompletableFuture.failedFuture;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.runAsync;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willTimeoutFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willTimeoutFast;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
@@ -115,7 +115,7 @@ public class MvPartitionStoragesTest {
assertThat(mvPartitionStorages.create(2, partId -> {
throw new RuntimeException("from test");
- }), willFailFast(RuntimeException.class));
+ }), willThrowFast(RuntimeException.class));
assertNull(getMvStorage(2));
}
@@ -163,22 +163,20 @@ public class MvPartitionStoragesTest {
CompletableFuture<Void> startErrorDestroyMvStorageFuture = new CompletableFuture<>();
CompletableFuture<Void> finishErrorDestroyMvStorageFuture = new CompletableFuture<>();
- CompletableFuture<?> errorDestroyMvStorageFuture = runAsync(() ->
- assertThat(mvPartitionStorages.destroy(0, mvStorage1 -> {
- startErrorDestroyMvStorageFuture.complete(null);
+ CompletableFuture<?> errorDestroyMvStorageFuture = mvPartitionStorages.destroy(0, mvStorage1 -> {
+ startErrorDestroyMvStorageFuture.complete(null);
- return finishErrorDestroyMvStorageFuture;
- }), willCompleteSuccessfully())
- );
+ return finishErrorDestroyMvStorageFuture;
+ });
assertThat(startErrorDestroyMvStorageFuture, willCompleteSuccessfully());
CompletableFuture<MvPartitionStorage> errorReCreateMvStorageFuture = createMvStorage(0);
- finishErrorDestroyMvStorageFuture.completeExceptionally(new RuntimeException("from test"));
+ finishErrorDestroyMvStorageFuture.completeExceptionally(new IllegalStateException("from test"));
- assertThat(errorDestroyMvStorageFuture, willFailFast(RuntimeException.class));
- assertThat(errorReCreateMvStorageFuture, willFailFast(RuntimeException.class));
+ assertThat(errorDestroyMvStorageFuture, willThrowFast(IllegalStateException.class));
+ assertThat(errorReCreateMvStorageFuture, willThrowFast(IllegalStateException.class));
assertNull(getMvStorage(0));
}
@@ -241,7 +239,7 @@ public class MvPartitionStoragesTest {
assertThat(
mvPartitionStorages.destroy(0, mvStorage -> failedFuture(new RuntimeException("from test"))),
- willFailFast(RuntimeException.class)
+ willThrowFast(RuntimeException.class)
);
assertNull(getMvStorage(0));
@@ -299,7 +297,7 @@ public class MvPartitionStoragesTest {
assertThat(
mvPartitionStorages.clear(0, mvStorage -> failedFuture(new RuntimeException("from test"))),
- willFailFast(RuntimeException.class)
+ willThrowFast(RuntimeException.class)
);
assertNotNull(getMvStorage(0));
@@ -356,7 +354,7 @@ public class MvPartitionStoragesTest {
assertThat(
mvPartitionStorages.startRebalance(0, mvStorage -> failedFuture(new RuntimeException("from test"))),
- willFailFast(RuntimeException.class)
+ willThrowFast(RuntimeException.class)
);
assertNotNull(getMvStorage(0));
@@ -423,7 +421,7 @@ public class MvPartitionStoragesTest {
assertThat(
mvPartitionStorages.startRebalance(0, mvStorage -> failedFuture(new RuntimeException("from test"))),
- willFailFast(RuntimeException.class)
+ willThrowFast(RuntimeException.class)
);
assertThat(mvPartitionStorages.abortRebalance(0, mvStorage -> {
@@ -449,7 +447,7 @@ public class MvPartitionStoragesTest {
assertThat(
mvPartitionStorages.abortRebalance(0, mvStorage -> failedFuture(new RuntimeException("from test"))),
- willFailFast(RuntimeException.class)
+ willThrowFast(RuntimeException.class)
);
}
@@ -505,7 +503,7 @@ public class MvPartitionStoragesTest {
assertThat(
mvPartitionStorages.finishRebalance(0, mvStorage -> failedFuture(new RuntimeException("from test"))),
- willFailFast(RuntimeException.class)
+ willThrowFast(RuntimeException.class)
);
// What if the start of the rebalance fails?
@@ -514,10 +512,10 @@ public class MvPartitionStoragesTest {
assertThat(
mvPartitionStorages.startRebalance(0, mvStorage -> failedFuture(new RuntimeException("from test"))),
- willFailFast(RuntimeException.class)
+ willThrowFast(RuntimeException.class)
);
- assertThat(finishRebalanceMvStorage(0), willFailFast(RuntimeException.class));
+ assertThat(finishRebalanceMvStorage(0), willThrowFast(RuntimeException.class));
}
@Test
diff --git a/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/util/ReentrantLockByRowIdTest.java b/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/util/ReentrantLockByRowIdTest.java
index 6749372b52..2e92174c79 100644
--- a/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/util/ReentrantLockByRowIdTest.java
+++ b/modules/storage-api/src/test/java/org/apache/ignite/internal/storage/util/ReentrantLockByRowIdTest.java
@@ -18,8 +18,8 @@
package org.apache.ignite.internal.storage.util;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.runAsync;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willTimeoutFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willTimeoutFast;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java
index 21e04bcf5a..0e3fcebcb2 100644
--- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java
+++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvTableStorageTest.java
@@ -20,8 +20,8 @@ package org.apache.ignite.internal.storage;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
import static org.apache.ignite.internal.storage.MvPartitionStorage.REBALANCE_IN_PROGRESS;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
@@ -548,7 +548,7 @@ public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
mvPartitionStorage.close();
- assertThat(tableStorage.startRebalancePartition(PARTITION_ID), willFailFast(StorageRebalanceException.class));
+ assertThat(tableStorage.startRebalancePartition(PARTITION_ID), willThrowFast(StorageRebalanceException.class));
}
@Test
@@ -704,8 +704,8 @@ public abstract class AbstractMvTableStorageTest extends BaseMvStoragesTest {
assertThat(tableStorage.startRebalancePartition(PARTITION_ID + 1), willCompleteSuccessfully());
try {
- assertThat(tableStorage.clearPartition(PARTITION_ID), willFailFast(StorageClosedException.class));
- assertThat(tableStorage.clearPartition(PARTITION_ID + 1), willFailFast(StorageRebalanceException.class));
+ assertThat(tableStorage.clearPartition(PARTITION_ID), willThrowFast(StorageClosedException.class));
+ assertThat(tableStorage.clearPartition(PARTITION_ID + 1), willThrowFast(StorageRebalanceException.class));
} finally {
assertThat(tableStorage.abortRebalancePartition(PARTITION_ID + 1), willCompleteSuccessfully());
}
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/gc/MvGcTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/gc/MvGcTest.java
index 7df77e99f5..2d7b56a2da 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/gc/MvGcTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/gc/MvGcTest.java
@@ -18,9 +18,9 @@
package org.apache.ignite.internal.table.distributed.gc;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.runRace;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willTimeoutFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willTimeoutFast;
import static org.apache.ignite.internal.util.IgniteUtils.closeAllManually;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
@@ -259,9 +259,9 @@ public class MvGcTest {
assertThat(removeStorageFuture, willTimeoutFast());
- finishInvokeVacuumMethodFuture.completeExceptionally(new RuntimeException("form test"));
+ finishInvokeVacuumMethodFuture.completeExceptionally(new IllegalStateException("from test"));
- assertThat(removeStorageFuture, willFailFast(RuntimeException.class));
+ assertThat(removeStorageFuture, willThrowFast(IllegalStateException.class));
}
@Test
@@ -387,7 +387,7 @@ public class MvGcTest {
when(storageUpdateHandler.vacuum(any(HybridTimestamp.class))).then(invocation -> {
startFuture.complete(null);
- assertThat(finishFuture, willCompleteSuccessfully());
+ finishFuture.get(1, TimeUnit.SECONDS);
return false;
});
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/raft/snapshot/incoming/IncomingSnapshotCopierTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/raft/snapshot/incoming/IncomingSnapshotCopierTest.java
index 8e66e4bcdd..b8e0847d33 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/raft/snapshot/incoming/IncomingSnapshotCopierTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/raft/snapshot/incoming/IncomingSnapshotCopierTest.java
@@ -20,8 +20,8 @@ package org.apache.ignite.internal.table.distributed.raft.snapshot.incoming;
import static java.util.concurrent.CompletableFuture.completedFuture;
import static java.util.stream.Collectors.toList;
import static org.apache.ignite.internal.testframework.IgniteTestUtils.runAsync;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willSucceedIn;
import static org.apache.ignite.internal.tx.TxState.ABORTED;
import static org.apache.ignite.internal.tx.TxState.COMMITED;
@@ -585,7 +585,7 @@ public class IncomingSnapshotCopierTest {
);
// Let's wait for an error on rebalancing.
- assertThat(runAsync(snapshotCopier::join), willFailFast(IllegalStateException.class));
+ assertThat(runAsync(snapshotCopier::join), willThrowFast(IllegalStateException.class));
verify(partitionSnapshotStorage.partition()).abortRebalance();
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
index ea9c401d64..5b191a1b28 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.table.distributed.replication;
import static java.util.concurrent.CompletableFuture.completedFuture;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willSucceedFast;
import static org.apache.ignite.internal.util.ArrayUtils.asList;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -1036,7 +1036,7 @@ public class PartitionReplicaListenerTest extends IgniteAbstractTest {
// Check that one more write after cleanup is discarded.
CompletableFuture<?> writeAfterCleanupFuture = partitionReplicaListener.invoke(updatingRequestSupplier.get());
- assertThat(writeAfterCleanupFuture, willFailFast(TransactionException.class));
+ assertThat(writeAfterCleanupFuture, willThrowFast(TransactionException.class));
}
@Test
diff --git a/modules/transactions/src/test/java/org/apache/ignite/internal/tx/NoWaitDeadlockPreventionTest.java b/modules/transactions/src/test/java/org/apache/ignite/internal/tx/NoWaitDeadlockPreventionTest.java
index 87944cf244..52f258d456 100644
--- a/modules/transactions/src/test/java/org/apache/ignite/internal/tx/NoWaitDeadlockPreventionTest.java
+++ b/modules/transactions/src/test/java/org/apache/ignite/internal/tx/NoWaitDeadlockPreventionTest.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.tx;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willSucceedFast;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -103,8 +103,8 @@ public class NoWaitDeadlockPreventionTest extends AbstractLockingTest {
assertThat(slock(tx0, key), willSucceedFast());
assertThat(slock(tx1, key), willSucceedFast());
- assertThat(xlock(tx0, key), willFailFast(LockException.class));
- assertThat(xlock(tx1, key), willFailFast(LockException.class));
+ assertThat(xlock(tx0, key), willThrowFast(LockException.class));
+ assertThat(xlock(tx1, key), willThrowFast(LockException.class));
}
@Test
@@ -118,7 +118,7 @@ public class NoWaitDeadlockPreventionTest extends AbstractLockingTest {
assertThat(xlock(tx0, key0), willSucceedFast());
assertThat(xlock(tx1, key1), willSucceedFast());
- assertThat(xlock(tx0, key1), willFailFast(LockException.class));
- assertThat(xlock(tx1, key0), willFailFast(LockException.class));
+ assertThat(xlock(tx0, key1), willThrowFast(LockException.class));
+ assertThat(xlock(tx1, key0), willThrowFast(LockException.class));
}
}
diff --git a/modules/transactions/src/test/java/org/apache/ignite/internal/tx/TimeoutDeadlockPreventionTest.java b/modules/transactions/src/test/java/org/apache/ignite/internal/tx/TimeoutDeadlockPreventionTest.java
index 770493e224..56b42d9711 100644
--- a/modules/transactions/src/test/java/org/apache/ignite/internal/tx/TimeoutDeadlockPreventionTest.java
+++ b/modules/transactions/src/test/java/org/apache/ignite/internal/tx/TimeoutDeadlockPreventionTest.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.tx;
-import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willFailFast;
+import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowFast;
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willSucceedFast;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -89,7 +89,7 @@ public class TimeoutDeadlockPreventionTest extends AbstractDeadlockPreventionTes
commitTx(tx1);
- assertThat(tx2Fut, willFailFast(LockException.class));
+ assertThat(tx2Fut, willThrowFast(LockException.class));
}
@Test
@@ -108,7 +108,7 @@ public class TimeoutDeadlockPreventionTest extends AbstractDeadlockPreventionTes
commitTx(tx2);
- assertThat(tx2Fut, willFailFast(LockException.class));
+ assertThat(tx2Fut, willThrowFast(LockException.class));
}
@Test
@@ -121,8 +121,8 @@ public class TimeoutDeadlockPreventionTest extends AbstractDeadlockPreventionTes
assertThat(slock(tx0, key), willSucceedFast());
assertThat(slock(tx1, key), willSucceedFast());
- assertThat(xlock(tx0, key), willFailFast(LockException.class));
- assertThat(xlock(tx1, key), willFailFast(LockException.class));
+ assertThat(xlock(tx0, key), willThrowFast(LockException.class));
+ assertThat(xlock(tx1, key), willThrowFast(LockException.class));
}
@Test
@@ -136,7 +136,7 @@ public class TimeoutDeadlockPreventionTest extends AbstractDeadlockPreventionTes
assertThat(xlock(tx0, key0), willSucceedFast());
assertThat(xlock(tx1, key1), willSucceedFast());
- assertThat(xlock(tx0, key1), willFailFast(LockException.class));
- assertThat(xlock(tx1, key0), willFailFast(LockException.class));
+ assertThat(xlock(tx0, key1), willThrowFast(LockException.class));
+ assertThat(xlock(tx1, key0), willThrowFast(LockException.class));
}
}