Search in sources :

Example 1 with Container

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

the class DockerMock method stopContainer.

@Override
public void stopContainer(ContainerName containerName) {
    synchronized (monitor) {
        callOrderVerifier.add("stopContainer with " + containerName);
        Container container = containersByContainerName.get(containerName);
        containersByContainerName.put(containerName, new Container(container.hostname, container.image, container.resources, container.name, Container.State.EXITED, 0));
    }
}
Also used : Container(com.yahoo.vespa.hosted.dockerapi.Container)

Example 2 with Container

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

the class DockerMock method createContainerCommand.

@Override
public CreateContainerCommand createContainerCommand(DockerImage dockerImage, ContainerResources containerResources, ContainerName containerName, String hostName) {
    synchronized (monitor) {
        callOrderVerifier.add("createContainerCommand with " + dockerImage + ", HostName: " + hostName + ", " + containerName);
        containersByContainerName.put(containerName, new Container(hostName, dockerImage, containerResources, containerName, Container.State.RUNNING, 2));
    }
    return new StartContainerCommandMock();
}
Also used : Container(com.yahoo.vespa.hosted.dockerapi.Container)

Example 3 with Container

use of com.yahoo.vespa.hosted.dockerapi.Container 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 4 with Container

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

the class AclMaintainerTest method reconfigures_acl_when_container_pid_changes.

@Test
public void reconfigures_acl_when_container_pid_changes() {
    Container container = makeContainer("container-1");
    List<ContainerAclSpec> aclSpecs = makeAclSpecs(3, container.name);
    when(nodeRepository.getContainerAclSpecs(NODE_ADMIN_HOSTNAME)).thenReturn(aclSpecs);
    aclMaintainer.run();
    assertAclsApplied(container.name, aclSpecs);
    // Container is restarted and PID changes
    makeContainer(container.name.asString(), Container.State.RUNNING, 43);
    aclMaintainer.run();
    assertAclsApplied(container.name, aclSpecs, times(2));
}
Also used : Container(com.yahoo.vespa.hosted.dockerapi.Container) ContainerAclSpec(com.yahoo.vespa.hosted.node.admin.ContainerAclSpec) Test(org.junit.Test)

Example 5 with Container

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

the class AclMaintainerTest method does_not_configure_acl_for_stopped_container.

@Test
public void does_not_configure_acl_for_stopped_container() {
    Container stoppedContainer = makeContainer("container-1", Container.State.EXITED, 0);
    List<ContainerAclSpec> aclSpecs = makeAclSpecs(1, stoppedContainer.name);
    when(nodeRepository.getContainerAclSpecs(NODE_ADMIN_HOSTNAME)).thenReturn(aclSpecs);
    aclMaintainer.run();
    assertAclsApplied(stoppedContainer.name, aclSpecs, never());
}
Also used : Container(com.yahoo.vespa.hosted.dockerapi.Container) ContainerAclSpec(com.yahoo.vespa.hosted.node.admin.ContainerAclSpec) Test(org.junit.Test)

Aggregations

Container (com.yahoo.vespa.hosted.dockerapi.Container)12 Test (org.junit.Test)6 ContainerName (com.yahoo.vespa.hosted.dockerapi.ContainerName)4 DockerImage (com.yahoo.vespa.hosted.dockerapi.DockerImage)4 ContainerAclSpec (com.yahoo.vespa.hosted.node.admin.ContainerAclSpec)4 NodeType (com.yahoo.config.provision.NodeType)2 ContainerResources (com.yahoo.vespa.hosted.dockerapi.ContainerResources)2 Docker (com.yahoo.vespa.hosted.dockerapi.Docker)2 ProcessResult (com.yahoo.vespa.hosted.dockerapi.ProcessResult)2 ContainerNodeSpec (com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec)2 Environment (com.yahoo.vespa.hosted.node.admin.component.Environment)2 PrefixLogger (com.yahoo.vespa.hosted.node.admin.util.PrefixLogger)2 IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Pair (com.yahoo.collections.Pair)1 ThreadFactoryFactory (com.yahoo.concurrent.ThreadFactoryFactory)1 ProcessExecuter (com.yahoo.system.ProcessExecuter)1