use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class NodeAgentImplTest method resumeProgramRunsUntilSuccess.
@Test
public void resumeProgramRunsUntilSuccess() {
final long restartGeneration = 1;
final ContainerNodeSpec nodeSpec = nodeSpecBuilder.wantedDockerImage(dockerImage).currentDockerImage(dockerImage).nodeState(Node.State.active).vespaVersion(vespaVersion).wantedRestartGeneration(restartGeneration).currentRestartGeneration(restartGeneration).build();
NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
when(nodeRepository.getContainerNodeSpec(eq(hostName))).thenReturn(Optional.of(nodeSpec));
when(storageMaintainer.getDiskUsageFor(eq(containerName))).thenReturn(Optional.of(201326592000L));
final InOrder inOrder = inOrder(orchestrator, dockerOperations, nodeRepository);
doThrow(new RuntimeException("Failed 1st time")).doNothing().when(dockerOperations).resumeNode(eq(containerName));
// 1st try
try {
nodeAgent.converge();
fail("Expected to throw an exception");
} catch (RuntimeException ignored) {
}
inOrder.verify(dockerOperations, times(1)).resumeNode(any());
inOrder.verifyNoMoreInteractions();
// 2nd try
nodeAgent.converge();
inOrder.verify(dockerOperations).resumeNode(any());
inOrder.verify(orchestrator).resume(hostName);
inOrder.verifyNoMoreInteractions();
}
use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class NodeAgentImplTest method inactiveNodeRunningContainerShouldStillBeRunning.
@Test
public void inactiveNodeRunningContainerShouldStillBeRunning() {
final long restartGeneration = 1;
final long rebootGeneration = 0;
final ContainerNodeSpec nodeSpec = nodeSpecBuilder.wantedDockerImage(dockerImage).currentDockerImage(dockerImage).nodeState(Node.State.inactive).wantedVespaVersion(vespaVersion).vespaVersion(vespaVersion).wantedRestartGeneration(restartGeneration).currentRestartGeneration(restartGeneration).wantedRebootGeneration(rebootGeneration).build();
NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(nodeSpec));
nodeAgent.converge();
final InOrder inOrder = inOrder(storageMaintainer, dockerOperations);
inOrder.verify(dockerOperations, never()).removeContainer(any(), any());
verify(orchestrator, never()).resume(any(String.class));
verify(nodeRepository, never()).updateNodeAttributes(eq(hostName), any());
}
use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class NodeAgentImplTest method noRestartIfOrchestratorSuspendFails.
@Test
public void noRestartIfOrchestratorSuspendFails() {
final long wantedRestartGeneration = 2;
final long currentRestartGeneration = 1;
final ContainerNodeSpec nodeSpec = nodeSpecBuilder.wantedDockerImage(dockerImage).currentDockerImage(dockerImage).nodeState(Node.State.active).wantedVespaVersion(vespaVersion).vespaVersion(vespaVersion).wantedRestartGeneration(wantedRestartGeneration).currentRestartGeneration(currentRestartGeneration).build();
NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
try {
nodeAgent.converge();
fail("Expected to throw an exception");
} catch (Exception ignored) {
}
verify(dockerOperations, never()).createContainer(eq(containerName), eq(nodeSpec));
verify(dockerOperations, never()).startContainer(eq(containerName), eq(nodeSpec));
verify(orchestrator, never()).resume(any(String.class));
verify(nodeRepository, never()).updateNodeAttributes(any(String.class), any(NodeAttributes.class));
}
use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class NodeAgentImplTest method reservedNodeDoesNotUpdateNodeRepoWithVersion.
@Test
public void reservedNodeDoesNotUpdateNodeRepoWithVersion() {
final long restartGeneration = 1;
final long rebootGeneration = 0;
final ContainerNodeSpec nodeSpec = nodeSpecBuilder.wantedDockerImage(dockerImage).nodeState(Node.State.reserved).wantedVespaVersion(vespaVersion).wantedRestartGeneration(restartGeneration).currentRestartGeneration(restartGeneration).wantedRebootGeneration(rebootGeneration).build();
NodeAgentImpl nodeAgent = makeNodeAgent(null, false);
when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(nodeSpec));
nodeAgent.converge();
verify(nodeRepository, never()).updateNodeAttributes(eq(hostName), any());
}
use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class NodeAgentImplTest method upToDateContainerIsUntouched.
@Test
public void upToDateContainerIsUntouched() {
final long restartGeneration = 1;
final long rebootGeneration = 0;
final ContainerNodeSpec nodeSpec = nodeSpecBuilder.wantedDockerImage(dockerImage).currentDockerImage(dockerImage).nodeState(Node.State.active).wantedVespaVersion(vespaVersion).vespaVersion(vespaVersion).wantedRestartGeneration(restartGeneration).currentRestartGeneration(restartGeneration).wantedRebootGeneration(rebootGeneration).build();
NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(nodeSpec));
when(storageMaintainer.getDiskUsageFor(eq(containerName))).thenReturn(Optional.of(187500000000L));
nodeAgent.converge();
verify(dockerOperations, never()).removeContainer(any(), any());
verify(orchestrator, never()).suspend(any(String.class));
verify(dockerOperations, never()).pullImageAsyncIfNeeded(any());
verify(storageMaintainer, never()).removeOldFilesFromNode(eq(containerName));
final InOrder inOrder = inOrder(dockerOperations, orchestrator, nodeRepository);
// TODO: Verify this isn't run unless 1st time
inOrder.verify(dockerOperations, times(1)).resumeNode(eq(containerName));
inOrder.verify(orchestrator).resume(hostName);
}
Aggregations