@Test public void sharedMemorySetTest() { try (GenericContainer containerWithSharedMemory = new GenericContainer("busybox:1.29") .withSharedMemorySize(1024L * FileUtils.ONE_MB)) { containerWithSharedMemory.start(); HostConfig hostConfig = containerWithSharedMemory.getDockerClient().inspectContainerCmd(containerWithSharedMemory.getContainerId()) .exec().getHostConfig(); assertEquals("Shared memory not set on container", hostConfig.getShmSize(), 1024 * FileUtils.ONE_MB); } } }
public void createTopics(Collection<String> topics) { if (!topics.isEmpty()) { log.info("Creating Kafka topics: {}", topics); for (String topic : topics) { String[] createTopicCmd = getCreateTopicCmd(topic, kafkaZookeeperConnect); ContainerUtils.ExecCmdResult output = ContainerUtils.execCmd(this.kafka.getDockerClient(), this.kafka.getContainerId(), createTopicCmd); log.debug("Topic={} creation cmd='{}' exitCode={} : {}", topic, createTopicCmd, output.getExitCode(), output.getOutput()); } } }
public static String getContainerHostname(GenericContainer container) { InspectContainerResponse containerInfo = container.getContainerInfo(); if (containerInfo == null) { containerInfo = container.getDockerClient().inspectContainerCmd(container.getContainerId()).exec(); } return containerInfo.getConfig().getHostName(); }
private void train(String user, Path folder, TrainingKind trainingKind) throws IOException { spamAssassinContainer.getDockerClient().copyArchiveToContainerCmd(spamAssassinContainer.getContainerId()) .withHostResource(folder.toAbsolutePath().toString()) .withRemotePath("/root") .exec(); try (Stream<Path> paths = Files.walk(folder)) { paths .filter(Files::isRegularFile) .map(Path::toFile) .forEach(Throwing.consumer(file -> spamAssassinContainer.execInContainer("sa-learn", trainingKind.saLearnExtensionName(), "-u", user, "/root/" + trainingKind.name().toLowerCase(Locale.US) + "/" + file.getName()))); } }