Search in sources :

Example 6 with ContainerName

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

the class AclMaintainerTest method makeContainer.

private Container makeContainer(String hostname, Container.State state, int pid) {
    final ContainerName containerName = new ContainerName(hostname);
    final Container container = new Container(hostname, new DockerImage("mock"), null, containerName, state, pid);
    containers.add(container);
    return container;
}
Also used : Container(com.yahoo.vespa.hosted.dockerapi.Container) ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage)

Example 7 with ContainerName

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

the class EnvironmentTest method testNonAbsolutePathInNodeConversion.

@Test(expected = IllegalArgumentException.class)
public void testNonAbsolutePathInNodeConversion() {
    Path varPath = Paths.get("some/relative/path");
    environment.pathInNodeAdminFromPathInNode(new ContainerName("container-1"), varPath);
}
Also used : Path(java.nio.file.Path) ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) Test(org.junit.Test)

Example 8 with ContainerName

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

the class DockerOperationsImplTest method processResultFromNodeProgramWhenSuccess.

@Test
public void processResultFromNodeProgramWhenSuccess() throws Exception {
    final ContainerName containerName = new ContainerName("container-name");
    final ProcessResult actualResult = new ProcessResult(0, "output", "errors");
    final String programPath = "/bin/command";
    final String[] command = new String[] { programPath, "arg" };
    when(docker.executeInContainerAsRoot(any(), anyVararg())).thenReturn(// output from node program
    actualResult);
    ProcessResult result = dockerOperations.executeCommandInContainer(containerName, command);
    final InOrder inOrder = inOrder(docker);
    inOrder.verify(docker, times(1)).executeInContainerAsRoot(eq(containerName), eq(command[0]), eq(command[1]));
    assertThat(result, is(actualResult));
}
Also used : InOrder(org.mockito.InOrder) ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) ProcessResult(com.yahoo.vespa.hosted.dockerapi.ProcessResult) Test(org.junit.Test)

Example 9 with ContainerName

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

the class DockerOperationsImplTest method makeContainer.

private Container makeContainer(String name, Container.State state, int pid) {
    final Container container = new Container(name + ".fqdn", new DockerImage("mock"), null, new ContainerName(name), state, pid);
    when(docker.getContainer(eq(container.name))).thenReturn(Optional.of(container));
    return container;
}
Also used : Container(com.yahoo.vespa.hosted.dockerapi.Container) ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage)

Example 10 with ContainerName

use of com.yahoo.vespa.hosted.dockerapi.ContainerName 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)

Aggregations

ContainerName (com.yahoo.vespa.hosted.dockerapi.ContainerName)21 Test (org.junit.Test)13 DockerImage (com.yahoo.vespa.hosted.dockerapi.DockerImage)7 ContainerNodeSpec (com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec)7 Container (com.yahoo.vespa.hosted.dockerapi.Container)4 ProcessResult (com.yahoo.vespa.hosted.dockerapi.ProcessResult)4 PrefixLogger (com.yahoo.vespa.hosted.node.admin.util.PrefixLogger)4 Map (java.util.Map)4 Docker (com.yahoo.vespa.hosted.dockerapi.Docker)3 IOException (java.io.IOException)3 List (java.util.List)3 Optional (java.util.Optional)3 Pair (com.yahoo.collections.Pair)2 NodeType (com.yahoo.config.provision.NodeType)2 ContainerResources (com.yahoo.vespa.hosted.dockerapi.ContainerResources)2 Environment (com.yahoo.vespa.hosted.node.admin.component.Environment)2 NodeRepository (com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeRepository)2 OrchestratorException (com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorException)2 DockerOperations (com.yahoo.vespa.hosted.node.admin.docker.DockerOperations)2 NodeAgent (com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent)2