use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.
the class ClusterAdminRpcServiceTest method testRemoveShardReplica.
@Test
public void testRemoveShardReplica() throws Exception {
String name = "testRemoveShardReplica";
String moduleShardsConfig = "module-shards-member1-and-2-and-3.conf";
final MemberNode leaderNode1 = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name).moduleShardsConfig(moduleShardsConfig).datastoreContextBuilder(DatastoreContext.newBuilder().shardHeartbeatIntervalInMillis(300).shardElectionTimeoutFactor(1)).build();
final MemberNode replicaNode2 = MemberNode.builder(memberNodes).akkaConfig("Member2").testName(name).moduleShardsConfig(moduleShardsConfig).build();
final MemberNode replicaNode3 = MemberNode.builder(memberNodes).akkaConfig("Member3").testName(name).moduleShardsConfig(moduleShardsConfig).build();
leaderNode1.configDataStore().waitTillReady();
replicaNode3.configDataStore().waitTillReady();
verifyRaftPeersPresent(leaderNode1.configDataStore(), "cars", "member-2", "member-3");
verifyRaftPeersPresent(replicaNode2.configDataStore(), "cars", "member-1", "member-3");
verifyRaftPeersPresent(replicaNode3.configDataStore(), "cars", "member-1", "member-2");
// Invoke RPC service on member-3 to remove it's local shard
ClusterAdminRpcService service3 = new ClusterAdminRpcService(replicaNode3.configDataStore(), replicaNode3.operDataStore(), null);
RpcResult<Void> rpcResult = service3.removeShardReplica(new RemoveShardReplicaInputBuilder().setShardName("cars").setMemberName("member-3").setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
verifySuccessfulRpcResult(rpcResult);
verifyRaftPeersPresent(leaderNode1.configDataStore(), "cars", "member-2");
verifyRaftPeersPresent(replicaNode2.configDataStore(), "cars", "member-1");
verifyNoShardPresent(replicaNode3.configDataStore(), "cars");
// Restart member-2 and verify member-3 isn't present.
Cluster.get(leaderNode1.kit().getSystem()).down(Cluster.get(replicaNode2.kit().getSystem()).selfAddress());
replicaNode2.cleanup();
MemberNode newPeplicaNode2 = MemberNode.builder(memberNodes).akkaConfig("Member2").testName(name).moduleShardsConfig(moduleShardsConfig).build();
newPeplicaNode2.configDataStore().waitTillReady();
verifyRaftPeersPresent(newPeplicaNode2.configDataStore(), "cars", "member-1");
// Invoke RPC service on member-1 to remove member-2
ClusterAdminRpcService service1 = new ClusterAdminRpcService(leaderNode1.configDataStore(), leaderNode1.operDataStore(), null);
rpcResult = service1.removeShardReplica(new RemoveShardReplicaInputBuilder().setShardName("cars").setMemberName("member-2").setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
verifySuccessfulRpcResult(rpcResult);
verifyRaftPeersPresent(leaderNode1.configDataStore(), "cars");
verifyNoShardPresent(newPeplicaNode2.configDataStore(), "cars");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.
the class ClusterAdminRpcServiceTest method testAddReplicasForAllShards.
@Test
public void testAddReplicasForAllShards() throws Exception {
String name = "testAddReplicasForAllShards";
String moduleShardsConfig = "module-shards-member1.conf";
MemberNode leaderNode1 = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name).moduleShardsConfig(moduleShardsConfig).waitForShardLeader("cars", "people").build();
ModuleShardConfiguration petsModuleConfig = new ModuleShardConfiguration(URI.create("pets-ns"), "pets-module", "pets", null, Collections.singletonList(MEMBER_1));
leaderNode1.configDataStore().getActorContext().getShardManager().tell(new CreateShard(petsModuleConfig, Shard.builder(), null), leaderNode1.kit().getRef());
leaderNode1.kit().expectMsgClass(Success.class);
leaderNode1.kit().waitUntilLeader(leaderNode1.configDataStore().getActorContext(), "pets");
MemberNode newReplicaNode2 = MemberNode.builder(memberNodes).akkaConfig("Member2").testName(name).moduleShardsConfig(moduleShardsConfig).build();
leaderNode1.waitForMembersUp("member-2");
newReplicaNode2.waitForMembersUp("member-1");
newReplicaNode2.configDataStore().getActorContext().getShardManager().tell(new CreateShard(petsModuleConfig, Shard.builder(), null), newReplicaNode2.kit().getRef());
newReplicaNode2.kit().expectMsgClass(Success.class);
newReplicaNode2.operDataStore().getActorContext().getShardManager().tell(new CreateShard(new ModuleShardConfiguration(URI.create("no-leader-ns"), "no-leader-module", "no-leader", null, Collections.singletonList(MEMBER_1)), Shard.builder(), null), newReplicaNode2.kit().getRef());
newReplicaNode2.kit().expectMsgClass(Success.class);
ClusterAdminRpcService service = new ClusterAdminRpcService(newReplicaNode2.configDataStore(), newReplicaNode2.operDataStore(), null);
RpcResult<AddReplicasForAllShardsOutput> rpcResult = service.addReplicasForAllShards().get(10, TimeUnit.SECONDS);
AddReplicasForAllShardsOutput result = verifySuccessfulRpcResult(rpcResult);
verifyShardResults(result.getShardResult(), successShardResult("cars", DataStoreType.Config), successShardResult("people", DataStoreType.Config), successShardResult("pets", DataStoreType.Config), successShardResult("cars", DataStoreType.Operational), successShardResult("people", DataStoreType.Operational), failedShardResult("no-leader", DataStoreType.Operational));
verifyRaftPeersPresent(newReplicaNode2.configDataStore(), "cars", "member-1");
verifyRaftPeersPresent(newReplicaNode2.configDataStore(), "people", "member-1");
verifyRaftPeersPresent(newReplicaNode2.configDataStore(), "pets", "member-1");
verifyRaftPeersPresent(newReplicaNode2.operDataStore(), "cars", "member-1");
verifyRaftPeersPresent(newReplicaNode2.operDataStore(), "people", "member-1");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.
the class ClusterAdminRpcServiceTest method testChangeMemberVotingStatesForSingleNodeShard.
@Test
public void testChangeMemberVotingStatesForSingleNodeShard() throws Exception {
String name = "testChangeMemberVotingStatesForSingleNodeShard";
String moduleShardsConfig = "module-shards-member1.conf";
MemberNode leaderNode = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name).moduleShardsConfig(moduleShardsConfig).datastoreContextBuilder(DatastoreContext.newBuilder().shardHeartbeatIntervalInMillis(300).shardElectionTimeoutFactor(1)).build();
leaderNode.configDataStore().waitTillReady();
// Invoke RPC service on member-3 to change voting status
ClusterAdminRpcService service = new ClusterAdminRpcService(leaderNode.configDataStore(), leaderNode.operDataStore(), null);
RpcResult<Void> rpcResult = service.changeMemberVotingStatesForShard(new ChangeMemberVotingStatesForShardInputBuilder().setShardName("cars").setDataStoreType(DataStoreType.Config).setMemberVotingState(ImmutableList.of(new MemberVotingStateBuilder().setMemberName("member-1").setVoting(FALSE).build())).build()).get(10, TimeUnit.SECONDS);
verifyFailedRpcResult(rpcResult);
verifyVotingStates(leaderNode.configDataStore(), "cars", new SimpleEntry<>("member-1", TRUE));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.
the class ClusterAdminRpcServiceTest method addPrefixShardReplica.
private void addPrefixShardReplica(final MemberNode memberNode, final InstanceIdentifier<?> identifier, final BindingNormalizedNodeSerializer serializer, final String shardName, final String... peerMemberNames) throws Exception {
final AddPrefixShardReplicaInput input = new AddPrefixShardReplicaInputBuilder().setShardPrefix(identifier).setDataStoreType(DataStoreType.Config).build();
final ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(), memberNode.operDataStore(), serializer);
final RpcResult<Void> rpcResult = service.addPrefixShardReplica(input).get(10, TimeUnit.SECONDS);
verifySuccessfulRpcResult(rpcResult);
verifyRaftPeersPresent(memberNode.configDataStore(), shardName, peerMemberNames);
Optional<ActorRef> optional = memberNode.configDataStore().getActorContext().findLocalShard(shardName);
assertTrue("Replica shard not present", optional.isPresent());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project controller by opendaylight.
the class ClusterAdminRpcServiceTest method testAddShardReplicaFailures.
@Test
public void testAddShardReplicaFailures() throws Exception {
String name = "testAddShardReplicaFailures";
MemberNode memberNode = MemberNode.builder(memberNodes).akkaConfig("Member1").testName(name).moduleShardsConfig("module-shards-cars-member-1.conf").build();
ClusterAdminRpcService service = new ClusterAdminRpcService(memberNode.configDataStore(), memberNode.operDataStore(), null);
RpcResult<Void> rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder().setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
verifyFailedRpcResult(rpcResult);
rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder().setShardName("cars").build()).get(10, TimeUnit.SECONDS);
verifyFailedRpcResult(rpcResult);
rpcResult = service.addShardReplica(new AddShardReplicaInputBuilder().setShardName("people").setDataStoreType(DataStoreType.Config).build()).get(10, TimeUnit.SECONDS);
verifyFailedRpcResult(rpcResult);
}
Aggregations