You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2020/06/22 14:18:47 UTC

[cassandra] branch trunk updated: Update driver version to prevent issues with extra events being received when a node is decommissioned.

This is an automated email from the ASF dual-hosted git repository.

brandonwilliams 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 02a80ef  Update driver version to prevent issues with extra events being received when a node is decommissioned.
02a80ef is described below

commit 02a80ef94fc8ea4dd5ef443869ce1a4e9f37c817
Author: bryn <br...@gmail.com>
AuthorDate: Fri Jun 19 13:06:06 2020 +0100

    Update driver version to prevent issues with extra events being received when a node is decommissioned.
    
    Patch by Bryn Cooke, reviewed by brandonwilliams for CASSANDRA-15677
---
 build.xml                                          |   2 +-
 ....jar => cassandra-driver-core-3.9.0-shaded.jar} | Bin 2725381 -> 2757525 bytes
 .../distributed/test/NodeDecommissionTest.java     |  57 ------
 .../distributed/test/TopologyChangeTest.java       | 198 +++++++++++++++++++++
 .../cassandra/auth/PasswordAuthenticatorTest.java  |   3 +-
 5 files changed, 201 insertions(+), 59 deletions(-)

diff --git a/build.xml b/build.xml
index 2d10819..15d4276 100644
--- a/build.xml
+++ b/build.xml
@@ -599,7 +599,7 @@
 	  </dependency>
           <dependency groupId="com.google.code.findbugs" artifactId="jsr305" version="2.0.2" />
           <dependency groupId="com.clearspring.analytics" artifactId="stream" version="2.5.2" />
-          <dependency groupId="com.datastax.cassandra" artifactId="cassandra-driver-core" version="3.6.0" classifier="shaded">
+          <dependency groupId="com.datastax.cassandra" artifactId="cassandra-driver-core" version="3.9.0" classifier="shaded">
             <exclusion groupId="io.netty" artifactId="netty-buffer"/>
             <exclusion groupId="io.netty" artifactId="netty-codec"/>
             <exclusion groupId="io.netty" artifactId="netty-handler"/>
diff --git a/lib/cassandra-driver-core-3.6.0-shaded.jar b/lib/cassandra-driver-core-3.9.0-shaded.jar
similarity index 69%
rename from lib/cassandra-driver-core-3.6.0-shaded.jar
rename to lib/cassandra-driver-core-3.9.0-shaded.jar
index ea06b02..1ecabbb 100644
Binary files a/lib/cassandra-driver-core-3.6.0-shaded.jar and b/lib/cassandra-driver-core-3.9.0-shaded.jar differ
diff --git a/test/distributed/org/apache/cassandra/distributed/test/NodeDecommissionTest.java b/test/distributed/org/apache/cassandra/distributed/test/NodeDecommissionTest.java
deleted file mode 100644
index 43aaadb..0000000
--- a/test/distributed/org/apache/cassandra/distributed/test/NodeDecommissionTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.util.concurrent.TimeUnit;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datastax.driver.core.Session;
-import org.apache.cassandra.distributed.Cluster;
-
-import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
-import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL;
-import static org.apache.cassandra.distributed.api.Feature.NETWORK;
-import static org.apache.cassandra.distributed.impl.INodeProvisionStrategy.Strategy.OneNetworkInterface;
-import static org.awaitility.Awaitility.await;
-
-public class NodeDecommissionTest extends TestBaseImpl
-{
-
-    @Test
-    public void testDecomissionSucceedsForNodesOnTheSameInterface() throws Throwable
-    {
-        try (Cluster control = init(Cluster.build().withNodes(3).withNodeProvisionStrategy(OneNetworkInterface).withConfig(
-        config -> {
-            config.with(GOSSIP, NETWORK, NATIVE_PROTOCOL);
-        }).start()))
-        {
-            final com.datastax.driver.core.Cluster cluster = com.datastax.driver.core.Cluster.builder().addContactPoint("127.0.0.1").build();
-            Session session = cluster.connect();
-            control.get(3).nodetool("disablebinary");
-            control.get(3).nodetool("decommission", "-f");
-            await().atMost(10, TimeUnit.SECONDS)
-                   .untilAsserted(() -> Assert.assertEquals(2, cluster.getMetadata().getAllHosts().size()));
-            session.close();
-            cluster.close();
-        }
-    }
-}
-
diff --git a/test/distributed/org/apache/cassandra/distributed/test/TopologyChangeTest.java b/test/distributed/org/apache/cassandra/distributed/test/TopologyChangeTest.java
new file mode 100644
index 0000000..f766775
--- /dev/null
+++ b/test/distributed/org/apache/cassandra/distributed/test/TopologyChangeTest.java
@@ -0,0 +1,198 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import com.datastax.driver.core.Host;
+import com.datastax.driver.core.Session;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.IInvokableInstance;
+import org.apache.cassandra.distributed.impl.INodeProvisionStrategy.Strategy;
+import org.apache.cassandra.distributed.test.TopologyChangeTest.EventStateListener.Event;
+
+import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
+import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+import static org.apache.cassandra.distributed.impl.INodeProvisionStrategy.Strategy.MultipleNetworkInterfaces;
+import static org.apache.cassandra.distributed.impl.INodeProvisionStrategy.Strategy.OneNetworkInterface;
+import static org.apache.cassandra.distributed.test.TopologyChangeTest.EventStateListener.EventType.Down;
+import static org.apache.cassandra.distributed.test.TopologyChangeTest.EventStateListener.EventType.Remove;
+import static org.apache.cassandra.distributed.test.TopologyChangeTest.EventStateListener.EventType.Up;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+@RunWith(Parameterized.class)
+public class TopologyChangeTest extends TestBaseImpl
+{
+    static class EventStateListener implements Host.StateListener
+    {
+        enum EventType
+        {
+            Add,
+            Up,
+            Down,
+            Remove,
+        }
+
+        static class Event
+        {
+            String host;
+            EventType type;
+
+            Event(EventType type, Host host)
+            {
+                this.type = type;
+                this.host = host.getBroadcastSocketAddress().toString();
+            }
+
+            public Event(EventType type, IInvokableInstance iInvokableInstance)
+            {
+                this.type = type;
+                this.host = iInvokableInstance.broadcastAddress().toString();
+            }
+
+
+            public String toString()
+            {
+                return "Event{" +
+                       "host='" + host + '\'' +
+                       ", type=" + type +
+                       '}';
+            }
+
+            public boolean equals(Object o)
+            {
+                if (this == o) return true;
+                if (o == null || getClass() != o.getClass()) return false;
+                Event event = (Event) o;
+                return Objects.equals(host, event.host) &&
+                       type == event.type;
+            }
+
+            public int hashCode()
+            {
+                return Objects.hash(host, type);
+            }
+        }
+
+        private List<Event> events = new ArrayList<>();
+
+        public void onAdd(Host host)
+        {
+            events.add(new Event(EventType.Add, host));
+        }
+
+        public void onUp(Host host)
+        {
+            events.add(new Event(Up, host));
+        }
+
+        public void onDown(Host host)
+        {
+            events.add(new Event(EventType.Down, host));
+        }
+
+        public void onRemove(Host host)
+        {
+            events.add(new Event(Remove, host));
+        }
+
+        public void onRegister(com.datastax.driver.core.Cluster cluster)
+        {
+        }
+
+        public void onUnregister(com.datastax.driver.core.Cluster cluster)
+        {
+        }
+    }
+
+    @Parameterized.Parameter(0)
+    public Strategy strategy;
+
+    @Parameterized.Parameters(name = "{index}: provision strategy={0}")
+    public static Collection<Strategy[]> data()
+    {
+        return Arrays.asList(new Strategy[][]{ { MultipleNetworkInterfaces },
+                                               { OneNetworkInterface }
+        });
+    }
+
+    @Test
+    public void testDecommission() throws Throwable
+    {
+        try (Cluster control = init(Cluster.build().withNodes(3).withNodeProvisionStrategy(strategy).withConfig(
+        config -> {
+            config.with(GOSSIP, NETWORK, NATIVE_PROTOCOL);
+        }).start()))
+        {
+            final com.datastax.driver.core.Cluster cluster = com.datastax.driver.core.Cluster.builder().addContactPoint("127.0.0.1").build();
+            Session session = cluster.connect();
+            EventStateListener eventStateListener = new EventStateListener();
+            session.getCluster().register(eventStateListener);
+            control.get(3).nodetool("disablebinary");
+            control.get(3).nodetool("decommission", "-f");
+            await().atMost(5, TimeUnit.SECONDS)
+                   .untilAsserted(() -> Assert.assertEquals(2, cluster.getMetadata().getAllHosts().size()));
+            assertThat(eventStateListener.events).containsExactly(new Event(Remove, control.get(3)));
+            session.close();
+            cluster.close();
+        }
+    }
+
+    @Test
+    public void testRestartNode() throws Throwable
+    {
+        try (Cluster control = init(Cluster.build().withNodes(3).withNodeProvisionStrategy(strategy).withConfig(
+        config -> {
+            config.with(GOSSIP, NETWORK, NATIVE_PROTOCOL);
+        }).start()))
+        {
+            final com.datastax.driver.core.Cluster cluster = com.datastax.driver.core.Cluster.builder().addContactPoint("127.0.0.1").build();
+            Session session = cluster.connect();
+            EventStateListener eventStateListener = new EventStateListener();
+            session.getCluster().register(eventStateListener);
+
+            control.get(3).shutdown().get();
+            await().atMost(5, TimeUnit.SECONDS)
+                   .untilAsserted(() -> Assert.assertEquals(2, cluster.getMetadata().getAllHosts().stream().filter(h -> h.isUp()).count()));
+
+            control.get(3).startup();
+            await().atMost(30, TimeUnit.SECONDS)
+                   .untilAsserted(() -> Assert.assertEquals(3, cluster.getMetadata().getAllHosts().stream().filter(h -> h.isUp()).count()));
+
+            assertThat(eventStateListener.events).containsExactly(new Event(Down, control.get(3)),
+                                                                  new Event(Up, control.get(3)));
+
+            session.close();
+            cluster.close();
+        }
+    }
+}
+
diff --git a/test/unit/org/apache/cassandra/auth/PasswordAuthenticatorTest.java b/test/unit/org/apache/cassandra/auth/PasswordAuthenticatorTest.java
index fd79b6a..5dd4ab5 100644
--- a/test/unit/org/apache/cassandra/auth/PasswordAuthenticatorTest.java
+++ b/test/unit/org/apache/cassandra/auth/PasswordAuthenticatorTest.java
@@ -26,6 +26,7 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import com.datastax.driver.core.Authenticator;
+import com.datastax.driver.core.EndPoint;
 import com.datastax.driver.core.PlainTextAuthProvider;
 import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.cql3.CQLTester;
@@ -121,7 +122,7 @@ public class PasswordAuthenticatorTest extends CQLTester
     {
         SaslNegotiator negotiator = authenticator.newSaslNegotiator(null);
         Authenticator clientAuthenticator = (new PlainTextAuthProvider(username, password))
-                                            .newAuthenticator(null, null);
+                                            .newAuthenticator((EndPoint) null, null);
 
         negotiator.evaluateResponse(clientAuthenticator.initialResponse());
         negotiator.getAuthenticatedUser();


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