return ((this.architecture == null) ? (that.architecture() == null) : this.architecture.equals(that.architecture())) && ((this.clusterStore == null) ? (that.clusterStore() == null) : this.clusterStore.equals(that.clusterStore())) && ((this.cgroupDriver == null) ? (that.cgroupDriver() == null) : this.cgroupDriver.equals(that.cgroupDriver())) && (this.containers.equals(that.containers())) && ((this.containersRunning == null) ? (that.containersRunning() == null) : this.containersRunning.equals(that.containersRunning())) && ((this.containersStopped == null) ? (that.containersStopped() == null) : this.containersStopped.equals(that.containersStopped())) && ((this.containersPaused == null) ? (that.containersPaused() == null) : this.containersPaused.equals(that.containersPaused())) && ((this.cpuCfsPeriod == null) ? (that.cpuCfsPeriod() == null) : this.cpuCfsPeriod.equals(that.cpuCfsPeriod())) && ((this.cpuCfsQuota == null) ? (that.cpuCfsQuota() == null) : this.cpuCfsQuota.equals(that.cpuCfsQuota())) && (this.debug.equals(that.debug())) && (this.dockerRootDir.equals(that.dockerRootDir())) && (this.storageDriver.equals(that.storageDriver())) && (this.driverStatus.equals(that.driverStatus())) && ((this.executionDriver == null) ? (that.executionDriver() == null) : this.executionDriver.equals(that.executionDriver())) && ((this.experimentalBuild == null) ? (that.experimentalBuild() == null) : this.experimentalBuild.equals(that.experimentalBuild())) && ((this.httpProxy == null) ? (that.httpProxy() == null) : this.httpProxy.equals(that.httpProxy())) && ((this.httpsProxy == null) ? (that.httpsProxy() == null) : this.httpsProxy.equals(that.httpsProxy())) && (this.id.equals(that.id())) && (this.ipv4Forwarding.equals(that.ipv4Forwarding())) && (this.images.equals(that.images())) && (this.indexServerAddress.equals(that.indexServerAddress())) && ((this.initPath == null) ? (that.initPath() == null) : this.initPath.equals(that.initPath())) && ((this.initSha1 == null) ? (that.initSha1() == null) : this.initSha1.equals(that.initSha1())) && ((this.kernelMemory == null) ? (that.kernelMemory() == null) : this.kernelMemory.equals(that.kernelMemory())) && (this.kernelVersion.equals(that.kernelVersion())) && (this.labels.equals(that.labels())) && (this.memTotal.equals(that.memTotal())) && (this.memoryLimit.equals(that.memoryLimit())) && (this.cpus.equals(that.cpus()))
if (info.memoryLimit()) { assertEquals(MEMORY, hostConfig.memory()); if (info.swapLimit()) { assertEquals(MEMORY_SWAP, hostConfig.memorySwap());
@Before public void setup() throws Exception { // LXC has a bug where the TERM signal isn't sent to containers, so we can only run this test // if docker runs with the native driver. // See: https://github.com/docker/docker/issues/2436 final DockerClient dockerClient = getNewDockerClient(); assumeThat(dockerClient.info().executionDriver(), startsWith("native")); }
envVars.put("PICK_ALL_RANDOM_PORTS", "true"); try { String hostName = dockerClient.info().name(); extraHosts.add(String.format("%s:%s", hostName, "127.0.1.0")); } catch (DockerException | InterruptedException e) {
@Test public void test() throws Exception { startDefaultMaster(); final String id = "test-" + toHexString(new SecureRandom().nextInt()); final String namespace = "helios-" + id; final String intruder1 = intruder(namespace); final String intruder2 = intruder(namespace); // Start a container in the agent namespace startContainer(intruder1); // Start agent final HeliosClient client = defaultClient(); startDefaultAgent(testHost(), "--id=" + id); awaitHostRegistered(client, testHost(), LONG_WAIT_SECONDS, SECONDS); awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS); // With LXC, killing a container results in exit code 0. // In docker 1.5 killing a container results in exit code 137, in previous versions it's -1. final String executionDriver = docker.info().executionDriver(); final List<Long> expectedExitCodes = (executionDriver != null && executionDriver.startsWith("lxc-")) ? Collections.singletonList(0L) : asList(-1L, 137L); // Wait for the agent to kill the container final ContainerExit exit1 = docker.waitContainer(intruder1); assertThat(exit1.statusCode(), isIn(expectedExitCodes)); // Start another container in the agent namespace startContainer(intruder2); // Wait for the agent to kill the second container as well final ContainerExit exit2 = docker.waitContainer(intruder2); assertThat(exit2.statusCode(), isIn(expectedExitCodes)); }
public void assertVolumes(final JobId jobId) throws Exception { // Wait for agent to come up awaitHostRegistered(client, testHost(), LONG_WAIT_SECONDS, SECONDS); awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS); // Deploy the job on the agent final Deployment deployment = Deployment.of(jobId, START); final JobDeployResponse deployed = client.deploy(deployment, testHost()).get(); assertEquals(JobDeployResponse.Status.OK, deployed.getStatus()); // Wait for the job to run final TaskStatus taskStatus = awaitJobState( client, testHost(), jobId, RUNNING, LONG_WAIT_SECONDS, SECONDS); assertJobEquals(job, taskStatus.getJob()); final Integer randomVolPort = taskStatus.getPorts().get("random").getExternalPort(); final Integer namedVolPort = taskStatus.getPorts().get("named").getExternalPort(); final Integer hostnamePort = taskStatus.getPorts().get("hostname").getExternalPort(); assert randomVolPort != null; assert namedVolPort != null; assert hostnamePort != null; // Read "foo" from /volume/bar and /mnt/my-volume/bar assertEquals("foo", recvUtf8(randomVolPort, 3)); assertEquals("foo", recvUtf8(namedVolPort, 3)); // Read hostname from /hostname final String hostname = getNewDockerClient().info().name(); final String mountedHostname = recvUtf8(hostnamePort, hostname.length()); assertEquals(hostname, mountedHostname); }
return ((this.architecture == null) ? (that.architecture() == null) : this.architecture.equals(that.architecture())) && ((this.clusterStore == null) ? (that.clusterStore() == null) : this.clusterStore.equals(that.clusterStore())) && ((this.cgroupDriver == null) ? (that.cgroupDriver() == null) : this.cgroupDriver.equals(that.cgroupDriver())) && (this.containers.equals(that.containers())) && ((this.containersRunning == null) ? (that.containersRunning() == null) : this.containersRunning.equals(that.containersRunning())) && ((this.containersStopped == null) ? (that.containersStopped() == null) : this.containersStopped.equals(that.containersStopped())) && ((this.containersPaused == null) ? (that.containersPaused() == null) : this.containersPaused.equals(that.containersPaused())) && ((this.cpuCfsPeriod == null) ? (that.cpuCfsPeriod() == null) : this.cpuCfsPeriod.equals(that.cpuCfsPeriod())) && ((this.cpuCfsQuota == null) ? (that.cpuCfsQuota() == null) : this.cpuCfsQuota.equals(that.cpuCfsQuota())) && (this.debug.equals(that.debug())) && (this.dockerRootDir.equals(that.dockerRootDir())) && (this.storageDriver.equals(that.storageDriver())) && (this.driverStatus.equals(that.driverStatus())) && ((this.executionDriver == null) ? (that.executionDriver() == null) : this.executionDriver.equals(that.executionDriver())) && ((this.experimentalBuild == null) ? (that.experimentalBuild() == null) : this.experimentalBuild.equals(that.experimentalBuild())) && ((this.httpProxy == null) ? (that.httpProxy() == null) : this.httpProxy.equals(that.httpProxy())) && ((this.httpsProxy == null) ? (that.httpsProxy() == null) : this.httpsProxy.equals(that.httpsProxy())) && (this.id.equals(that.id())) && (this.ipv4Forwarding.equals(that.ipv4Forwarding())) && (this.images.equals(that.images())) && (this.indexServerAddress.equals(that.indexServerAddress())) && ((this.initPath == null) ? (that.initPath() == null) : this.initPath.equals(that.initPath())) && ((this.initSha1 == null) ? (that.initSha1() == null) : this.initSha1.equals(that.initSha1())) && ((this.kernelMemory == null) ? (that.kernelMemory() == null) : this.kernelMemory.equals(that.kernelMemory())) && (this.kernelVersion.equals(that.kernelVersion())) && (this.labels.equals(that.labels())) && (this.memTotal.equals(that.memTotal())) && (this.memoryLimit.equals(that.memoryLimit())) && (this.cpus.equals(that.cpus()))
private static boolean compatibleDockerVersion(final DockerClient docker) { final String executionDriver; final String apiVersion; try { executionDriver = docker.info().executionDriver(); apiVersion = docker.version().apiVersion(); } catch (DockerException e) { return false; } catch (InterruptedException e) { Thread.currentThread().interrupt(); return false; } if (Strings.isNullOrEmpty(executionDriver) || !executionDriver.startsWith("native")) { return false; } if (Strings.isNullOrEmpty(apiVersion)) { return false; } final Iterable<String> split = Splitter.on(".").split(apiVersion); final int major = Integer.parseInt(Iterables.get(split, 0, "0")); final int minor = Integer.parseInt(Iterables.get(split, 1, "0")); return major == 1 && minor >= 18; } }
@Test public void test() throws Exception { try (final DockerClient docker = getNewDockerClient()) { // Start Helios agent, configured to bind host /etc/hostname into container /mnt/hostname startDefaultMaster(); startDefaultAgent(testHost(), "--bind", "/etc/hostname:/mnt/hostname:ro"); awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS); // Figure out the host kernel version final String hostname = docker.info().name(); // Run a job that cat's /mnt/hostname, which should be the host's name final List<String> command = ImmutableList.of("cat", "/mnt/hostname"); final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, command); deployJob(jobId, testHost()); final TaskStatus taskStatus = awaitTaskState(jobId, testHost(), EXITED); final String log; try (LogStream logs = docker.logs(taskStatus.getContainerId(), stdout(), stderr())) { log = logs.readFully(); } // the kernel version from the host should be in the log assertThat(log, containsString(hostname)); } }