Search in sources :

Example 1 with ClusterMembershipSnapshot

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);
}
Also used : ClusterMembershipSnapshot(com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot) Test(org.junit.Test)

Example 2 with ClusterMembershipSnapshot

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");
}
Also used : ClusterMembershipSnapshot(com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot) Test(org.junit.Test)

Example 3 with ClusterMembershipSnapshot

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();
}
Also used : ClusterMembershipSnapshot(com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot) Test(org.junit.Test)

Example 4 with ClusterMembershipSnapshot

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);
}
Also used : ClusterMembershipSnapshot(com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot) Test(org.junit.Test)

Example 5 with ClusterMembershipSnapshot

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");
}
Also used : ClusterMembershipSnapshot(com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot) ClusterMember(com.netflix.titus.grpc.protogen.ClusterMember) Test(org.junit.Test)

Aggregations

ClusterMembershipSnapshot (com.netflix.titus.api.clustermembership.model.ClusterMembershipSnapshot)15 Test (org.junit.Test)12 Preconditions (com.google.common.base.Preconditions)2 Stopwatch (com.google.common.base.Stopwatch)2 ClusterMember (com.netflix.titus.api.clustermembership.model.ClusterMember)2 ClusterMemberAddress (com.netflix.titus.api.clustermembership.model.ClusterMemberAddress)2 ClusterMemberLeadership (com.netflix.titus.api.clustermembership.model.ClusterMemberLeadership)2 ClusterMembershipRevision (com.netflix.titus.api.clustermembership.model.ClusterMembershipRevision)2 ScheduleReference (com.netflix.titus.common.framework.scheduler.ScheduleReference)2 ScheduleDescriptor (com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor)2 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)2 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)2 Retryers (com.netflix.titus.common.util.retry.Retryers)2 ReactorExt (com.netflix.titus.common.util.rx.ReactorExt)2 Duration (java.time.Duration)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2