use of com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method canReEnableSingleNamespace.
@Test
public void canReEnableSingleNamespace() {
ReenableNamespacesRequest request = ReenableNamespacesRequest.of(ImmutableSet.of(NAMESPACE), LOCK_ID);
when(remote1.reenable(AUTH_HEADER, request)).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
when(remote2.reenable(AUTH_HEADER, request)).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
when(localUpdater.reEnable(request)).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
ReenableNamespacesResponse response = updater.reEnableOnAllNodes(AUTH_HEADER, request);
assertThat(response).isEqualTo(REENABLED_SUCCESSFULLY);
}
use of com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method reEnableCanPartiallyFail.
// Case A: Start with one disabled namespace, re-enable fails on some node, we should re-disable
@Test
public void reEnableCanPartiallyFail() {
ImmutableSet<Namespace> oneNamespace = ImmutableSet.of(NAMESPACE);
ReenableNamespacesRequest request = ReenableNamespacesRequest.of(oneNamespace, LOCK_ID);
when(remote1.reenable(AUTH_HEADER, request)).thenReturn(SingleNodeUpdateResponse.successful());
when(remote2.reenable(AUTH_HEADER, request)).thenReturn(singleNodeUpdateFailure(oneNamespace));
when(localUpdater.reEnable(request)).thenReturn(SingleNodeUpdateResponse.successful());
ReenableNamespacesResponse response = updater.reEnableOnAllNodes(AUTH_HEADER, request);
assertThat(response).isEqualTo(partiallyLocked(oneNamespace));
// verify we still unlocked locally
verify(localUpdater).reEnable(request);
}
use of com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method reEnableDoesNotReportConsistentStateWhenNamespacesAreLockedWithDifferentIds.
@Test
public void reEnableDoesNotReportConsistentStateWhenNamespacesAreLockedWithDifferentIds() {
Set<Namespace> namespaces = ImmutableSet.of(NAMESPACE);
String otherLockId = "otherLockId";
String yetAnotherLockId = "yetAnotherLockId";
SingleNodeUpdateResponse lockedWithOtherLock = ImmutableSingleNodeUpdateResponse.builder().isSuccessful(false).putLockedNamespaces(NAMESPACE, otherLockId).build();
SingleNodeUpdateResponse lockedWithYetAnotherLock = ImmutableSingleNodeUpdateResponse.builder().isSuccessful(false).putLockedNamespaces(NAMESPACE, yetAnotherLockId).build();
when(remote1.reenable(any(), any())).thenReturn(lockedWithOtherLock);
when(remote2.reenable(any(), any())).thenReturn(SingleNodeUpdateResponse.successful());
when(localUpdater.reEnable(any())).thenReturn(lockedWithYetAnotherLock);
ReenableNamespacesResponse reenableResponse = updater.reEnableOnAllNodes(AUTH_HEADER, ReenableNamespacesRequest.of(namespaces, LOCK_ID));
assertThat(reenableResponse).isEqualTo(partiallyLocked(namespaces));
verify(remote1, never()).disable(any(), any());
verify(remote2, never()).disable(any(), any());
}
use of com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method doesNotReEnableIfSomeNamespaceDisabledWithOtherLock.
// Case B: re-enable with wrong lock -> don't re-enable anywhere
@Test
public void doesNotReEnableIfSomeNamespaceDisabledWithOtherLock() {
Set<Namespace> disabledNamespaces = ImmutableSet.of(OTHER_NAMESPACE);
SingleNodeUpdateResponse unsuccessfulResponse = singleNodeUpdateFailure(disabledNamespaces);
when(remote1.reenable(any(), any())).thenReturn(unsuccessfulResponse);
when(remote2.reenable(any(), any())).thenReturn(unsuccessfulResponse);
when(localUpdater.reEnable(any())).thenReturn(unsuccessfulResponse);
ReenableNamespacesResponse response = updater.reEnableOnAllNodes(AUTH_HEADER, ReenableNamespacesRequest.of(BOTH_NAMESPACES, LOCK_ID));
assertThat(response).isEqualTo(consistentlyLocked(disabledNamespaces));
}
use of com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method handlesNodesBecomingUnreachableDuringReEnable.
@Test
public void handlesNodesBecomingUnreachableDuringReEnable() {
when(remote1.reenable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
when(remote2.reenable(any(), any())).thenThrow(new SafeRuntimeException("unreachable"));
when(localUpdater.reEnable(any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
ReenableNamespacesRequest request = ReenableNamespacesRequest.of(BOTH_NAMESPACES, LOCK_ID);
ReenableNamespacesResponse response = updater.reEnableOnAllNodes(AUTH_HEADER, request);
assertThat(response).isEqualTo(partiallyLocked(ImmutableSet.of()));
}
Aggregations