Search in sources :

Example 6 with ContainerNodeSpec

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();
}
Also used : InOrder(org.mockito.InOrder) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) Test(org.junit.Test)

Example 7 with ContainerNodeSpec

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());
}
Also used : InOrder(org.mockito.InOrder) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) Test(org.junit.Test)

Example 8 with ContainerNodeSpec

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));
}
Also used : ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) DockerException(com.yahoo.vespa.hosted.dockerapi.DockerException) IOException(java.io.IOException) Test(org.junit.Test)

Example 9 with ContainerNodeSpec

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());
}
Also used : ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) Test(org.junit.Test)

Example 10 with ContainerNodeSpec

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);
}
Also used : InOrder(org.mockito.InOrder) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) Test(org.junit.Test)

Aggregations

ContainerNodeSpec (com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec)30 Test (org.junit.Test)22 InOrder (org.mockito.InOrder)8 ContainerName (com.yahoo.vespa.hosted.dockerapi.ContainerName)7 DockerImage (com.yahoo.vespa.hosted.dockerapi.DockerImage)7 Docker (com.yahoo.vespa.hosted.dockerapi.Docker)4 DockerException (com.yahoo.vespa.hosted.dockerapi.DockerException)4 ArrayList (java.util.ArrayList)4 DimensionMetrics (com.yahoo.vespa.hosted.dockerapi.metrics.DimensionMetrics)3 Dimensions (com.yahoo.vespa.hosted.dockerapi.metrics.Dimensions)3 Node (com.yahoo.vespa.hosted.provision.Node)3 IOException (java.io.IOException)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ThreadFactoryFactory (com.yahoo.concurrent.ThreadFactoryFactory)2 NodeType (com.yahoo.config.provision.NodeType)2 Container (com.yahoo.vespa.hosted.dockerapi.Container)2 ContainerResources (com.yahoo.vespa.hosted.dockerapi.ContainerResources)2 DockerExecTimeoutException (com.yahoo.vespa.hosted.dockerapi.DockerExecTimeoutException)2