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("")));
}
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));
}
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"));
}
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"));
}
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));
}
Aggregations