Search in sources :

Example 6 with DockerImage

use of com.yahoo.vespa.hosted.dockerapi.DockerImage in project vespa by vespa-engine.

the class NodeAgentImplTest method nodeRunningContainerIsTakenDownAndCleanedAndRecycled.

private void nodeRunningContainerIsTakenDownAndCleanedAndRecycled(Node.State nodeState, Optional<Long> wantedRestartGeneration) {
    wantedRestartGeneration.ifPresent(restartGeneration -> nodeSpecBuilder.wantedRestartGeneration(restartGeneration).currentRestartGeneration(restartGeneration));
    final ContainerNodeSpec nodeSpec = nodeSpecBuilder.wantedDockerImage(dockerImage).currentDockerImage(dockerImage).nodeState(nodeState).build();
    NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
    when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(nodeSpec));
    nodeAgent.converge();
    final InOrder inOrder = inOrder(storageMaintainer, dockerOperations, nodeRepository);
    inOrder.verify(dockerOperations, times(1)).removeContainer(any(), any());
    inOrder.verify(storageMaintainer, times(1)).cleanupNodeStorage(eq(containerName), eq(nodeSpec));
    inOrder.verify(nodeRepository, times(1)).markNodeAvailableForNewAllocation(eq(hostName));
    verify(dockerOperations, never()).createContainer(eq(containerName), any());
    verify(dockerOperations, never()).startContainer(eq(containerName), any());
    verify(orchestrator, never()).resume(any(String.class));
    verify(orchestrator, never()).suspend(any(String.class));
    // current Docker image and vespa version should be cleared
    verify(nodeRepository, times(1)).updateNodeAttributes(any(String.class), eq(new NodeAttributes().withRestartGeneration(wantedRestartGeneration.orElse(null)).withRebootGeneration(0L).withDockerImage(new DockerImage("")).withVespaVersion("")));
}
Also used : InOrder(org.mockito.InOrder) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec)

Example 7 with DockerImage

use of com.yahoo.vespa.hosted.dockerapi.DockerImage in project vespa by vespa-engine.

the class NodeAgentImplTest method containerIsNotStoppedIfNewImageMustBePulled.

@Test
public void containerIsNotStoppedIfNewImageMustBePulled() {
    final DockerImage newDockerImage = new DockerImage("new-image");
    final long wantedRestartGeneration = 2;
    final long currentRestartGeneration = 1;
    final ContainerNodeSpec nodeSpec = nodeSpecBuilder.wantedDockerImage(newDockerImage).currentDockerImage(dockerImage).nodeState(Node.State.active).wantedVespaVersion(vespaVersion).vespaVersion(vespaVersion).wantedRestartGeneration(wantedRestartGeneration).currentRestartGeneration(currentRestartGeneration).build();
    NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
    when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(nodeSpec));
    when(dockerOperations.pullImageAsyncIfNeeded(any())).thenReturn(true);
    when(storageMaintainer.getDiskUsageFor(eq(containerName))).thenReturn(Optional.of(201326592000L));
    nodeAgent.converge();
    verify(orchestrator, never()).suspend(any(String.class));
    verify(orchestrator, never()).resume(any(String.class));
    verify(dockerOperations, never()).removeContainer(any(), any());
    final InOrder inOrder = inOrder(dockerOperations);
    inOrder.verify(dockerOperations, times(1)).pullImageAsyncIfNeeded(eq(newDockerImage));
}
Also used : InOrder(org.mockito.InOrder) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) Test(org.junit.Test)

Example 8 with DockerImage

use of com.yahoo.vespa.hosted.dockerapi.DockerImage in project vespa by vespa-engine.

the class RealNodeRepositoryTest method testUpdateNodeAttributes.

@Test
public void testUpdateNodeAttributes() throws InterruptedException, IOException {
    waitForJdiscContainerToServe();
    NodeRepository nodeRepositoryApi = new RealNodeRepository(configServerApi);
    String hostname = "host4.yahoo.com";
    nodeRepositoryApi.updateNodeAttributes(hostname, new NodeAttributes().withRestartGeneration(1L).withDockerImage(new DockerImage("image-1:6.2.3")).withVespaVersion("6.2.3"));
}
Also used : NodeAttributes(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAttributes) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage) Test(org.junit.Test)

Example 9 with DockerImage

use of com.yahoo.vespa.hosted.dockerapi.DockerImage in project vespa by vespa-engine.

the class RealNodeRepositoryTest method testUpdateNodeAttributesWithBadValue.

@Test(expected = RuntimeException.class)
public void testUpdateNodeAttributesWithBadValue() throws InterruptedException, IOException {
    waitForJdiscContainerToServe();
    NodeRepository nodeRepositoryApi = new RealNodeRepository(configServerApi);
    String hostname = "host4.yahoo.com";
    nodeRepositoryApi.updateNodeAttributes(hostname, new NodeAttributes().withRestartGeneration(1L).withDockerImage(new DockerImage("image-1")).withVespaVersion("6.2.3\n"));
}
Also used : NodeAttributes(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAttributes) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage) Test(org.junit.Test)

Example 10 with DockerImage

use of com.yahoo.vespa.hosted.dockerapi.DockerImage in project vespa by vespa-engine.

the class RealNodeRepositoryTest method testGetContainersToRunApi.

@Test
public void testGetContainersToRunApi() throws InterruptedException {
    waitForJdiscContainerToServe();
    NodeRepository nodeRepositoryApi = new RealNodeRepository(configServerApi);
    String dockerHostHostname = "dockerhost1.yahoo.com";
    final List<ContainerNodeSpec> containersToRun = nodeRepositoryApi.getContainersToRun(dockerHostHostname);
    assertThat(containersToRun.size(), is(1));
    final ContainerNodeSpec nodeSpec = containersToRun.get(0);
    assertThat(nodeSpec.hostname, is("host4.yahoo.com"));
    assertThat(nodeSpec.wantedDockerImage.get(), is(new DockerImage("docker-registry.domain.tld:8080/dist/vespa:6.42.0")));
    assertThat(nodeSpec.nodeState, is(Node.State.active));
    assertThat(nodeSpec.wantedRestartGeneration.get(), is(0L));
    assertThat(nodeSpec.currentRestartGeneration.get(), is(0L));
    assertThat(nodeSpec.minCpuCores, is(0.2));
    assertThat(nodeSpec.minMainMemoryAvailableGb, is(0.5));
    assertThat(nodeSpec.minDiskAvailableGb, is(100.0));
}
Also used : DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) Test(org.junit.Test)

Aggregations

DockerImage (com.yahoo.vespa.hosted.dockerapi.DockerImage)12 Test (org.junit.Test)8 ContainerNodeSpec (com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec)7 ContainerName (com.yahoo.vespa.hosted.dockerapi.ContainerName)6 Container (com.yahoo.vespa.hosted.dockerapi.Container)3 OrchestratorException (com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorException)2 NodeAttributes (com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAttributes)2 Node (com.yahoo.vespa.hosted.provision.Node)2 InOrder (org.mockito.InOrder)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ThreadFactoryFactory (com.yahoo.concurrent.ThreadFactoryFactory)1 NodeType (com.yahoo.config.provision.NodeType)1 ContainerResources (com.yahoo.vespa.hosted.dockerapi.ContainerResources)1 Docker (com.yahoo.vespa.hosted.dockerapi.Docker)1 DockerException (com.yahoo.vespa.hosted.dockerapi.DockerException)1 DockerExecTimeoutException (com.yahoo.vespa.hosted.dockerapi.DockerExecTimeoutException)1 ProcessResult (com.yahoo.vespa.hosted.dockerapi.ProcessResult)1 DimensionMetrics (com.yahoo.vespa.hosted.dockerapi.metrics.DimensionMetrics)1 Dimensions (com.yahoo.vespa.hosted.dockerapi.metrics.Dimensions)1 MetricReceiverWrapper (com.yahoo.vespa.hosted.dockerapi.metrics.MetricReceiverWrapper)1