Upgrade to Atomix 3.0-rc5
* Upgrade Raft primitives to Atomix 3.0
* Replace cluster store and messaging implementations with Atomix cluster management/messaging
* Add test scripts for installing/starting Atomix cluster
* Replace core primitives with Atomix primitives.
Change-Id: I7623653c81292a34f21b01f5f38ca11b5ef15cad
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataDiffTest.java b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataDiffTest.java
deleted file mode 100644
index f97bd6a..0000000
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataDiffTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed 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.onosproject.cluster;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-import org.onosproject.core.Version;
-
-/**
- * Unit tests for ClusterMetadataDiff.
- */
-public class ClusterMetadataDiffTest {
-
- @Test
- public void testDiffNoChange() {
- PartitionId pid1 = PartitionId.from(1);
- NodeId nid1 = NodeId.nodeId("10.0.0.1");
- ControllerNode n1 = new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
- Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- ClusterMetadata md1 = new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
- ClusterMetadataDiff diff = new ClusterMetadataDiff(md1, md1);
- assertTrue(diff.nodesAdded().isEmpty());
- assertTrue(diff.nodesRemoved().isEmpty());
- assertEquals(diff.partitionDiffs().size(), 1);
- assertEquals(diff.partitionDiffs().keySet(), Sets.newHashSet(pid1));
- PartitionDiff pdiff = diff.partitionDiffs().get(pid1);
- assertFalse(pdiff.hasChanged());
- }
-
- @Test
- public void testDiffForScaleUp() {
- PartitionId pid1 = PartitionId.from(1);
- NodeId nid1 = NodeId.nodeId("10.0.0.1");
- NodeId nid2 = NodeId.nodeId("10.0.0.2");
- ControllerNode n1 = new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
- ControllerNode n2 = new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
- Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- Partition p12 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1, nid2));
- ClusterMetadata md1 = new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
- ClusterMetadata md12 = new ClusterMetadata("foo", ImmutableSet.of(n1, n2), ImmutableSet.of(p12));
- ClusterMetadataDiff diff = new ClusterMetadataDiff(md1, md12);
- assertEquals(diff.nodesAdded(), Sets.newHashSet(n2));
- assertTrue(diff.nodesRemoved().isEmpty());
- assertEquals(diff.partitionDiffs().size(), 1);
- assertEquals(diff.partitionDiffs().keySet(), Sets.newHashSet(pid1));
- PartitionDiff pdiff = diff.partitionDiffs().get(pid1);
- assertTrue(pdiff.hasChanged());
- assertFalse(pdiff.isAdded(nid1));
- assertTrue(pdiff.isAdded(nid2));
- assertFalse(pdiff.isRemoved(nid1));
- assertFalse(pdiff.isAdded(nid1));
- }
-
- @Test
- public void testDiffForScaleDown() {
- PartitionId pid1 = PartitionId.from(1);
- NodeId nid1 = NodeId.nodeId("10.0.0.1");
- NodeId nid2 = NodeId.nodeId("10.0.0.2");
- ControllerNode n1 = new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
- ControllerNode n2 = new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
- Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- Partition p12 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1, nid2));
- ClusterMetadata md1 = new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
- ClusterMetadata md12 = new ClusterMetadata("foo", ImmutableSet.of(n1, n2), ImmutableSet.of(p12));
- ClusterMetadataDiff diff = new ClusterMetadataDiff(md12, md1);
- assertEquals(diff.nodesRemoved(), Sets.newHashSet(nid2));
- assertTrue(diff.nodesAdded().isEmpty());
- assertEquals(diff.partitionDiffs().size(), 1);
- assertEquals(diff.partitionDiffs().keySet(), Sets.newHashSet(pid1));
- PartitionDiff pdiff = diff.partitionDiffs().get(pid1);
- assertTrue(pdiff.hasChanged());
- assertTrue(pdiff.isRemoved(nid2));
- assertFalse(pdiff.isAdded(nid2));
- assertFalse(pdiff.isRemoved(nid1));
- assertFalse(pdiff.isAdded(nid1));
- }
-}
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataEventTest.java b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataEventTest.java
index 036839a..b176aee 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataEventTest.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataEventTest.java
@@ -19,7 +19,6 @@
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import org.onlab.packet.IpAddress;
-import org.onosproject.core.Version;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@@ -38,15 +37,12 @@
new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
private final ControllerNode n2 =
new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
- private final Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- private final Partition p2 = new DefaultPartition(pid2, Version.version("1.0.0"), ImmutableSet.of(nid1, nid2));
- private final Partition p3 = new DefaultPartition(pid2, Version.version("1.0.0"), ImmutableSet.of(nid2));
private final ClusterMetadata metadata1 =
- new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
+ new ClusterMetadata("foo", n1, ImmutableSet.of(n1));
private final ClusterMetadata metadata2 =
- new ClusterMetadata("bar", ImmutableSet.of(n1, n2), ImmutableSet.of(p1, p2));
+ new ClusterMetadata("bar", n1, ImmutableSet.of(n1, n2));
private final ClusterMetadata metadata3 =
- new ClusterMetadata("baz", ImmutableSet.of(n2), ImmutableSet.of(p3));
+ new ClusterMetadata("baz", n1, ImmutableSet.of(n2));
private final ClusterMetadataEvent event1 =
new ClusterMetadataEvent(ClusterMetadataEvent.Type.METADATA_CHANGED, metadata1, time1);
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataServiceAdapter.java b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataServiceAdapter.java
index 443ee29..b1b46f9 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataServiceAdapter.java
@@ -15,10 +15,8 @@
*/
package org.onosproject.cluster;
-import org.onlab.packet.IpAddress;
-
import com.google.common.collect.Sets;
-import org.onosproject.core.Version;
+import org.onlab.packet.IpAddress;
/**
* Test adapter for the ClusterMetadata service.
@@ -29,10 +27,7 @@
public ClusterMetadata getClusterMetadata() {
final NodeId nid = new NodeId("test-node");
final IpAddress addr = IpAddress.valueOf(0);
- final Partition p = new DefaultPartition(PartitionId.from(1), Version.version("1.0.0"), Sets.newHashSet(nid));
- return new ClusterMetadata("test-cluster",
- Sets.newHashSet(new DefaultControllerNode(nid, addr)),
- Sets.newHashSet(p));
+ return new ClusterMetadata("test-cluster", new DefaultControllerNode(nid, addr), Sets.newHashSet());
}
@Override
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java
index 3d86d93..d6e2f33 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterMetadataTest.java
@@ -19,21 +19,17 @@
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import org.onlab.packet.IpAddress;
-import org.onosproject.core.Version;
import org.onosproject.net.provider.ProviderId;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
/**
* Unit tests for ClusterMetadata.
*/
public class ClusterMetadataTest {
- private final PartitionId pid1 = PartitionId.from(1);
- private final PartitionId pid2 = PartitionId.from(2);
-
private final NodeId nid1 = NodeId.nodeId("10.0.0.1");
private final NodeId nid2 = NodeId.nodeId("10.0.0.2");
@@ -42,15 +38,12 @@
private final ControllerNode n2 =
new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
- private final Partition p1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(nid1));
- private final Partition p2 = new DefaultPartition(pid2, Version.version("1.0.0"), ImmutableSet.of(nid1, nid2));
-
private final ClusterMetadata metadata1 =
- new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
+ new ClusterMetadata("foo", n1, ImmutableSet.of(n1));
private final ClusterMetadata sameAsMetadata1 =
- new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
+ new ClusterMetadata("foo", n1, ImmutableSet.of(n1));
private final ClusterMetadata metadata2 =
- new ClusterMetadata("bar", ImmutableSet.of(n1, n2), ImmutableSet.of(p1, p2));
+ new ClusterMetadata("bar", n1, ImmutableSet.of(n1, n2));
private final ProviderId defaultProvider =
new ProviderId("none", "none");
/**
@@ -73,9 +66,6 @@
assertThat(metadata2.getName(), is("bar"));
assertThat(metadata2.getNodes(), hasSize(2));
assertThat(metadata2.getNodes(), contains(n1, n2));
- assertThat(metadata2.getPartitions(), hasSize(2));
- assertThat(metadata2.getPartitions(), contains(p1, p2));
assertThat(metadata1.providerId(), is(defaultProvider));
-
}
}
diff --git a/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java b/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
index bc40f67..b486132 100644
--- a/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/cluster/ClusterServiceAdapter.java
@@ -46,6 +46,11 @@
}
@Override
+ public Set<Node> getConsensusNodes() {
+ return null;
+ }
+
+ @Override
public ControllerNode.State getState(NodeId nodeId) {
return null;
}
diff --git a/core/api/src/test/java/org/onosproject/cluster/DefaultPartitionTest.java b/core/api/src/test/java/org/onosproject/cluster/DefaultPartitionTest.java
index 105c94e..292c9a2 100644
--- a/core/api/src/test/java/org/onosproject/cluster/DefaultPartitionTest.java
+++ b/core/api/src/test/java/org/onosproject/cluster/DefaultPartitionTest.java
@@ -17,11 +17,9 @@
import java.util.Collection;
-import org.junit.Test;
-
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.EqualsTester;
-import org.onosproject.core.Version;
+import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
@@ -44,13 +42,13 @@
PartitionId pid2 = new PartitionId(2);
PartitionId pid3 = new PartitionId(3);
- DefaultPartition partition1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(id1));
- DefaultPartition sameAsPartition1 = new DefaultPartition(pid1, Version.version("1.0.0"), ImmutableSet.of(id1));
+ DefaultPartition partition1 = new DefaultPartition(pid1, ImmutableSet.of(id1));
+ DefaultPartition sameAsPartition1 = new DefaultPartition(pid1, ImmutableSet.of(id1));
- DefaultPartition partition2 = new DefaultPartition(pid2, Version.version("1.0.0"), ImmutableSet.of(id2));
+ DefaultPartition partition2 = new DefaultPartition(pid2, ImmutableSet.of(id2));
DefaultPartition copyOfPartition2 = new DefaultPartition(partition2);
- DefaultPartition partition3 = new DefaultPartition(pid3, Version.version("1.0.0"), ImmutableSet.of(id1, id2, id3));
+ DefaultPartition partition3 = new DefaultPartition(pid3, ImmutableSet.of(id1, id2, id3));
/**
* Checks that the default partition implementation is an immutable