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));
}
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);
}
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);
}
};
}
Aggregations