use of com.spotify.docker.client.messages.Version in project linuxtools by eclipse.
the class DockerConnection method getInfo.
@Override
public IDockerConnectionInfo getInfo() throws DockerException {
if (this.client == null) {
return null;
}
try {
final Info info = this.client.info();
final Version version = this.client.version();
return new DockerConnectionInfo(info, version);
} catch (com.spotify.docker.client.exceptions.DockerRequestException e) {
throw new DockerException(e.message());
} catch (com.spotify.docker.client.exceptions.DockerException | InterruptedException e) {
throw new DockerException(Messages.Docker_General_Info_Failure, e);
}
}
use of com.spotify.docker.client.messages.Version in project docker-client by spotify.
the class DefaultDockerClientTest method testVersion.
@Test
public void testVersion() throws Exception {
final Version version = sut.version();
assertThat(version.apiVersion(), not(isEmptyOrNullString()));
assertThat(version.arch(), not(isEmptyOrNullString()));
assertThat(version.gitCommit(), not(isEmptyOrNullString()));
assertThat(version.goVersion(), not(isEmptyOrNullString()));
assertThat(version.kernelVersion(), not(isEmptyOrNullString()));
assertThat(version.os(), not(isEmptyOrNullString()));
assertThat(version.version(), not(isEmptyOrNullString()));
if (dockerApiVersionAtLeast("1.22")) {
assertThat(version.buildTime(), not(isEmptyOrNullString()));
}
}
use of com.spotify.docker.client.messages.Version in project helios by spotify.
the class TaskRunnerTest method arePullsConcurrent.
private boolean arePullsConcurrent(final String dockerVersion) throws DockerException, InterruptedException, ExecutionException {
final Version version = mock(Version.class);
doReturn(dockerVersion).when(version).version();
doReturn(version).when(mockDocker).version();
final AtomicInteger pullers = new AtomicInteger();
final AtomicBoolean concurrentPullsIssued = new AtomicBoolean(false);
doAnswer(new Answer() {
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable {
try {
if (pullers.incrementAndGet() > 1) {
concurrentPullsIssued.set(true);
}
Thread.sleep(5000);
} finally {
pullers.decrementAndGet();
}
return null;
}
}).when(mockDocker).pull(any());
final TaskRunner tr = TaskRunner.builder().delayMillis(0).config(TaskConfig.builder().namespace("test").host(HOST).job(JOB).containerDecorators(ImmutableList.of(containerDecorator)).build()).docker(mockDocker).listener(new TaskRunner.NopListener()).build();
final TaskRunner tr2 = TaskRunner.builder().delayMillis(0).config(TaskConfig.builder().namespace("test").host(HOST).job(JOB).containerDecorators(ImmutableList.of(containerDecorator)).build()).docker(mockDocker).listener(new TaskRunner.NopListener()).build();
final ExecutorService executor = Executors.newFixedThreadPool(2);
final Future<?> future = executor.submit(new Runnable() {
@Override
public void run() {
tr.run();
}
});
final Future<?> future2 = executor.submit(new Runnable() {
@Override
public void run() {
tr2.run();
}
});
future.get();
future2.get();
return concurrentPullsIssued.get();
}
use of com.spotify.docker.client.messages.Version in project helios by spotify.
the class HealthCheckTest method execCompatibleDockerVersion.
private static Matcher<Version> execCompatibleDockerVersion() {
return new CustomTypeSafeMatcher<Version>("apiVersion >= 1.18") {
@Override
protected boolean matchesSafely(final Version version) {
try {
final Iterator<String> versionParts = Splitter.on('.').split(version.apiVersion()).iterator();
final int apiVersionMajor = Integer.parseInt(versionParts.next());
final int apiVersionMinor = Integer.parseInt(versionParts.next());
return apiVersionMajor == 1 && apiVersionMinor >= 18;
} catch (Exception e) {
return false;
}
}
};
}
use of com.spotify.docker.client.messages.Version 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(0L);
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);
}
Aggregations