org.testcontainers.containers.wait.strategy.Wait Java Examples

The following examples show how to use org.testcontainers.containers.wait.strategy.Wait. 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: PulsarTlsContainer.java    From liiklus with MIT License 6 votes vote down vote up
public PulsarTlsContainer(String pulsarVersion) {
    super(pulsarVersion);
    withExposedPorts(BROKER_TLS_PORT, BROKER_HTTP_PORT);
    withEnv("PULSAR_PREFIX_brokerServicePortTls", BROKER_TLS_PORT + "");
    withEnv("PULSAR_PREFIX_tlsEnabled", "true");
    withEnv("PULSAR_PREFIX_tlsCertificateFilePath", "/pulsar/broker.cert.pem");
    withEnv("PULSAR_PREFIX_tlsKeyFilePath", "/pulsar/broker.key-pk8.pem");
    withEnv("PULSAR_PREFIX_tlsTrustCertsFilePath", "/pulsar/ca.cert.pem");

    withCopyFileToContainer(MountableFile.forClasspathResource("certs/"), "/pulsar/");

    setCommand(
            "/bin/bash",
            "-c",
            "bin/apply-config-from-env.py conf/standalone.conf && " +
            "bin/apply-config-from-env.py conf/proxy.conf && " +
                    "bin/pulsar standalone --no-functions-worker -nss"
    );

    waitingFor(Wait.forLogMessage(".*Created namespace public\\/default.*", 1));
}
 
Example #2
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 #3
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 #4
Source File: ZookeeperContainer.java    From camel-kafka-connector with Apache License 2.0 6 votes vote down vote up
public ZookeeperContainer(Network network, String name) {
    super(ZOOKEEPER_CONTAINER);

    withEnv("LOG_DIR", "/tmp/logs");
    withExposedPorts(ZOOKEEPER_PORT);
    withNetwork(network);
    withCreateContainerCmdModifier(
            new Consumer<CreateContainerCmd>() {
                @Override
                public void accept(CreateContainerCmd createContainerCmd) {
                    createContainerCmd.withHostName(name);
                    createContainerCmd.withName(name);
                }
            }
    );

    withCommand("sh", "-c",
            "bin/zookeeper-server-start.sh config/zookeeper.properties");

    waitingFor(Wait.forListeningPort());
}
 
Example #5
Source File: InfluxdbTestResource.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<>(INFLUXDB_IMAGE)
                .withExposedPorts(INFLUXDB_PORT)
                .waitingFor(Wait.forListeningPort());

        container.start();

        return CollectionHelper.mapOf(
                InfluxdbResource.INFLUXDB_CONNECTION_PROPERTY,
                "http://" + ContainerSupport.getHostAndPort(container, INFLUXDB_PORT));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #6
Source File: AzureTestResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, String> start() {
    try {
        container = new GenericContainer<>(AZURITE_IMAGE)
                .withExposedPorts(BLOB_SERVICE_PORT, QUEUE_SERVICE_PORT)
                .withLogConsumer(new Slf4jLogConsumer(LOGGER))
                .waitingFor(Wait.forListeningPort());
        container.start();

        String baseServiceUrl = "http://%s:%d/devstoreaccount1/";
        String blobServiceUrl = String.format(baseServiceUrl, container.getContainerIpAddress(),
                container.getMappedPort(BLOB_SERVICE_PORT));
        String queueServiceUrl = String.format(baseServiceUrl, container.getContainerIpAddress(),
                container.getMappedPort(QUEUE_SERVICE_PORT));

        Map<String, String> configuration = new HashMap<>();
        configuration.put("azurite.blob.service.url", blobServiceUrl);
        configuration.put("azurite.queue.service.url", queueServiceUrl);
        configuration.put("azurite.credentials", String.format(AZURITE_CREDENTIALS, blobServiceUrl, queueServiceUrl));
        return configuration;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #7
Source File: FhirTestResource.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)
                .withEnv("HAPI_FHIR_VERSION", "DSTU3")
                .waitingFor(Wait.forListeningPort());

        container.start();

        return CollectionHelper.mapOf(
                "camel.fhir.test-url",
                String.format(
                        "http://%s:%d/hapi-fhir-jpaserver/fhir",
                        container.getContainerIpAddress(),
                        container.getMappedPort(CONTAINER_PORT)));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #8
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 #9
Source File: TestHashicorpVaultAliasService.java    From knox with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpClass() {
  try {
    vaultContainer = new VaultContainer(vaultImage)
                         .withVaultToken(vaultToken)
                         .waitingFor(Wait.forListeningPort());
    vaultContainer.addExposedPort(vaultPort);

    vaultContainer.start();

    vaultAddress = String.format(Locale.ROOT,
        "http://%s:%s",
        vaultContainer.getContainerIpAddress(),
        vaultContainer.getMappedPort(vaultPort));

    assertTrue(vaultContainer.isRunning());
  } catch (Exception e) {
    assumeNoException(e);
  }
}
 
Example #10
Source File: ActiveMQTestResource.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<>(ACTIVEMQ_IMAGE)
                .withExposedPorts(TCP_PORT)
                .withLogConsumer(new Slf4jLogConsumer(LOGGER))
                .waitingFor(Wait.forListeningPort());

        container.start();

        return Collections.singletonMap(
                "camel.component.activemq.broker-url",
                String.format("tcp://%s:%d", container.getContainerIpAddress(), container.getMappedPort(TCP_PORT)));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #11
Source File: ActiveMQTestResource.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(ACTIVEMQ_IMAGE)
                .withExposedPorts(AMQP_PORT)
                .withLogConsumer(new Slf4jLogConsumer(LOGGER))
                .withEnv("BROKER_CONFIG_MAX_DISK_USAGE", "100")
                .waitingFor(Wait.forListeningPort());

        container.start();

        String brokerUrl = String.format("amqp://127.0.0.1:%d", container.getMappedPort(AMQP_PORT));

        return CollectionHelper.mapOf(
                "quarkus.qpid-jms.url", brokerUrl,
                "quarkus.qpid-jms.username", ACTIVEMQ_USERNAME,
                "quarkus.qpid-jms.password", ACTIVEMQ_PASSWORD);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #12
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 #13
Source File: MongoDbTestResource.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(MONGO_IMAGE)
                .withExposedPorts(MONGODB_PORT)
                .waitingFor(Wait.forListeningPort());

        container.start();

        return CollectionHelper.mapOf(
                "quarkus.mongodb.hosts",
                container.getContainerIpAddress() + ":" + container.getMappedPort(MONGODB_PORT).toString());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #14
Source File: ElasticSearchTestResource.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(ELASTICSEARCH_IMAGE)
                .withExposedPorts(ELASTICSEARCH_PORT)
                .withLogConsumer(new Slf4jLogConsumer(LOGGER))
                .withEnv("discovery.type", "single-node")
                .waitingFor(Wait.forListeningPort());

        container.start();

        return CollectionHelper.mapOf(
                "camel.component.elasticsearch-rest.host-addresses",
                String.format("localhost:%s", container.getMappedPort(ELASTICSEARCH_PORT)));

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #15
Source File: CamelKafkaTestResource.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 KafkaContainer(CONFLUENT_PLATFORM_VERSION)
                .withEmbeddedZookeeper()
                .waitingFor(Wait.forListeningPort());

        container.start();

        return Collections.singletonMap("camel.component.kafka.brokers", container.getBootstrapServers());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #16
Source File: OrientDBContainer.java    From testcontainers-java with MIT License 6 votes vote down vote up
public OrientDBContainer(@NonNull String dockerImageName) {
    super(dockerImageName);

    serverPassword = DEFAULT_SERVER_PASSWORD;
    databaseName = DEFAULT_DATABASE_NAME;

    WaitStrategy waitForHttp = new HttpWaitStrategy()
        .forPort(DEFAULT_HTTP_PORT)
        .forStatusCodeMatching(response -> response == HTTP_OK);

    waitStrategy = new WaitAllStrategy()
        .withStrategy(Wait.forListeningPort())
        .withStrategy(waitForHttp)
        .withStartupTimeout(Duration.ofMinutes(2));

    addExposedPorts(DEFAULT_BINARY_PORT, DEFAULT_HTTP_PORT);
}
 
Example #17
Source File: InfinispanServerTestResource.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, String> start() {
    if (INFINISPAN_IMAGE == null) {
        throw new RuntimeException("Please define a valid Infinispan image in system property container.image.infinispan");
    }
    LOGGER.info("Using Infinispan image: {}", INFINISPAN_IMAGE);
    infinispan = new FixedHostPortGenericContainer(INFINISPAN_IMAGE)
            .withFixedExposedPort(11232, 11222)
            //wait for the server to be  fully started
            .waitingFor(Wait.forLogMessage(".*\\bstarted\\b.*", 1))
            .withEnv("USER", "admin")
            .withEnv("PASS", "admin")
            .withLogConsumer(new Slf4jLogConsumer(LOGGER));
    infinispan.start();
    return Collections.emptyMap();
}
 
Example #18
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 #19
Source File: ContainersProvider.java    From replicator with Apache License 2.0 6 votes vote down vote up
private GenericContainer<?> getContainer(String image, int port, Network network, String logWaitRegex, int logWaitTimes, boolean matchExposedPort) {

        GenericContainer<?> container = new GenericContainer<>(image)
                .withExposedPorts(port)
                .waitingFor(
                        Wait.forLogMessage(logWaitRegex, logWaitTimes).withStartupTimeout(Duration.ofMinutes(5L))
                );

        if (network != null) {
            container.withNetwork(network);
        }

        if (matchExposedPort) {
            container.withCreateContainerCmdModifier(
                    command -> command.withPortBindings(PortBinding.parse(String.format("%d:%d", port, port)))
            );
        }

        container.withLogConsumer(outputFrame -> {
//            System.out.println(image + " " + outputFrame.getUtf8String());
        });


        return container;
    }
 
Example #20
Source File: VaultTestUtil.java    From hashicorp-vault-plugin with MIT License 6 votes vote down vote up
public static VaultContainer createVaultAgentContainer(
    Path roleIDPath,
    Path secretIDPath) {
    return new VaultContainer<>("vault:1.2.1")
        .withNetwork(network)
        .withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(IPC_LOCK))
        .withCopyFileToContainer(forHostPath(
            TestConstants.class.getResource("vaultTest_agent.hcl").getPath()),
            "/agent.hcl")
        .withCopyFileToContainer(forHostPath(roleIDPath),
            "/home/vault/role_id")
        .withCopyFileToContainer(forHostPath(secretIDPath),
            "/home/vault/secret_id")
        .withCommand("vault agent -config=/agent.hcl -address=http://vault:8200")
        .withExposedPorts(8200)
        .waitingFor(Wait.forLogMessage(".*renewed auth token.*", 1));
}
 
Example #21
Source File: MainIT.java    From dockerfile-maven with Apache License 2.0 6 votes vote down vote up
private GenericContainer createBackend(final Network network) {
  final String image;
  try {
    image = Resources.toString(
        Resources.getResource("META-INF/docker/com.spotify.it/backend/image-name"),
        Charsets.UTF_8).trim();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }

  final GenericContainer container = new GenericContainer(image)
      .withExposedPorts(BACKEND_PORT)
      .withNetwork(network)
      .withNetworkAliases("backend")
      .waitingFor(Wait.forHttp("/api/version"));

  // start early, since frontend needs to know the port of backend
  container.start();

  return container;
}
 
Example #22
Source File: JBossAMQBrokerContainer.java    From syndesis with Apache License 2.0 6 votes vote down vote up
public JBossAMQBrokerContainer() {
    super(String.format("registry.access.redhat.com/jboss-amq-6/amq63-openshift:%s", IMAGE_VERSION));

    withEnv("AMQ_USER", USERNAME);
    withEnv("AMQ_PASSWORD", PASSWORD);
    withEnv("AMQ_TRANSPORTS", "openwire,stomp,amqp,mqtt");

    withExposedPorts(OPENWIRE_PORT);
    withExposedPorts(STOMP_PORT);
    withExposedPorts(AMQP_PORT);
    withExposedPorts(MQTT_PORT);
    withExposedPorts(JOLOKIA_PORT);

    withNetwork(Network.newNetwork());
    withNetworkAliases("broker-amq-tcp");

    withCreateContainerCmdModifier(cmd -> cmd.withName("broker-amq"));

    waitingFor(Wait.forLogMessage(".*Apache ActiveMQ.*started.*\\s", 1));
}
 
Example #23
Source File: MongoDBContainer.java    From testcontainers-java with MIT License 5 votes vote down vote up
public MongoDBContainer(@NonNull final String dockerImageName) {
    super(dockerImageName);
    withExposedPorts(MONGODB_INTERNAL_PORT);
    withCommand("--replSet", "docker-rs");
    waitingFor(
        Wait.forLogMessage(".*waiting for connections on port.*", 1)
    );
}
 
Example #24
Source File: DockerComposeWaitStrategyTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testWaitOnListeningPort() {
    environment
        .withExposedService("redis_1", REDIS_PORT, Wait.forListeningPort());

    try {
        environment.starting(Description.createTestDescription(Object.class, "name"));
        VisibleAssertions.pass("Docker compose should start after waiting for listening port");
    } catch (RuntimeException e) {
        VisibleAssertions.fail("Docker compose should start after waiting for listening port with failed with: " + e);
    }
}
 
Example #25
Source File: DockerRabbitMQ.java    From james-project with Apache License 2.0 5 votes vote down vote up
private WaitStrategy waitStrategy() {
    return new WaitAllStrategy()
        .withStrategy(Wait.forHttp("").forPort(DEFAULT_RABBITMQ_ADMIN_PORT)
            .withRateLimiter(RateLimiters.TWENTIES_PER_SECOND)
            .withStartupTimeout(TEN_MINUTES_TIMEOUT))
        .withStrategy(new RabbitMQWaitStrategy(this, TEN_MINUTES_TIMEOUT))
        .withStartupTimeout(TEN_MINUTES_TIMEOUT);
}
 
Example #26
Source File: DockerAwsS3Container.java    From james-project with Apache License 2.0 5 votes vote down vote up
public DockerAwsS3Container() {
    this.awsS3Container = new GenericContainer<>(AWS_S3_DOCKER_IMAGE);
    this.awsS3Container
        .withExposedPorts(AWS_S3_PORT)
        .withEnv("S3BACKEND", "mem")
        .withEnv("SCALITY_ACCESS_KEY_ID", ACCESS_KEY_ID)
        .withEnv("SCALITY_SECRET_ACCESS_KEY", SECRET_ACCESS_KEY)
        .withEnv("LOG_LEVEL", "trace")
        .waitingFor(Wait.forLogMessage(".*\"message\":\"server started\".*\\n", ONE_TIME));
}
 
Example #27
Source File: VaultTestUtil.java    From hashicorp-vault-plugin with MIT License 5 votes vote down vote up
public static VaultContainer createVaultContainer() {
    if (!hasDockerDaemon()) {
        return null;
    }
    return new VaultContainer<>(VaultTestUtil.VAULT_DOCKER_IMAGE)
        .withVaultToken(VaultTestUtil.VAULT_ROOT_TOKEN)
        .withNetwork(network)
        .withNetworkAliases("vault")
        .withCopyFileToContainer(forHostPath(
            TestConstants.class.getResource("vaultTest_adminPolicy.hcl").getPath()),
            "/admin.hcl")
        .withExposedPorts(8200)
        .waitingFor(Wait.forHttp("/v1/sys/seal-status").forStatusCode(200));
}
 
Example #28
Source File: TimerToLog_IT.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
public void timeToLogJsonTest() {
    SyndesisIntegrationRuntimeContainer.Builder integrationContainerBuilder = new SyndesisIntegrationRuntimeContainer.Builder()
            .name("timer-to-log-json")
            .fromSource(new JsonIntegrationSource(TimerToLog_IT.class.getResourceAsStream("TimerToLog.json")));

    try (SyndesisIntegrationRuntimeContainer integrationContainer = integrationContainerBuilder.build()
            .waitingFor(Wait.forLogMessage(".*\"message\":\"Hello Syndesis!\".*\\s", 1))) {
        integrationContainer.start();
    }
}
 
Example #29
Source File: TimerToLog_IT.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
public void timeToLogExportTest() {
    try(SyndesisIntegrationRuntimeContainer integrationContainer =
            new SyndesisIntegrationRuntimeContainer.Builder()
                .name("timer-to-log-export")
                .fromExport(TimerToLog_IT.class.getResourceAsStream("TimerToLog-export.zip"))
                .build()) {
        integrationContainer.waitingFor(
            Wait.forLogMessage(".*\"message\":\"Hello Syndesis!\".*\\s", 2));
        integrationContainer.start();
    }
}
 
Example #30
Source File: DataNodeContainer.java    From camel-kafka-connector with Apache License 2.0 5 votes vote down vote up
public DataNodeContainer(Network network, String name) {
    super(network, name);

    withCommand("sh", "-c", "/hadoop/run-datanode.sh");

    withExposedPorts(HDFSPorts.DATA_NODE_HTTP_PORT, HDFSPorts.DATA_NODE_DATA_TRANSFER_PORT, HDFSPorts.DATA_NODE_IPC_PORT);

    waitingFor(Wait.forHttp("/").forPort(HDFSPorts.DATA_NODE_HTTP_PORT));



    /*
     We need the name to be a valid hostname: the files are uploaded
     directly to the dataNode host using the *hostname*. By default, the hostname
     is not valid and no accessible from outside, therefore we trick the container
     into using the localhost name so when the data node is resolved, it actually
     points to the port on the local host that is redirected inside the container.
     */
    withCreateContainerCmdModifier(
        createContainerCmd -> {
            createContainerCmd.withHostName(name);
            createContainerCmd.withName(name);
        }
    );

    addFixedExposedPort(HDFSPorts.DATA_NODE_HTTP_PORT, HDFSPorts.DATA_NODE_HTTP_PORT);
    addFixedExposedPort(HDFSPorts.DATA_NODE_DATA_TRANSFER_PORT, HDFSPorts.DATA_NODE_DATA_TRANSFER_PORT);
    addFixedExposedPort(HDFSPorts.DATA_NODE_IPC_PORT, HDFSPorts.DATA_NODE_IPC_PORT);
}