You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/04/11 15:06:54 UTC

[GitHub] [cassandra] ifesdjeen commented on a diff in pull request #1432: CASSANDRA-17332 Add support for vnodes in jvm-dtest

ifesdjeen commented on code in PR #1432:
URL: https://github.com/apache/cassandra/pull/1432#discussion_r847432130


##########
test/distributed/org/apache/cassandra/distributed/test/CASTest.java:
##########
@@ -79,8 +79,9 @@ public static void beforeClass() throws Throwable
                                                    .set("write_request_timeout", REQUEST_TIMEOUT)
                                                    .set("cas_contention_timeout", CONTENTION_TIMEOUT)
                                                    .set("request_timeout", REQUEST_TIMEOUT);
-        THREE_NODES = init(Cluster.create(3, conf));
-        FOUR_NODES = init(Cluster.create(4, conf), 3);
+        // TODO: fails with vnode enabled

Review Comment:
   Should we file a jira for this? I can't see anything in this test that should make it fail with vnodes, could be a bug or test bug?
   



##########
test/distributed/org/apache/cassandra/distributed/impl/AbstractClusterTest.java:
##########
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cassandra.distributed.impl;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Consumer;
+
+import org.junit.AssumptionViolatedException;
+import org.junit.Test;
+
+import org.apache.cassandra.distributed.api.IInstanceConfig;
+import org.apache.cassandra.distributed.api.IInvokableInstance;
+import org.apache.cassandra.distributed.api.TokenSupplier;
+import org.apache.cassandra.distributed.impl.AbstractCluster.AbstractBuilder;
+import org.apache.cassandra.distributed.shared.Versions;
+import org.apache.cassandra.utils.FailingRunnable;
+import org.assertj.core.api.Assertions;
+import org.mockito.Mockito;
+
+
+public class AbstractClusterTest
+{
+    @Test
+    public void allowVnodeWithMultipleTokens()
+    {
+        AbstractBuilder builder = builder();
+        builder.withTokenCount(42);
+        unroll(() -> builder.createWithoutStarting());
+    }
+
+    @Test
+    public void allowVnodeWithSingleToken()
+    {
+        AbstractBuilder builder = builder();
+        builder.withTokenCount(1);
+        unroll(() -> builder.createWithoutStarting());
+    }
+
+    @Test
+    public void disallowVnodeWithMultipleTokens()
+    {
+        AbstractBuilder builder = builder();
+
+        builder.withoutVNodes();
+        builder.withTokenCount(42);
+
+        Assertions.assertThatThrownBy(() -> builder.createWithoutStarting())
+                  .isInstanceOf(AssumptionViolatedException.class)
+                  .hasMessage("vnode is not supported");
+    }
+
+
+    @Test
+    public void disallowVnodeWithSingleToken()
+    {
+        AbstractBuilder builder = builder();
+
+        builder.withoutVNodes();
+        builder.withTokenCount(1);
+
+        unroll(() -> builder.createWithoutStarting());
+    }
+
+    @Test
+    public void withoutVNodes()
+    {
+        AbstractBuilder builder = builder();
+
+        builder.withoutVNodes();
+        //TODO casting is annoying... what can be done to be smarter?
+        builder.withTokenSupplier((TokenSupplier) i -> Arrays.asList("a", "b", "c"));
+
+        Assertions.assertThatThrownBy(() -> builder.createWithoutStarting())
+                  .isInstanceOf(AssumptionViolatedException.class)
+                  .hasMessage("vnode is not supported");
+    }
+
+    @Test
+    public void vnodeButTokensDoNotMatch()
+    {
+        AbstractBuilder builder = builder();
+
+        builder.withTokenCount(1);
+        //TODO casting is annoying... what can be done to be smarter?

Review Comment:
   I'm not sure there's an easy way out, really: we can remove the SingleTokenSupplier interface to disambiguate though.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org