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 2020/02/05 02:04:02 UTC

[GitHub] [cassandra] dcapwell commented on a change in pull request #435: repair token boundary in-jvm tests for CASSANDRA-15542

dcapwell commented on a change in pull request #435: repair token boundary in-jvm tests for CASSANDRA-15542
URL: https://github.com/apache/cassandra/pull/435#discussion_r374997108
 
 

 ##########
 File path: test/distributed/org/apache/cassandra/distributed/test/RepairBoundaryTest.java
 ##########
 @@ -0,0 +1,197 @@
+/*
+ * 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.test;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.google.common.collect.ImmutableList;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.impl.IInvokableInstance;
+import org.apache.cassandra.service.StorageService;
+import org.apache.cassandra.utils.concurrent.SimpleCondition;
+import org.apache.cassandra.utils.progress.ProgressEventType;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.apache.cassandra.dht.Murmur3Partitioner.*;
+import static org.apache.cassandra.dht.Murmur3Partitioner.LongToken.keyForToken;
+import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+
+public class RepairBoundaryTest extends DistributedTestBase
+{
+    private static Cluster cluster;
+
+    private static final String INSERT = withKeyspace("INSERT INTO %s.test (k, c1, c2) VALUES" +
+                                                      "(?, 'C1', ?);");
+
+    private static final String DELETE = withKeyspace("DELETE FROM %s.test WHERE k = ?;");
+    private static final String ALL = withKeyspace("SELECT c2 FROM %s.test;");
+
+    private final Map<Integer, ByteBuffer> keys = new HashMap<>();
+
+    private Object[][] c2Row(int... keys)
+    {
+        Object[][] ret = new Object[keys.length][];
+        for (int i = 0; i < keys.length; i++)
+        {
+            ret[i] = new Object[]{ String.valueOf(keys[i]) };
+        }
+        return ret;
+    }
+
+    void delete(IInvokableInstance instance, int... toDelete)
+    {
+        for (int key : toDelete)
+        {
+            instance.executeInternal(DELETE, keys.get(key));
+        }
+    }
+
+    void verify()
+    {
+        assertRows(c2Row(999, 1000, 2001, 2999, 3000, 3001), cluster.get(1).executeInternal(ALL));
+        assertRows(c2Row(999, 1000, 1001, 1999, 2000, 3001), cluster.get(2).executeInternal(ALL));
+        assertRows(c2Row(1001, 1999, 2000, 2001, 2999, 3000), cluster.get(3).executeInternal(ALL));
+    }
+
+    /**
+     * Insert on every token boundary and + or - to first replica.
+     */
+    void populate()
+    {
+        try
+        {
+            cluster.schemaChange(withKeyspace("DROP TABLE IF EXISTS %s.test;"));
+            cluster.schemaChange(withKeyspace("CREATE TABLE %s.test (k blob, c1 text, c2 text," +
+                                              "PRIMARY KEY (k))"));
+
+            for (int i = 1000; i <= 3000; i += 1000)
+            {
+                keys.put(i, keyForToken(new LongToken(i)));
+                keys.put(i - 1, keyForToken(new LongToken(i - 1)));
+                keys.put(i + 1, keyForToken(new LongToken(i + 1)));
+
+                cluster.coordinator(1).execute(INSERT, ConsistencyLevel.ALL, keys.get(i), String.valueOf(i));
 
 Review comment:
   not a you thing, but have found `ConsistencyLevel.ALL` to be flaky in jvm dtests; its possible this will cause the tests to fail in CI.
   
   Not recommending you change it here, but we should look into default timeouts for dtest or have execute run until success (cc @ifesdjeen )

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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