org.testcontainers.containers.GenericContainer Java Examples

The following examples show how to use org.testcontainers.containers.GenericContainer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MySQLRule.java    From vertx-sql-client with Apache License 2.0 6 votes vote down vote up
private void initServer() {
  server = new GenericContainer(databaseServerInfo.getDatabaseType().toDockerImageName() + ":" + databaseServerInfo.getDockerImageTag())
    .withEnv("MYSQL_USER", "mysql")
    .withEnv("MYSQL_PASSWORD", "password")
    .withEnv("MYSQL_ROOT_PASSWORD", "password")
    .withEnv("MYSQL_DATABASE", "testschema")
    .withExposedPorts(3306)
    .withClasspathResourceMapping("init.sql", "/docker-entrypoint-initdb.d/init.sql", BindMode.READ_ONLY)
    .withReuse(true);

  if (ssl) {
    server.withClasspathResourceMapping("tls/conf", "/etc/mysql/conf.d", BindMode.READ_ONLY);
    server.withClasspathResourceMapping("tls/files", "/etc/mysql/tls", BindMode.READ_ONLY);
  } else {
    server.withClasspathResourceMapping("tls/files", "/etc/mysql/tls", BindMode.READ_ONLY);
    String cmd = "--max_allowed_packet=33554432 --max_prepared_stmt_count=16382 --local_infile=true --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci";
    if (isUsingMySQL8()) {
      // introduced in MySQL 8.0.3
      cmd += " --caching-sha2-password-public-key-path=/etc/mysql/tls/public_key.pem --caching-sha2-password-private-key-path=/etc/mysql/tls/private_key.pem";
    }
    server.withCommand(cmd);
  }
}
 
Example #2
Source File: Linshare.java    From james-project with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
private GenericContainer<?> createLinshareBackendInit() {
    return new GenericContainer<>("linagora/linshare-init:2.3.2")
        .withNetworkAliases("init")
        .withLogConsumer(frame -> LOGGER.debug("<linshare-init> " + frame.getUtf8String()))
        .withEnv("LS_HOST", "backend")
        .withEnv("LS_PORT", "8080")
        .withEnv("LS_LDAP_NAME", "ldap-local")
        .withEnv("LS_LDAP_URL", "ldap://ldap:389")
        .withEnv("LS_LDAP_BASE_DN", "ou=People,dc=linshare,dc=org")
        .withEnv("LS_LDAP_DN", "cn=linshare,dc=linshare,dc=org")
        .withEnv("LS_LDAP_PW", "linshare")
        .withEnv("LS_DOMAIN_PATTERN_NAME", "openldap-local")
        .withEnv("LS_DOMAIN_PATTERN_MODEL", "868400c0-c12e-456a-8c3c-19e985290586")
        .withEnv("NO_REPLY_ADDRESS", "[email protected]")
        .withEnv("DEBUG", "1")
        .withEnv("FORCE_INIT", "1")
        .waitingFor(Wait.forLogMessage(WAIT_FOR_LDAP_INIT_LOG, 1)
            .withStartupTimeout(Duration.ofMinutes(10)))
        .withNetwork(network);
}
 
Example #3
Source File: FileOperationsTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void copyFileToContainerFileTest() throws Exception {
    try (
        GenericContainer alpineCopyToContainer = new GenericContainer("alpine:3.2")
            .withCommand("top")
    ) {
        alpineCopyToContainer.start();
        final MountableFile mountableFile = MountableFile.forClasspathResource("test_copy_to_container.txt");
        alpineCopyToContainer.copyFileToContainer(mountableFile, "/test.txt");

        File actualFile = new File(temporaryFolder.getRoot().getAbsolutePath() + "/test_copy_to_container.txt");
        alpineCopyToContainer.copyFileFromContainer("/test.txt", actualFile.getPath());

        File expectedFile = new File(mountableFile.getResolvedPath());
        assertTrue("Files aren't same ", FileUtils.contentEquals(expectedFile, actualFile));
    }
}
 
Example #4
Source File: Linshare.java    From james-project with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
private GenericContainer<?> createDockerBackend() {
    return new GenericContainer<>(
        new ImageFromDockerfile()
            .withFileFromClasspath("conf/log4j.properties", "backend/conf/log4j.properties")
            .withFileFromClasspath("conf/catalina.properties", "backend/conf/catalina.properties")
            .withFileFromClasspath("conf/id_rsa", "backend/conf/id_rsa.pri")
            .withFileFromClasspath("conf/id_rsa.pub", "backend/conf/id_rsa.pub")
            .withFileFromClasspath("Dockerfile", "backend/Dockerfile"))
        .withLogConsumer(frame -> LOGGER.debug("<linshare-backend> " + frame.getUtf8String()))
        .withNetworkAliases("backend")
        .withEnv("SMTP_HOST", "linshare_smtp")
        .withEnv("SMTP_PORT", "25")
        .withEnv("POSTGRES_HOST", "linshare_database")
        .withEnv("POSTGRES_PORT", "5432")
        .withEnv("POSTGRES_USER", "linshare")
        .withEnv("POSTGRES_PASSWORD", "linshare")
        .withEnv("MONGODB_HOST", "linshare_mongodb")
        .withEnv("MONGODB_PORT", "27017")
        .withEnv("THUMBNAIL_ENABLE", "false")
        .withExposedPorts(LINSHARE_BACKEND_PORT)
        .waitingFor(Wait.forLogMessage(WAIT_FOR_BACKEND_INIT_LOG, 1)
            .withStartupTimeout(Duration.ofMinutes(10)))
        .withNetwork(network);
}
 
Example #5
Source File: ContainersProvider.java    From replicator with Apache License 2.0 6 votes vote down vote up
@Override
public ServicesControl startZookeeper() {
    GenericContainer<?> zookeeper = this.getZookeeper(
            null, VersionedPipelines.defaultTags.zookeeperTag);

    zookeeper.start();


    return new ServicesControl() {
        @Override
        public GenericContainer<?> getContainer() { return zookeeper; }

        @Override
        public void close() {
            zookeeper.stop();
        }

        @Override
        public int getPort() {
            return zookeeper.getMappedPort(ContainersProvider.ZOOKEEPER_PORT);
        }

    };
}
 
Example #6
Source File: EmbeddedGraphiteBootstrapConfiguration.java    From kayenta with Apache License 2.0 6 votes vote down vote up
@Bean(name = "graphite", destroyMethod = "stop")
public GenericContainer graphite(
    ConfigurableEnvironment environment, WaitStrategy graphiteWaitStrategy) {

  GenericContainer container =
      new GenericContainer("graphiteapp/graphite-statsd:1.1.5-12")
          .withLogConsumer(containerLogsConsumer(log))
          .withExposedPorts(PICKLE_RECEIVER_PORT)
          .waitingFor(graphiteWaitStrategy)
          .withClasspathResourceMapping(
              "/external/graphite/storage-schemas.conf",
              "/opt/graphite/conf/storage-schemas.conf",
              BindMode.READ_ONLY)
          .withStartupTimeout(Duration.ofSeconds(30));
  container.start();

  Map<String, Object> map = registerEnvironment(environment, container);
  log.info("Started Graphite server. Connection details: {}", map);
  return container;
}
 
Example #7
Source File: DependenciesTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void shouldWorkWithMutlipleDependencies() {
    InvocationCountingStartable startable1 = new InvocationCountingStartable();
    InvocationCountingStartable startable2 = new InvocationCountingStartable();

    try (
        GenericContainer container = new GenericContainer()
            .withStartupCheckStrategy(new OneShotStartupCheckStrategy())
            .dependsOn(startable1, startable2)
    ) {
        container.start();
    }

    VisibleAssertions.assertEquals("Startable1 started once", 1, startable1.getStartInvocationCount().intValue());
    VisibleAssertions.assertEquals("Startable2 started once", 1, startable2.getStartInvocationCount().intValue());
}
 
Example #8
Source File: DirectoryTarResourceTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void simpleRecursiveClasspathResourceTest() {
    // This test combines the copying of classpath resources from JAR files with the recursive TAR approach, to allow JARed classpath resources to be copied in to an image

    GenericContainer container = new GenericContainer(
            new ImageFromDockerfile()
                    .withDockerfileFromBuilder(builder ->
                            builder.from("alpine:3.3")
                                    .copy("/tmp/foo", "/foo")
                                    .cmd("ls -lRt /foo")
                                    .build()
                    ).withFileFromClasspath("/tmp/foo", "/recursive/dir"))          // here we use /org/junit as a directory that really should exist on the classpath
            .withStartupCheckStrategy(new OneShotStartupCheckStrategy());

    container.start();

    final String results = container.getLogs();

    // ExternalResource.class is known to exist in a subdirectory of /org/junit so should be successfully copied in
    assertTrue("The container has a file that was copied in via a recursive copy from a JAR resource", results.contains("content.txt"));
}
 
Example #9
Source File: ConsulTestResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, String> start() {
    LOGGER.info(TestcontainersConfiguration.getInstance().toString());

    try {
        container = new GenericContainer(CONTAINER_IMAGE)
                .withExposedPorts(CONTAINER_PORT)
                .withCommand("agent", "-dev", "-server", "-bootstrap", "-client", "0.0.0.0", "-log-level", "trace")
                .waitingFor(Wait.forLogMessage(".*Synced node info.*", 1));

        container.start();

        return CollectionHelper.mapOf(
                "camel.consul.test-url",
                String.format("http://%s:%d",
                        container.getContainerIpAddress(),
                        container.getMappedPort(CONTAINER_PORT)));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #10
Source File: EmbeddedPrometheusBootstrapConfiguration.java    From kayenta with Apache License 2.0 6 votes vote down vote up
@Bean(name = "prometheus", destroyMethod = "stop")
public GenericContainer prometheus(
    ConfigurableEnvironment environment, WaitStrategy prometheusWaitStrategy) {

  GenericContainer container =
      new GenericContainer("prom/prometheus:v2.10.0")
          .withLogConsumer(containerLogsConsumer(log))
          .withExposedPorts(PORT)
          .withCopyFileToContainer(
              MountableFile.forClasspathResource("/external/prometheus/prometheus.yml"),
              "/etc/prometheus/prometheus.yml")
          .waitingFor(prometheusWaitStrategy)
          .withStartupTimeout(Duration.ofSeconds(30));
  container.start();
  Map<String, Object> env = registerEnvironment(environment, container.getMappedPort(PORT));
  log.info("Started Prometheus server. Connection details: {}", env);
  return container;
}
 
Example #11
Source File: TestcontainersConfiguration.java    From microprofile-sandbox with Apache License 2.0 6 votes vote down vote up
private Set<GenericContainer<?>> discoverContainers(Class<?> clazz) {
    Set<GenericContainer<?>> discoveredContainers = new HashSet<>();
    for (Field containerField : AnnotationSupport.findAnnotatedFields(clazz, Container.class)) {
        if (!Modifier.isPublic(containerField.getModifiers()))
            throw new ExtensionConfigurationException("@Container annotated fields must be public visibility");
        if (!Modifier.isStatic(containerField.getModifiers()))
            throw new ExtensionConfigurationException("@Container annotated fields must be static");
        boolean isStartable = GenericContainer.class.isAssignableFrom(containerField.getType());
        if (!isStartable)
            throw new ExtensionConfigurationException("@Container annotated fields must be a subclass of " + GenericContainer.class);
        try {
            GenericContainer<?> startableContainer = (GenericContainer<?>) containerField.get(null);
            discoveredContainers.add(startableContainer);
        } catch (IllegalArgumentException | IllegalAccessException e) {
            LOG.warn("Unable to access field " + containerField, e);
        }
    }
    return discoveredContainers;
}
 
Example #12
Source File: DockerignoreTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@SuppressWarnings("resource")
@Test
public void testValidDockerignore() throws Exception {
    ImageFromDockerfile img = new ImageFromDockerfile()
            .withFileFromPath(".", DockerfileBuildTest.RESOURCE_PATH)
            .withDockerfile(DockerfileBuildTest.RESOURCE_PATH.resolve("Dockerfile-currentdir"));
    try(
        final GenericContainer<?> container = new GenericContainer<>(img.get())
        .withStartupCheckStrategy(new OneShotStartupCheckStrategy())
        .withCommand("ls", "/")
    ) {

        container.start();

        final String logs = container.getLogs();
        assertTrue("Files in the container indicated the .dockerignore was not applied. Output was: " + logs, 
                logs.contains("should_not_be_ignored.txt"));
        assertTrue("Files in the container indicated the .dockerignore was not applied. Output was: " + logs, 
                !logs.contains("should_be_ignored.txt"));
    }
}
 
Example #13
Source File: InfinispanServerTestResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, String> start() {
    LOGGER.info(TestcontainersConfiguration.getInstance().toString());

    try {
        container = new GenericContainer<>(CONTAINER_IMAGE)
                .withExposedPorts(HOTROD_PORT)
                .withEnv("USER", USER)
                .withEnv("PASS", PASS)
                .waitingFor(Wait.forListeningPort());

        container.start();

        return CollectionHelper.mapOf(
                "quarkus.infinispan-client.server-list", getHostAndPort(container, HOTROD_PORT),
                "quarkus.infinispan-client.near-cache-max-entries", "3",
                "quarkus.infinispan-client.auth-username", USER,
                "quarkus.infinispan-client.auth-password", PASS,
                "quarkus.infinispan-client.auth-realm", "default",
                "quarkus.infinispan-client.sasl-mechanism", "DIGEST-MD5",
                "quarkus.infinispan-client.auth-server-name", "infinispan");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #14
Source File: GenericContainerRuleTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void withTmpFsTest() throws Exception {
    try (
        GenericContainer container = new GenericContainer()
            .withCommand("top")
            .withTmpFs(singletonMap("/testtmpfs", "rw"))
    ) {
        container.start();
        // check file doesn't exist
        String path = "/testtmpfs/test.file";
        Container.ExecResult execResult = container.execInContainer("ls", path);
        assertEquals("tmpfs inside container works fine", execResult.getStderr(),
            "ls: /testtmpfs/test.file: No such file or directory\n");
        // touch && check file does exist
        container.execInContainer("touch", path);
        execResult = container.execInContainer("ls", path);
        assertEquals("tmpfs inside container works fine", execResult.getStdout(), path + "\n");
    }
}
 
Example #15
Source File: TestcontainersConfiguration.java    From microshed-testing with Apache License 2.0 6 votes vote down vote up
void configureKafka() {
    // If a KafkaContainer is defined, store the bootstrap location
    Class<?> KafkaContainer = tryLoad("org.testcontainers.containers.KafkaContainer");
    if (KafkaContainer == null)
        return;

    Set<GenericContainer<?>> kafkaContainers = containers.allContainers.stream()
                    .filter(c -> KafkaContainer.isAssignableFrom(c.getClass()))
                    .collect(Collectors.toSet());

    if (kafkaContainers.size() == 1) {
        try {
            GenericContainer<?> kafka = kafkaContainers.iterator().next();
            String bootstrapServers = (String) KafkaContainer.getMethod("getBootstrapServers").invoke(kafka);
            System.setProperty("org.microshed.kafka.bootstrap.servers", bootstrapServers);
            LOG.debug("Discovered KafkaContainer with bootstrap.servers=" + bootstrapServers);
        } catch (Exception e) {
            LOG.warn("Unable to set kafka boostrap server", e);
        }
    } else if (kafkaContainers.size() > 1) {
        LOG.info("Located multiple KafkaContainer instances. Unable to auto configure kafka clients");
    } else {
        LOG.debug("No KafkaContainer instances found in configuration");
    }
}
 
Example #16
Source File: DirectoryTarResourceTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void simpleRecursiveFileWithPermissionTest() {
    GenericContainer container = new GenericContainer(
            new ImageFromDockerfile()
                    .withDockerfileFromBuilder(builder ->
                            builder.from("alpine:3.3")
                                    .copy("/tmp/foo", "/foo")
                                    .cmd("ls", "-al", "/")
                                    .build()
                    ).withFileFromFile("/tmp/foo", new File("/mappable-resource/test-resource.txt"),
                    0754))
            .withStartupCheckStrategy(new OneShotStartupCheckStrategy());

    container.start();
    String listing = container.getLogs();

    assertThat("Listing shows that file is copied with mode requested.",
            Arrays.asList(listing.split("\\n")),
            exactlyNItems(1, allOf(containsString("-rwxr-xr--"), containsString("foo"))));
}
 
Example #17
Source File: TestingKuduServer.java    From presto with Apache License 2.0 6 votes vote down vote up
public TestingKuduServer()
{
    Network network = Network.newNetwork();
    ImmutableList.Builder<GenericContainer<?>> tServersBuilder = ImmutableList.builder();
    this.master = new GenericContainer<>("apache/kudu:1.10.0")
            .withExposedPorts(KUDU_MASTER_PORT)
            .withCommand("master")
            .withNetwork(network)
            .withNetworkAliases("kudu-master");

    for (int instance = 0; instance < NUMBER_OF_REPLICA; instance++) {
        String instanceName = "kudu-tserver-" + instance;
        GenericContainer<?> tableServer = new GenericContainer<>("apache/kudu:1.10.0")
                .withExposedPorts(KUDU_TSERVER_PORT)
                .withCommand("tserver")
                .withEnv("KUDU_MASTERS", "kudu-master:" + KUDU_MASTER_PORT)
                .withNetwork(network)
                .withNetworkAliases("kudu-tserver-" + instance)
                .dependsOn(master)
                .withEnv("TSERVER_ARGS", "--fs_wal_dir=/var/lib/kudu/tserver --use_hybrid_clock=false --rpc_advertised_addresses=" + instanceName);
        tServersBuilder.add(tableServer);
    }
    this.tServers = tServersBuilder.build();
    master.start();
    tServers.forEach(GenericContainer::start);
}
 
Example #18
Source File: FileOperationsTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void copyFolderToContainerFolderTest() throws Exception {
    try (
        GenericContainer alpineCopyToContainer = new GenericContainer("alpine:3.2")
            .withCommand("top")
    ) {

        alpineCopyToContainer.start();
        final MountableFile mountableFile = MountableFile.forClasspathResource("mappable-resource/");
        alpineCopyToContainer.copyFileToContainer(mountableFile, "/home/test/");

        File actualFile = new File(temporaryFolder.getRoot().getAbsolutePath() + "/test_copy_to_container.txt");
        alpineCopyToContainer.copyFileFromContainer("/home/test/test-resource.txt", actualFile.getPath());

        File expectedFile = new File(mountableFile.getResolvedPath() + "/test-resource.txt");
        assertTrue("Files aren't same ", FileUtils.contentEquals(expectedFile, actualFile));
    }
}
 
Example #19
Source File: FileOperationsTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void copyFileToContainerFolderTest() throws Exception {
    try (
        GenericContainer alpineCopyToContainer = new GenericContainer("alpine:3.2")
            .withCommand("top")
    ) {
        alpineCopyToContainer.start();
        final MountableFile mountableFile = MountableFile.forClasspathResource("test_copy_to_container.txt");
        alpineCopyToContainer.copyFileToContainer(mountableFile, "/home/");

        File actualFile = new File(temporaryFolder.getRoot().getAbsolutePath() + "/test_copy_to_container.txt");
        alpineCopyToContainer.copyFileFromContainer("/home/test_copy_to_container.txt", actualFile.getPath());

        File expectedFile = new File(mountableFile.getResolvedPath());
        assertTrue("Files aren't same ", FileUtils.contentEquals(expectedFile, actualFile));
    }
}
 
Example #20
Source File: NexusPaxExamSupport.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
protected static Option[] configureDatabase() {
  switch (getValidTestDatabase()) {
    case POSTGRES:
      postgresContainer = new GenericContainer(POSTGRES_IMAGE) //NOSONAR
        .withExposedPorts(POSTGRES_PORT)
        .withEnv("POSTGRES_USER", DB_USER)
        .withEnv("POSTGRES_PASSWORD", DB_PASSWORD)
        .withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(NexusPaxExamSupport.class)))
        .withClasspathResourceMapping("initialize-postgres.sql", "/docker-entrypoint-initdb.d/initialize-postgres.sql", READ_ONLY)
        .waitingFor(Wait.forLogMessage(".*database system is ready to accept connections.*", 1));

      return combine(null,
          editConfigurationFilePut(NEXUS_PROPERTIES_FILE, "nexus.orient.enabled", "false"),
          systemProperty(TEST_JDBC_URL_PROPERTY).value(configurePostgres())
      );
    case H2:
      return combine(null,
          editConfigurationFilePut(NEXUS_PROPERTIES_FILE, "nexus.orient.enabled", "false")
      );
    case ORIENT:
      return new Option[0];
    default:
      throw new IllegalStateException("No case defined for " + getValidTestDatabase());
  }
}
 
Example #21
Source File: DockerNetworkModeTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testHostNetworkContainer() {
    try (
        GenericContainer container = new GenericContainer()
            .withStartupCheckStrategy(new OneShotStartupCheckStrategy())
            .withCommand("true")
            .withNetworkMode("host")
    ) {
        container.start();
        NetworkSettings networkSettings = container.getContainerInfo().getNetworkSettings();

        assertEquals("only one network is set", 1, networkSettings.getNetworks().size());
        assertTrue("network is 'host'", networkSettings.getNetworks().containsKey("host"));
    }
}
 
Example #22
Source File: JettyIT.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
public JettyIT(final String version) {
    super(new GenericContainer<>("jetty:" + version)
            .withExposedPorts(8080),
        "jetty-application",
        "/var/lib/jetty/webapps",
        "jetty");

    this.version = version;
}
 
Example #23
Source File: StatefulFunctionsAppContainers.java    From flink-statefun with Apache License 2.0 5 votes vote down vote up
private static List<GenericContainer<?>> workerContainers(
    ImageFromDockerfile appImage, int numWorkers, Network network) {
  final List<GenericContainer<?>> workers = new ArrayList<>(numWorkers);

  for (int i = 0; i < numWorkers; i++) {
    workers.add(
        new GenericContainer(appImage)
            .withNetwork(network)
            .withNetworkAliases(workerHostOf(i))
            .withEnv("ROLE", "worker")
            .withEnv("MASTER_HOST", MASTER_HOST));
  }

  return workers;
}
 
Example #24
Source File: PayaraIT.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
public PayaraIT(final String serverVersion, final String deploymentsFolder) {
    super(new GenericContainer<>(
            new ImageFromDockerfile()
                .withDockerfileFromBuilder(builder -> {
                        builder
                            .from("payara/server-web:" + serverVersion)
                            .run("sed", "-i", "s#" +
                                    "</java-config>#" +
                                    "<jvm-options>-javaagent:/elastic-apm-agent.jar</jvm-options></java-config>#",
                                "glassfish/domains/domain1/config/domain.xml")
                            .run("sed", "-i", "s#" +
                                    "</java-config>#" +
                                    "<jvm-options>-Xdebug</jvm-options></java-config>#",
                                "glassfish/domains/domain1/config/domain.xml");
                        if (ENABLE_DEBUGGING) {
                            builder.run("sed", "-i", "s#" +
                                    "</java-config>#" +
                                    "<jvm-options>-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005</jvm-options></java-config>#",
                                "glassfish/domains/domain1/config/domain.xml");
                        }
                    }
                )
        ),
        "glassfish-application",
        deploymentsFolder,
        "payara");
}
 
Example #25
Source File: AuthenticatedImagePullTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testThatAuthLocatorIsUsedForContainerCreation() {
    // actually start a container, which will require an authenticated pull
    try (final GenericContainer<?> container = new GenericContainer<>(testImageNameWithTag)
        .withCommand("/bin/sh", "-c", "sleep 10")) {
        container.start();

        assertTrue("container started following an authenticated pull", container.isRunning());
    }
}
 
Example #26
Source File: JBossIT.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
public JBossIT(final String jbossVersion) {
    super(new GenericContainer<>("registry.access.redhat.com/" + jbossVersion)
            // this overrides the defaults, so we have to manually re-add preferIPv4Stack
            // the other defaults don't seem to be important
            .withEnv("JAVA_OPTS", "-javaagent:/elastic-apm-agent.jar -Djava.net.preferIPv4Stack=true " +
                "-Djboss.modules.system.pkgs=org.jboss.logmanager,jdk.nashorn.api,com.sun.crypto.provider"),
        "jboss-application",
        "/opt/eap/standalone/deployments",
        "jboss");
}
 
Example #27
Source File: DaemonTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
public static void main(String[] args) {
    Thread mainThread = Thread.currentThread();

    GenericContainer genericContainer = null;

    try {
        genericContainer = new GenericContainer().withCommand("top");
        genericContainer.start();

        Set<Thread> threads = new HashSet<>(Thread.getAllStackTraces().keySet());
        threads.remove(mainThread);

        Set<Thread> nonDaemonThreads = threads.stream().filter(it -> !it.isDaemon()).collect(Collectors.toSet());

        if (nonDaemonThreads.isEmpty()) {
            VisibleAssertions.pass("All threads marked as daemon");
        } else {
            String nonDaemonThreadNames = nonDaemonThreads.stream()
                .map(Thread::getName)
                .collect(Collectors.joining("\n", "\n", ""));

            VisibleAssertions.fail("Expected all threads to be daemons but the following are not:\n" + nonDaemonThreadNames);
        }
    } finally {
        if (genericContainer != null) {
            genericContainer.stop();
        }
    }
}
 
Example #28
Source File: PulsarCluster.java    From pulsar with Apache License 2.0 5 votes vote down vote up
public void startService(String networkAlias,
                         GenericContainer<?> serviceContainer) {
    log.info("Starting external service {} ...", networkAlias);
    serviceContainer.withNetwork(network);
    serviceContainer.withNetworkAliases(networkAlias);
    serviceContainer.start();
    log.info("Successfully start external service {}", networkAlias);
}
 
Example #29
Source File: WebSphereIT.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
public WebSphereIT(final String version) {
    super((ENABLE_DEBUGGING
            ? new GenericContainer<>(new ImageFromDockerfile()
            .withDockerfileFromBuilder(builder -> builder
                .from("websphere-liberty:" + version).cmd("/opt/ibm/wlp/bin/server", "debug", "defaultServer")))
            : new GenericContainer<>("websphere-liberty:" + version)
        )
            .withEnv("JVM_ARGS", "-javaagent:/elastic-apm-agent.jar"),
        9080,
        7777,
        "websphere-application",
        "/config/dropins",
        "websphere");
}
 
Example #30
Source File: RedisServer.java    From presto with Apache License 2.0 5 votes vote down vote up
public RedisServer()
{
    container = new GenericContainer<>("redis:2.8.9")
            .withExposedPorts(PORT);
    container.start();

    jedisPool = new JedisPool(container.getContainerIpAddress(), container.getMappedPort(PORT));
}