Search in sources :

Example 1 with ClusterMembershipChangeEvent

use of com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent in project titus-control-plane by Netflix.

the class KubeClusterMembershipConnectorTest method doAddOrUpdateSibling.

private ClusterMembershipRevision<ClusterMember> doAddOrUpdateSibling(ClusterMembershipRevision<ClusterMember> revision, ClusterMembershipChangeEvent.ChangeType changeType) throws InterruptedException {
    String siblingId = revision.getCurrent().getMemberId();
    kubeExecutors.addOrUpdateSibling(revision);
    ClusterMembershipEvent event = connectorEvents.takeNext(TIMEOUT);
    assertThat(event).isInstanceOf(ClusterMembershipChangeEvent.class);
    assertThat(((ClusterMembershipChangeEvent) event).getChangeType()).isEqualTo(changeType);
    assertThat(((ClusterMembershipChangeEvent) event).getRevision()).isEqualTo(revision);
    assertThat(connector.getClusterMemberSiblings()).containsKey(siblingId);
    return connector.getClusterMemberSiblings().get(siblingId);
}
Also used : ClusterMembershipChangeEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent) ClusterMembershipEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)

Example 2 with ClusterMembershipChangeEvent

use of com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent in project titus-control-plane by Netflix.

the class KubeClusterMembershipConnectorTest method testRegistrationConnectionErrorRecoveryInReconciler.

@Test
public void testRegistrationConnectionErrorRecoveryInReconciler() throws InterruptedException {
    doRegister();
    kubeExecutors.failOnMembershipUpdate(new RuntimeException("Simulated membership update error"), 1);
    await().until(() -> !kubeExecutors.isFailingOnMembershipUpdate());
    long now = System.currentTimeMillis();
    ClusterMembershipChangeEvent event;
    while ((event = (ClusterMembershipChangeEvent) connectorEvents.takeNext(TIMEOUT)) != null) {
        if (event.getRevision().getTimestamp() > now) {
            return;
        }
    }
    fail("No re-registration observed in time");
}
Also used : ClusterMembershipChangeEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent) Test(org.junit.Test)

Example 3 with ClusterMembershipChangeEvent

use of com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent in project titus-control-plane by Netflix.

the class KubeClusterMembershipConnectorTest method doRemoveSibling.

private void doRemoveSibling(ClusterMembershipRevision<ClusterMember> revision) throws InterruptedException {
    kubeExecutors.removeSibling(revision.getCurrent().getMemberId());
    ClusterMembershipEvent event = connectorEvents.takeNext(TIMEOUT);
    assertThat(event).isInstanceOf(ClusterMembershipChangeEvent.class);
    assertThat(((ClusterMembershipChangeEvent) event).getChangeType()).isEqualTo(ClusterMembershipChangeEvent.ChangeType.Removed);
}
Also used : ClusterMembershipChangeEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent) ClusterMembershipEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)

Example 4 with ClusterMembershipChangeEvent

use of com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent in project titus-control-plane by Netflix.

the class DefaultClusterMembershipServiceTest method expectLocalLeadershipTransition.

private void expectLocalLeadershipTransition(ClusterMemberLeadershipState state, boolean active) throws InterruptedException {
    expectLocalLeadershipTransition(state);
    ClusterMembershipChangeEvent membershipChangeEvent = (ClusterMembershipChangeEvent) eventSubscriber.takeNext(TIMEOUT);
    assertThat(membershipChangeEvent).isNotNull();
    assertThat(membershipChangeEvent.getRevision().getCurrent().isActive()).isEqualTo(active);
}
Also used : ClusterMembershipChangeEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent)

Example 5 with ClusterMembershipChangeEvent

use of com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent in project titus-control-plane by Netflix.

the class AbstractKubeMembershipExecutorTest method findNextMemberEvent.

private ClusterMembershipChangeEvent findNextMemberEvent(String memberId) throws InterruptedException {
    while (true) {
        ClusterMembershipEvent event = eventSubscriber.takeNext(KUBE_TIMEOUT);
        assertThat(event).isNotNull();
        if (event instanceof ClusterMembershipChangeEvent) {
            ClusterMembershipChangeEvent memberEvent = (ClusterMembershipChangeEvent) event;
            if (memberEvent.getRevision().getCurrent().getMemberId().equals(memberId)) {
                return memberEvent;
            }
        }
    }
}
Also used : ClusterMembershipChangeEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent) ClusterMembershipEvent(com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)

Aggregations

ClusterMembershipChangeEvent (com.netflix.titus.api.clustermembership.model.event.ClusterMembershipChangeEvent)7 ClusterMembershipEvent (com.netflix.titus.api.clustermembership.model.event.ClusterMembershipEvent)4 ClusterMember (com.netflix.titus.api.clustermembership.model.ClusterMember)1 ClusterMemberGenerator.activeClusterMember (com.netflix.titus.testkit.model.clustermembership.ClusterMemberGenerator.activeClusterMember)1 Test (org.junit.Test)1