Search in sources :

Example 1 with ExecState

use of com.spotify.docker.client.messages.ExecState in project helios by spotify.

the class ExecHealthCheckerTest method setUp.

@Before
public void setUp() throws Exception {
    final ExecHealthCheck healthCheck = ExecHealthCheck.of("exit 0");
    final Info info = mock(Info.class);
    when(info.executionDriver()).thenReturn("native-0.2");
    final Version version = mock(Version.class);
    when(version.apiVersion()).thenReturn("1.18");
    final ExecState execState = mock(ExecState.class);
    when(execState.exitCode()).thenReturn(0);
    final LogStream log = mock(LogStream.class);
    when(log.readFully()).thenReturn("");
    docker = mock(DockerClient.class);
    when(docker.info()).thenReturn(info);
    when(docker.version()).thenReturn(version);
    when(docker.execCreate(eq(CONTAINER_ID), any(String[].class), (DockerClient.ExecCreateParam) anyVararg())).thenReturn(ExecCreation.create(EXEC_ID, emptyList()));
    when(docker.execStart(eq(EXEC_ID), (ExecStartParameter) anyVararg())).thenReturn(log);
    when(docker.execInspect(EXEC_ID)).thenReturn(execState);
    checker = new ExecHealthChecker(healthCheck, docker);
}
Also used : DockerClient(com.spotify.docker.client.DockerClient) Version(com.spotify.docker.client.messages.Version) ExecHealthCheck(com.spotify.helios.common.descriptors.ExecHealthCheck) ExecState(com.spotify.docker.client.messages.ExecState) LogStream(com.spotify.docker.client.LogStream) Info(com.spotify.docker.client.messages.Info) ExecHealthChecker(com.spotify.helios.agent.HealthCheckerFactory.ExecHealthChecker) Before(org.junit.Before)

Example 2 with ExecState

use of com.spotify.docker.client.messages.ExecState in project helios by spotify.

the class ExecHealthCheckerTest method testHealthCheckFailure.

@Test
public void testHealthCheckFailure() throws Exception {
    final ExecState execState = mock(ExecState.class);
    when(execState.exitCode()).thenReturn(2);
    when(docker.execInspect(EXEC_ID)).thenReturn(execState);
    assertThat(checker.check(CONTAINER_ID), is(false));
}
Also used : ExecState(com.spotify.docker.client.messages.ExecState) Test(org.junit.Test)

Aggregations

ExecState (com.spotify.docker.client.messages.ExecState)2 DockerClient (com.spotify.docker.client.DockerClient)1 LogStream (com.spotify.docker.client.LogStream)1 Info (com.spotify.docker.client.messages.Info)1 Version (com.spotify.docker.client.messages.Version)1 ExecHealthChecker (com.spotify.helios.agent.HealthCheckerFactory.ExecHealthChecker)1 ExecHealthCheck (com.spotify.helios.common.descriptors.ExecHealthCheck)1 Before (org.junit.Before)1 Test (org.junit.Test)1