Search in sources :

Example 16 with ContainerNodeSpec

use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.

the class FilebeatConfigProviderTest method it_does_not_generate_config_for_nodes_wihout_owner.

@Test
public void it_does_not_generate_config_for_nodes_wihout_owner() {
    FilebeatConfigProvider filebeatConfigProvider = new FilebeatConfigProvider(getEnvironment(logstashNodes));
    ContainerNodeSpec nodeSpec = new ContainerNodeSpec.Builder().nodeFlavor("flavor").nodeState(Node.State.active).nodeType("type").hostname("hostname").minCpuCores(1).minMainMemoryAvailableGb(1).minDiskAvailableGb(1).build();
    Optional<String> config = filebeatConfigProvider.getConfig(nodeSpec);
    assertFalse(config.isPresent());
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) Test(org.junit.Test)

Example 17 with ContainerNodeSpec

use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.

the class MultiDockerTest method addAndWaitForNode.

private ContainerNodeSpec addAndWaitForNode(DockerTester tester, String hostName, DockerImage dockerImage) throws InterruptedException {
    ContainerNodeSpec containerNodeSpec = new ContainerNodeSpec.Builder().hostname(hostName).wantedDockerImage(dockerImage).wantedVespaVersion("1.2.3").nodeState(Node.State.active).nodeType("tenant").nodeFlavor("docker").wantedRestartGeneration(1L).currentRestartGeneration(1L).minCpuCores(1).minMainMemoryAvailableGb(1).minDiskAvailableGb(1).build();
    tester.addContainerNodeSpec(containerNodeSpec);
    // Wait for node admin to be notified with node repo state and the docker container has been started
    while (tester.nodeAdmin.getListOfHosts().size() != tester.nodeRepositoryMock.getNumberOfContainerSpecs()) {
        Thread.sleep(10);
    }
    ContainerName containerName = ContainerName.fromHostname(hostName);
    tester.callOrderVerifier.assertInOrder("createContainerCommand with " + dockerImage + ", HostName: " + hostName + ", " + containerName, "executeInContainerAsRoot with " + containerName + ", args: [" + DockerTester.NODE_PROGRAM + ", resume]");
    return containerNodeSpec;
}
Also used : ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec)

Example 18 with ContainerNodeSpec

use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.

the class FilebeatConfigProviderTest method getConfigString.

private String getConfigString() {
    FilebeatConfigProvider filebeatConfigProvider = new FilebeatConfigProvider(getEnvironment(logstashNodes));
    ContainerNodeSpec nodeSpec = getNodeSpec(tenant, application, instance);
    return filebeatConfigProvider.getConfig(nodeSpec).orElseThrow(() -> new RuntimeException("Failed to get filebeat config"));
}
Also used : ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec)

Example 19 with ContainerNodeSpec

use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.

the class NodeAgentImplTest method failedNodeRunningContainerShouldStillBeRunning.

@Test
public void failedNodeRunningContainerShouldStillBeRunning() {
    final long restartGeneration = 1;
    final ContainerNodeSpec nodeSpec = nodeSpecBuilder.wantedDockerImage(dockerImage).currentDockerImage(dockerImage).nodeState(Node.State.failed).wantedVespaVersion(vespaVersion).vespaVersion(vespaVersion).wantedRestartGeneration(restartGeneration).currentRestartGeneration(restartGeneration).build();
    NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
    when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(nodeSpec));
    nodeAgent.converge();
    verify(dockerOperations, never()).removeContainer(any(), any());
    verify(orchestrator, never()).resume(any(String.class));
    verify(nodeRepository, never()).updateNodeAttributes(eq(hostName), any());
}
Also used : ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) Test(org.junit.Test)

Example 20 with ContainerNodeSpec

use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.

the class NodeAgentImplTest method containerIsRestartedIfFlavorChanged.

@Test
public void containerIsRestartedIfFlavorChanged() throws IOException {
    final long wantedRestartGeneration = 1;
    final long currentRestartGeneration = 1;
    ContainerNodeSpec.Builder specBuilder = nodeSpecBuilder.wantedDockerImage(dockerImage).currentDockerImage(dockerImage).nodeState(Node.State.active).wantedVespaVersion(vespaVersion).vespaVersion(vespaVersion).wantedRestartGeneration(wantedRestartGeneration).currentRestartGeneration(currentRestartGeneration);
    NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
    ContainerNodeSpec firstSpec = specBuilder.build();
    ContainerNodeSpec secondSpec = specBuilder.minDiskAvailableGb(200).build();
    ContainerNodeSpec thirdSpec = specBuilder.minCpuCores(4).build();
    when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(firstSpec)).thenReturn(Optional.of(secondSpec)).thenReturn(Optional.of(thirdSpec));
    when(dockerOperations.pullImageAsyncIfNeeded(any())).thenReturn(true);
    when(storageMaintainer.getDiskUsageFor(eq(containerName))).thenReturn(Optional.of(201326592000L));
    when(pathResolver.getApplicationStoragePathForHost()).thenReturn(Files.createTempDirectory("bar"));
    nodeAgent.converge();
    nodeAgent.converge();
    nodeAgent.converge();
    InOrder inOrder = inOrder(orchestrator, dockerOperations);
    inOrder.verify(orchestrator).resume(any(String.class));
    inOrder.verify(orchestrator).resume(any(String.class));
    inOrder.verify(orchestrator).suspend(any(String.class));
    inOrder.verify(dockerOperations).removeContainer(any(), any());
    inOrder.verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(thirdSpec));
    inOrder.verify(dockerOperations).startContainer(eq(containerName), eq(thirdSpec));
    inOrder.verify(orchestrator).resume(any(String.class));
}
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