use of com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot in project titus-control-plane by Netflix.
the class MultiNodeClusterMemberResolverTest method testNewMemberDiscovery.
@Test(timeout = 30_000)
public void testNewMemberDiscovery() {
Iterator<ClusterMembershipSnapshot> eventIterator = resolver.resolve().toIterable().iterator();
eventIterator.next();
memberResolver1.addMembers(MEMBER_3);
await().until(() -> resolver.getSnapshot().getMemberRevisions().size() == 3);
ClusterMembershipSnapshot nextEvent = eventIterator.next();
assertThat(nextEvent.getMemberRevisions()).hasSize(3);
}
use of com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot in project titus-control-plane by Netflix.
the class MultiNodeClusterMemberResolverTest method testInitialState.
@Test(timeout = 30_000)
public void testInitialState() {
await().until(() -> resolver.getSnapshot().getMemberRevisions().size() == 2);
ClusterMembershipSnapshot snapshot = resolver.resolve().blockFirst(TIMEOUT);
assertThat(snapshot).isNotNull();
assertThat(snapshot.getMemberRevisions()).hasSize(2);
assertThat(snapshot.getLeaderRevision()).isEmpty();
assertThat(snapshot.getMemberRevisions().keySet()).contains("member1", "member2");
}
use of com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot in project titus-control-plane by Netflix.
the class SingleClusterMemberResolverTest method testLeaderElection.
@Test(timeout = 30_000)
public void testLeaderElection() {
Iterator<ClusterMembershipSnapshot> eventIt = subscribeAndDiscardFirstSnapshot();
// Elect a leader
serviceStub.addMember(MEMBER_2.toBuilder().setCurrent(MEMBER_2.getCurrent().toBuilder().setLeadershipState(ClusterMember.LeadershipState.Leader)).build());
ClusterMembershipSnapshot leadElectedEvent = eventIt.next();
assertThat(leadElectedEvent.getLeaderRevision()).isNotEmpty();
// Loose the leader.
serviceStub.removeMember(MEMBER_2);
ClusterMembershipSnapshot leaderLostEvent = eventIt.next();
assertThat(leaderLostEvent.getLeaderRevision()).isEmpty();
}
use of com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot in project titus-control-plane by Netflix.
the class SingleClusterMemberResolverTest method testBrokenConnection.
@Test(timeout = 30_000)
public void testBrokenConnection() {
Iterator<ClusterMembershipSnapshot> eventIt = subscribeAndDiscardFirstSnapshot();
serviceStub.breakConnection();
ClusterMembershipSnapshot newSnapshot = eventIt.next();
assertThat(newSnapshot).isNotNull();
assertThat(newSnapshot.getMemberRevisions()).hasSize(3);
}
use of com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot in project titus-control-plane by Netflix.
the class SingleClusterMemberResolverTest method testMemberUpdate.
@Test(timeout = 30_000)
public void testMemberUpdate() {
Iterator<ClusterMembershipSnapshot> eventIt = subscribeAndDiscardFirstSnapshot();
serviceStub.addMember(MEMBER_1.toBuilder().setMessage("Update").build());
ClusterMembershipSnapshot update = eventIt.next();
com.netflix.titus.api.clustermembership.model.ClusterMembershipRevision<com.netflix.titus.api.clustermembership.model.ClusterMember> updated = update.getMemberRevisions().get(MEMBER_1.getCurrent().getMemberId());
assertThat(updated.getMessage()).isEqualTo("Update");
}
Aggregations