Search in sources :

Example 1 with ProcessResult

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

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

the class DockerOperationsImplTest method processResultFromNodeProgramWhenNonZeroExitCode.

@Test(expected = RuntimeException.class)
public void processResultFromNodeProgramWhenNonZeroExitCode() {
    final ContainerName containerName = new ContainerName("container-name");
    final ProcessResult actualResult = new ProcessResult(3, "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);
    dockerOperations.executeCommandInContainer(containerName, command);
}
Also used : ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) ProcessResult(com.yahoo.vespa.hosted.dockerapi.ProcessResult) Test(org.junit.Test)

Example 3 with ProcessResult

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

the class NodeAgentImpl method start.

@Override
public void start() {
    String message = "Starting with interval " + timeBetweenEachConverge.toMillis() + " ms";
    logger.info(message);
    addDebugMessage(message);
    loopThread.start();
    serviceRestarter = service -> {
        try {
            ProcessResult processResult = dockerOperations.executeCommandInContainerAsRoot(containerName, "service", service, "restart");
            if (!processResult.isSuccess()) {
                logger.error("Failed to restart service " + service + ": " + processResult);
            }
        } catch (Exception e) {
            logger.error("Failed to restart service " + service, e);
        }
    };
}
Also used : ProcessResult(com.yahoo.vespa.hosted.dockerapi.ProcessResult) DockerException(com.yahoo.vespa.hosted.dockerapi.DockerException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) DockerExecTimeoutException(com.yahoo.vespa.hosted.dockerapi.DockerExecTimeoutException) UncheckedIOException(java.io.UncheckedIOException) OrchestratorException(com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorException)

Aggregations

ProcessResult (com.yahoo.vespa.hosted.dockerapi.ProcessResult)3 ContainerName (com.yahoo.vespa.hosted.dockerapi.ContainerName)2 Test (org.junit.Test)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 DockerException (com.yahoo.vespa.hosted.dockerapi.DockerException)1 DockerExecTimeoutException (com.yahoo.vespa.hosted.dockerapi.DockerExecTimeoutException)1 OrchestratorException (com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorException)1 UncheckedIOException (java.io.UncheckedIOException)1 InOrder (org.mockito.InOrder)1