You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by dc...@apache.org on 2021/11/16 22:43:42 UTC
[cassandra] branch trunk updated: Fix test distributed.test.trackwarnings.TombstoneWarningTest
This is an automated email from the ASF dual-hosted git repository.
dcapwell pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 1c79c68 Fix test distributed.test.trackwarnings.TombstoneWarningTest
1c79c68 is described below
commit 1c79c6823c6eac002d912afb979f6f9fa7fe61e6
Author: David Capwell <dc...@apache.org>
AuthorDate: Tue Nov 16 12:38:38 2021 -0800
Fix test distributed.test.trackwarnings.TombstoneWarningTest
patch by David Capwell; reviewed by Caleb Rackliffe for CASSANDRA-17156
---
...ingTest.java => TombstoneCountWarningTest.java} | 26 +++++++++++++++-------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/TombstoneWarningTest.java b/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/TombstoneCountWarningTest.java
similarity index 91%
rename from test/distributed/org/apache/cassandra/distributed/test/trackwarnings/TombstoneWarningTest.java
rename to test/distributed/org/apache/cassandra/distributed/test/trackwarnings/TombstoneCountWarningTest.java
index be83fc1..66bd60d 100644
--- a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/TombstoneWarningTest.java
+++ b/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/TombstoneCountWarningTest.java
@@ -26,7 +26,7 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
-import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -53,8 +53,11 @@ import org.apache.cassandra.service.ClientWarn;
import org.apache.cassandra.service.QueryState;
import org.apache.cassandra.service.reads.trackwarnings.CoordinatorWarnings;
import org.assertj.core.api.Assertions;
+import org.assertj.core.api.Condition;
-public class TombstoneWarningTest extends TestBaseImpl
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class TombstoneCountWarningTest extends TestBaseImpl
{
private static final int TOMBSTONE_WARN = 50;
private static final int TOMBSTONE_FAIL = 100;
@@ -228,12 +231,19 @@ public class TombstoneWarningTest extends TestBaseImpl
// without changing the client can't produce a better message...
// client does NOT include the message sent from the server in the exception; so the message doesn't work
// well in this case
- Assertions.assertThat(e.getMessage()).contains("(3 responses were required but only 0 replica responded"); // can't include ', 3 failed)' as some times its 2
- Assertions.assertThat(e.getFailuresMap())
- .isEqualTo(ImmutableMap.of(
- InetAddress.getByAddress(new byte[] {127, 0, 0, 1}), RequestFailureReason.READ_TOO_MANY_TOMBSTONES.code,
- InetAddress.getByAddress(new byte[] {127, 0, 0, 2}), RequestFailureReason.READ_TOO_MANY_TOMBSTONES.code,
- InetAddress.getByAddress(new byte[] {127, 0, 0, 3}), RequestFailureReason.READ_TOO_MANY_TOMBSTONES.code));
+ Assertions.assertThat(e.getMessage()).contains("responses were required but only 0 replica responded"); // can't include ', 3 failed)' as some times its 2
+
+ ImmutableSet<InetAddress> expectedKeys = ImmutableSet.of(InetAddress.getByAddress(new byte[]{ 127, 0, 0, 1 }), InetAddress.getByAddress(new byte[]{ 127, 0, 0, 2 }), InetAddress.getByAddress(new byte[]{ 127, 0, 0, 3 }));
+ assertThat(e.getFailuresMap())
+ .hasSizeBetween(1, 3)
+ // coordinator changes from run to run, so can't assert map as the key is dynamic... so assert the domain of keys and the single value expect
+ .containsValue(RequestFailureReason.READ_TOO_MANY_TOMBSTONES.code)
+ .hasKeySatisfying(new Condition<InetAddress>() {
+ public boolean matches(InetAddress value)
+ {
+ return expectedKeys.contains(value);
+ }
+ });
}
assertWarnAborts(0, 2, 1);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org