use of com.yahoo.vespa.hosted.dockerapi.Container in project vespa by vespa-engine.
the class AclMaintainerTest method configures_container_acl.
@Test
public void configures_container_acl() {
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);
}
use of com.yahoo.vespa.hosted.dockerapi.Container in project vespa by vespa-engine.
the class AclMaintainerTest method rollback_is_attempted_when_applying_acl_fail.
@Test
public void rollback_is_attempted_when_applying_acl_fail() {
Container container = makeContainer("container-1");
when(nodeRepository.getContainerAclSpecs(NODE_ADMIN_HOSTNAME)).thenReturn(makeAclSpecs(1, container.name));
doThrow(new RuntimeException("iptables command failed")).doNothing().when(dockerOperations).executeCommandInNetworkNamespace(any(), anyVararg());
aclMaintainer.run();
verify(dockerOperations).executeCommandInNetworkNamespace(eq(container.name), eq("ip6tables"), eq("-P"), eq("INPUT"), eq("ACCEPT"));
}
use of com.yahoo.vespa.hosted.dockerapi.Container 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;
}
use of com.yahoo.vespa.hosted.dockerapi.Container in project vespa by vespa-engine.
the class AclMaintainerTest method does_not_configure_acl_if_unchanged.
@Test
public void does_not_configure_acl_if_unchanged() {
Container container = makeContainer("container-1");
List<ContainerAclSpec> aclSpecs = makeAclSpecs(3, container.name);
when(nodeRepository.getContainerAclSpecs(NODE_ADMIN_HOSTNAME)).thenReturn(aclSpecs);
// Run twice
aclMaintainer.run();
aclMaintainer.run();
assertAclsApplied(container.name, aclSpecs, times(1));
}
use of com.yahoo.vespa.hosted.dockerapi.Container in project vespa by vespa-engine.
the class DockerOperationsImplTest method runsCommandInNetworkNamespace.
@Test
public void runsCommandInNetworkNamespace() {
Container container = makeContainer("container-42", Container.State.RUNNING, 42);
try {
when(processExecuter.exec(aryEq(new String[] { "sudo", "nsenter", "--net=/host/proc/42/ns/net", "--", "iptables", "-nvL" }))).thenReturn(new Pair<>(0, ""));
} catch (IOException e) {
e.printStackTrace();
}
dockerOperations.executeCommandInNetworkNamespace(container.name, "iptables", "-nvL");
}
Aggregations