org.testcontainers.containers.Network Java Examples

The following examples show how to use org.testcontainers.containers.Network. 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: HadoopBaseContainer.java    From camel-kafka-connector with Apache License 2.0 7 votes vote down vote up
public HadoopBaseContainer(Network network, String name) {
    super(new ImageFromDockerfile("hadoop-2x:ckc", false)
            .withFileFromClasspath(".",
                    "org/apache/camel/kafkaconnector/hdfs/services/"));

    withNetwork(network);

    withCreateContainerCmdModifier(
            new Consumer<CreateContainerCmd>() {
                @Override
                public void accept(CreateContainerCmd createContainerCmd) {
                    createContainerCmd.withHostName(name);
                    createContainerCmd.withName(name);
                }
            }
    );
}
 
Example #2
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 #3
Source File: TekuNode.java    From teku with Apache License 2.0 6 votes vote down vote up
public static TekuNode create(
    final SimpleHttpClient httpClient,
    final Network network,
    Consumer<Config> configOptions,
    final GenesisStateGenerator genesisStateGenerator)
    throws TimeoutException, IOException {

  final Config config = new Config();
  configOptions.accept(config);

  final TekuNode node = new TekuNode(httpClient, network, config);

  if (config.getGenesisStateConfig().isPresent()) {
    final GenesisStateConfig genesisConfig = config.getGenesisStateConfig().get();
    File genesisFile = genesisStateGenerator.generateState(genesisConfig);
    node.copyFileToContainer(genesisFile, genesisConfig.getPath());
  }

  return node;
}
 
Example #4
Source File: CouchbaseContainer.java    From java-dcp-client with Apache License 2.0 6 votes vote down vote up
public static CouchbaseContainer newCluster(String dockerImageName, Network network, String hostname, int hostUiPort) {
  final String username;
  final String password;

  try (InputStream is = BasicRebalanceIntegrationTest.class.getResourceAsStream("/application.properties")) {
    Properties props = new Properties();
    props.load(is);
    username = props.getProperty("username");
    password = props.getProperty("password");
  } catch (IOException e) {
    throw new UncheckedIOException(e);
  }

  log.info("Username: " + username);
  log.info("Password: " + password);

  final CouchbaseContainer couchbase = new CouchbaseContainer(dockerImageName, hostname, username, password, hostUiPort)
      .withNetwork(network);

  couchbase.start();
  couchbase.assignHostname();
  couchbase.initCluster();

  return couchbase;
}
 
Example #5
Source File: BesuNode.java    From teku with Apache License 2.0 6 votes vote down vote up
public BesuNode(final Network network) {
  super(network, "hyperledger/besu:1.3.6", LOG);
  container
      .withExposedPorts(JSON_RPC_PORT)
      .withLogConsumer(frame -> LOG.debug(frame.getUtf8String().trim()))
      .waitingFor(new HttpWaitStrategy().forPort(JSON_RPC_PORT).forPath("/liveness"))
      .withCopyFileToContainer(
          MountableFile.forClasspathResource("besu/depositContractGenesis.json"), "/genesis.json")
      .withCommand(
          "--rpc-http-enabled",
          "--rpc-http-port",
          Integer.toString(JSON_RPC_PORT),
          "--rpc-http-cors-origins=*",
          "--host-whitelist=*",
          "--miner-enabled",
          "--miner-coinbase",
          "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
          "--genesis-file",
          "/genesis.json");
}
 
Example #6
Source File: NetworkTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void testNetworkSupport() throws Exception {
    // useCustomNetwork {
    try (
            Network network = Network.newNetwork();

            GenericContainer foo = new GenericContainer()
                    .withNetwork(network)
                    .withNetworkAliases("foo")
                    .withCommand("/bin/sh", "-c", "while true ; do printf 'HTTP/1.1 200 OK\\n\\nyay' | nc -l -p 8080; done");

            GenericContainer bar = new GenericContainer()
                    .withNetwork(network)
                    .withCommand("top")
    ) {
        foo.start();
        bar.start();

        String response = bar.execInContainer("wget", "-O", "-", "http://foo:8080").getStdout();
        assertEquals("received response", "yay", response);
    }
    // }
}
 
Example #7
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 #8
Source File: StatefulFunctionsAppContainers.java    From flink-statefun with Apache License 2.0 6 votes vote down vote up
private static GenericContainer<?> masterContainer(
    ImageFromDockerfile appImage,
    Network network,
    List<GenericContainer<?>> dependents,
    int numWorkers,
    @Nullable Logger masterLogger) {
  final GenericContainer<?> master =
      new GenericContainer(appImage)
          .withNetwork(network)
          .withNetworkAliases(MASTER_HOST)
          .withEnv("ROLE", "master")
          .withEnv("MASTER_HOST", MASTER_HOST)
          .withCommand("-p " + numWorkers)
          .withExposedPorts(8081);

  for (GenericContainer<?> dependent : dependents) {
    master.dependsOn(dependent);
  }

  if (masterLogger != null) {
    master.withLogConsumer(new Slf4jLogConsumer(masterLogger, true));
  }

  return master;
}
 
Example #9
Source File: DockerElasticSearch.java    From james-project with Apache License 2.0 6 votes vote down vote up
WithAuth(String imageName) {
    this.network = Network.newNetwork();
    this.elasticSearch = new DockerElasticSearch.NoAuth(
        DockerElasticSearch.NoAuth
            .defaultContainer(imageName)
            .withLogConsumer(frame -> LOGGER.debug("[ElasticSearch] " + frame.getUtf8String()))
            .withNetwork(network)
            .withNetworkAliases("elasticsearch"));

    this.nginx = new DockerContainer(
            new GenericContainer<>(
                new ImageFromDockerfile()
                .withFileFromClasspath("conf/nginx-conf/", "auth-es/nginx-conf/")
                .withFileFromClasspath("conf/default.crt", "auth-es/default.crt")
                .withFileFromClasspath("conf/default.key", "auth-es/default.key")
                .withFileFromClasspath("Dockerfile", "auth-es/NginxDockerfile")))
        .withExposedPorts(ES_HTTP_PORT)
        .withLogConsumer(frame -> LOGGER.debug("[NGINX] " + frame.getUtf8String()))
        .withNetwork(network);
}
 
Example #10
Source File: ContainersProvider.java    From replicator with Apache License 2.0 6 votes vote down vote up
@Override
public ServicesControl startZookeeper(Network network, String networkAlias) {
    GenericContainer<?> zookeeper = this.getZookeeper(network, VersionedPipelines.defaultTags.zookeeperTag);
    zookeeper.withNetworkAliases(networkAlias);

    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 #11
Source File: IrohaNetwork.java    From iroha-java with Apache License 2.0 6 votes vote down vote up
/**
 * Finalizes current configuration. Should be called manually to apply latest changes.
 *
 * Useful for debugging.
 */
public IrohaNetwork configure() {
  val gb = genesisBlockBuilder.build();

  this.peers
      .forEach(pd -> {
        // update postgres host in config
        val ic = irohaConfig.clone();
        ic.getPg_opt().setHost(pd.getPostgresHost());

        val pc = PeerConfig.builder()
            .irohaConfig(ic)
            .genesisBlock(gb)
            .dir(Files.createTempDir())
            .build()
            .withPeerKeyPair(pd.getKeyPair());

        pd.getContainer().withPeerConfig(pc);
      });

  // init network
  network = Network.builder().id(networkName).build();

  return this;
}
 
Example #12
Source File: PulsarStandaloneTestBase.java    From pulsar with Apache License 2.0 6 votes vote down vote up
protected void startCluster(final String pulsarImageName) throws Exception {
    network = Network.newNetwork();
    String clusterName = PulsarClusterTestBase.randomName(8);
    container = new StandaloneContainer(clusterName, pulsarImageName)
        .withNetwork(network)
        .withNetworkAliases(StandaloneContainer.NAME + "-" + clusterName)
        .withEnv("PF_stateStorageServiceUrl", "bk://localhost:4181");
    container.start();
    log.info("Pulsar cluster {} is up running:", clusterName);
    log.info("\tBinary Service Url : {}", container.getPlainTextServiceUrl());
    log.info("\tHttp Service Url : {}", container.getHttpServiceUrl());

    // add cluster to public tenant
    ContainerExecResult result = container.execCmd(
            "/pulsar/bin/pulsar-admin", "namespaces", "policies", "public/default");
    assertEquals(0, result.getExitCode());
    log.info("public/default namespace policies are {}", result.getStdout());
}
 
Example #13
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 #14
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 #15
Source File: DcpIntegrationTestBase.java    From java-dcp-client with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
  final Network network = Network.builder().id("dcp-test-network").build();
  final String couchbaseVersionEnvar = "COUCHBASE";
  String couchbaseVersion = System.getenv(couchbaseVersionEnvar);
  if (couchbaseVersion == null) {
    if (runningInJenkins) {
      throw new RuntimeException("Environment variable " + couchbaseVersionEnvar + " must be set when running in Jenkins." +
          " Value should be the version of the 'couchbase/server' docker image to test against.");
    } else {
      couchbaseVersion = "6.5.0";
    }
  }
  //Check if using an internal server build image (ie. 6.5.0-4960), or a released build (ie. 6.5.0)
  //Only Couchbase org members will have access to the internal builds
  final String dockerImage = couchbaseVersion.matches("\\d.\\d.\\d-\\d{4}") ? "couchbase/server-internal:" + couchbaseVersion : "couchbase/server:" + couchbaseVersion;
  couchbase = CouchbaseContainer.newCluster(dockerImage, network, "kv1.couchbase.host", HOST_COUCHBASE_UI_PORT);

  // Dummy bucket for authenticating management requests (required for Couchbase versions prior to 6.5).
  // Give it a replica so failover tests don't fail with complaint about losing vbuckets.
  couchbase.createBucket("default", 100, 1, true);

  agentContainer = startAgent(network);
  agent = new RemoteAgent(agentContainer);
}
 
Example #16
Source File: NetworkTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void testReusability() throws Exception {
    try (Network network = Network.newNetwork()) {
        String firstId = network.getId();
        assertNotNull(
                "Network exists",
                DockerClientFactory.instance().client().inspectNetworkCmd().withNetworkId(firstId).exec()
        );

        network.close();

        assertNotEquals(
                "New network created",
                firstId,
                DockerClientFactory.instance().client().inspectNetworkCmd().withNetworkId(network.getId()).exec().getId()
        );
    }
}
 
Example #17
Source File: DockerRabbitMQ.java    From james-project with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("resource")
private DockerRabbitMQ(Optional<String> hostNamePrefix, Optional<String> clusterIdentity, Optional<String> erlangCookie, Optional<Network> net) {
    paused = false;
    this.hostNameSuffix = clusterIdentity.orElse(UUID.randomUUID().toString());
    this.rabbitHostName = hostName(hostNamePrefix);
    this.container = new GenericContainer<>(Images.RABBITMQ)
        .withCreateContainerCmdModifier(cmd -> cmd.withName(this.rabbitHostName))
        .withCreateContainerCmdModifier(cmd -> cmd.withHostName(this.rabbitHostName))
        .withExposedPorts(DEFAULT_RABBITMQ_PORT, DEFAULT_RABBITMQ_ADMIN_PORT)
        .waitingFor(waitStrategy())
        .withLogConsumer(frame -> LOGGER.debug(frame.getUtf8String()))
        .withTmpFs(ImmutableMap.of("/var/lib/rabbitmq/mnesia", "rw,noexec,nosuid,size=100m"));
    net.ifPresent(this.container::withNetwork);
    erlangCookie.ifPresent(cookie -> this.container.withEnv(RABBITMQ_ERLANG_COOKIE, cookie));
    this.nodeName = DEFAULT_RABBIT_NODE_NAME_PREFIX + "@" + this.rabbitHostName;
    this.container.withEnv(RABBITMQ_NODENAME, this.nodeName);
}
 
Example #18
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 #19
Source File: ReplicatorKafkaAvroTest.java    From replicator with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void before() {
    ServicesProvider servicesProvider = ServicesProvider.build(ServicesProvider.Type.CONTAINERS);

    ReplicatorKafkaAvroTest.zookeeper = servicesProvider.startZookeeper();

    MySQLConfiguration mySQLActiveSchemaConfiguration = new MySQLConfiguration(
            ReplicatorKafkaAvroTest.MYSQL_ACTIVE_SCHEMA,
            ReplicatorKafkaAvroTest.MYSQL_USERNAME,
            ReplicatorKafkaAvroTest.MYSQL_PASSWORD,
            ReplicatorKafkaAvroTest.MYSQL_CONF_FILE,
            Collections.emptyList(),
            null,
            null
    );

    ReplicatorKafkaAvroTest.mysqlBinaryLog = servicesProvider.startMySQL(MYSQL_CONFIG);
    ReplicatorKafkaAvroTest.mysqlActiveSchema = servicesProvider.startMySQL(mySQLActiveSchemaConfiguration);
    Network network = Network.newNetwork();
    ReplicatorKafkaAvroTest.kafkaZk = servicesProvider.startZookeeper(network, "kafkaZk");
    ReplicatorKafkaAvroTest.kafka = servicesProvider.startKafka(network, ReplicatorKafkaAvroTest.KAFKA_REPLICATOR_TOPIC_NAME, ReplicatorKafkaAvroTest.KAFKA_TOPIC_PARTITIONS, ReplicatorKafkaAvroTest.KAFKA_TOPIC_REPLICAS, "kafka");
    ReplicatorKafkaAvroTest.schemaRegistry = servicesProvider.startSchemaRegistry(network);
}
 
Example #20
Source File: ReplicatorKafkaJSONTest.java    From replicator with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void before() {
    ServicesProvider servicesProvider = ServicesProvider.build(ServicesProvider.Type.CONTAINERS);
    ReplicatorKafkaJSONTest.zookeeper = servicesProvider.startZookeeper();

    MySQLConfiguration mySQLActiveSchemaConfiguration = new MySQLConfiguration(
            ReplicatorKafkaJSONTest.MYSQL_ACTIVE_SCHEMA,
            ReplicatorKafkaJSONTest.MYSQL_USERNAME,
            ReplicatorKafkaJSONTest.MYSQL_PASSWORD,
            ReplicatorKafkaJSONTest.MYSQL_CONF_FILE,
            Collections.emptyList(),
            null,
            null
    );

    ReplicatorKafkaJSONTest.mysqlBinaryLog = servicesProvider.startMySQL(MYSQL_CONFIG);
    ReplicatorKafkaJSONTest.mysqlActiveSchema = servicesProvider.startMySQL(mySQLActiveSchemaConfiguration);
    Network network = Network.newNetwork();
    ReplicatorKafkaJSONTest.kafkaZk = servicesProvider.startZookeeper(network, "kafkaZk");
    ReplicatorKafkaJSONTest.kafka = servicesProvider.startKafka(network, ReplicatorKafkaJSONTest.KAFKA_REPLICATOR_TOPIC_NAME, ReplicatorKafkaJSONTest.KAFKA_TOPIC_PARTITIONS, ReplicatorKafkaJSONTest.KAFKA_TOPIC_REPLICAS, "kafka");
}
 
Example #21
Source File: ContainersProvider.java    From replicator with Apache License 2.0 5 votes vote down vote up
@Override
public ServicesControl startSchemaRegistry(Network network) {

    GenericContainer<?> schemaRegistry = this.getContainer(System.getProperty(
            ContainersProvider.SCHEMA_REGISTRY_IMAGE_KEY,
            VersionedPipelines.defaultTags.schemaRegistryTag
            ),
            ContainersProvider.SCHEMA_REGISTRY_PORT,
            network,
            ContainersProvider.SCHEMA_REGISTRY_WAIT_REGEX,
            1,
            true
    ).withEnv(
            ContainersProvider.SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL_KEY,
            String.format("%s:%d", "kafkaZk", ContainersProvider.ZOOKEEPER_PORT)
    ).withEnv(
            ContainersProvider.SCHEMA_REGISTRY_HOST_NAME_KEY,
            "localhost"
    );

    schemaRegistry.start();

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

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

        @Override
        public int getPort() {
            return schemaRegistry.getMappedPort(ContainersProvider.SCHEMA_REGISTRY_PORT);
        }
    };
}
 
Example #22
Source File: DcpIntegrationTestBase.java    From java-dcp-client with Apache License 2.0 5 votes vote down vote up
protected static AgentContainer startAgent(Network network) throws Exception {
  File appFile = new File("target/dcp-test-agent-0.1.0.jar");

  AgentContainer agentContainer = new AgentContainer(appFile, AGENT_UI_PORT).withNetwork(network)
      .withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("container.agent")));
  agentContainer.start();

  return agentContainer;
}
 
Example #23
Source File: NetworkTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testBuilder() throws Exception {
    try (
            Network network = Network.builder()
                    .driver("macvlan")
                    .build();
    ) {
        String id = network.getId();
        assertEquals(
                "Flag is set",
                "macvlan",
                DockerClientFactory.instance().client().inspectNetworkCmd().withNetworkId(id).exec().getDriver()
        );
    }
}
 
Example #24
Source File: SyndesisDbContainer.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public SyndesisDbContainer() {
    withDatabaseName("sampledb");
    withUsername("sampledb");
    withPassword("secret");

    withCreateContainerCmdModifier(cmd -> cmd.withName("syndesis-db"));
    withCreateContainerCmdModifier(cmd -> cmd.withPortBindings(new PortBinding(Ports.Binding.bindPort(DB_PORT), new ExposedPort(DB_PORT))));
    withInitScript("syndesis-db-init.sql");

    withNetwork(Network.newNetwork());
    withNetworkAliases("syndesis-db");
}
 
Example #25
Source File: MySQLConfiguration.java    From replicator with Apache License 2.0 5 votes vote down vote up
public MySQLConfiguration(String schema,
                          String username,
                          String password,
                          String confPath,
                          List<String> initScripts,
                          Network network,
                          String networkAlias) {
    this.schema = schema;
    this.username = username;
    this.password = password;
    this.confPath = confPath;
    this.initScripts = initScripts;
    this.network = network;
    this.networkAlias = networkAlias;
}
 
Example #26
Source File: StrimziKafkaContainer.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
public StrimziKafkaContainer(final String version) {
    super("strimzi/kafka:" + version);
    super.withNetwork(Network.SHARED);

    // exposing kafka port from the container
    withExposedPorts(KAFKA_PORT);
}
 
Example #27
Source File: BootstrapReplicatorTest.java    From replicator with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void before() {
    ServicesProvider servicesProvider = ServicesProvider.build(ServicesProvider.Type.CONTAINERS);

    MySQLConfiguration mySQLConfiguration = new MySQLConfiguration(
            BootstrapReplicatorTest.MYSQL_SCHEMA,
            BootstrapReplicatorTest.MYSQL_USERNAME,
            BootstrapReplicatorTest.MYSQL_PASSWORD,
            BootstrapReplicatorTest.MYSQL_CONF_FILE,
            Collections.singletonList(BootstrapReplicatorTest.MYSQL_INIT_SCRIPT),
            null,
            null
    );

    MySQLConfiguration mySQLActiveSchemaConfiguration = new MySQLConfiguration(
            BootstrapReplicatorTest.MYSQL_ACTIVE_SCHEMA,
            BootstrapReplicatorTest.MYSQL_USERNAME,
            BootstrapReplicatorTest.MYSQL_PASSWORD,
            BootstrapReplicatorTest.MYSQL_CONF_FILE,
            Collections.emptyList(),
            null,
            null
    );

    BootstrapReplicatorTest.mysqlBinaryLog = servicesProvider.startMySQL(mySQLConfiguration);
    BootstrapReplicatorTest.mysqlActiveSchema = servicesProvider.startMySQL(mySQLActiveSchemaConfiguration);
    Network network = Network.newNetwork();
    BootstrapReplicatorTest.kafkaZk = servicesProvider.startZookeeper(network, "kafkaZk");
    BootstrapReplicatorTest.kafka = servicesProvider.startKafka(network, BootstrapReplicatorTest.KAFKA_REPLICATOR_TOPIC_NAME, 3, 1, "kafka");
    BootstrapReplicatorTest.schemaRegistry = servicesProvider.startSchemaRegistry(network);

}
 
Example #28
Source File: ContainersProvider.java    From replicator with Apache License 2.0 5 votes vote down vote up
@Override
public ServicesControl startHbase() {

    Network network = Network.newNetwork();

    GenericContainer<?> hbase = this.getContainerHBase(
            VersionedPipelines.defaultTags.hbase,
            network,
            "",
            0,
            true
    );

    hbase.start();

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

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

        @Override
        public int getPort() {
            return hbase.getMappedPort(ContainersProvider.HBASE_ZK_PORT);
        }
    };
}
 
Example #29
Source File: ContainersProvider.java    From replicator with Apache License 2.0 5 votes vote down vote up
private GenericContainer<?> getZookeeper(Network network, String zkImageTag) {

        return this.getContainer(
                System.getProperty(
                        ContainersProvider.ZOOKEEPER_DOCKER_IMAGE_KEY,
                        zkImageTag
                ),
                ContainersProvider.ZOOKEEPER_PORT,
                network,
                ContainersProvider.ZOOKEEPER_STARTUP_WAIT_REGEX,
                ContainersProvider.ZOOKEEPER_STARTUP_WAIT_TIMES,
                network == null
        );
    }
 
Example #30
Source File: MainIT.java    From dockerfile-maven with Apache License 2.0 5 votes vote down vote up
private GenericContainer createFrontend(final Network network) {
  final String image;
  try {
    image = Files.readFirstLine(new File("target/docker/image-name"), Charsets.UTF_8);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }

  return new GenericContainer(image)
      .withExposedPorts(1338)
      .withCommand("http://backend:" + BACKEND_PORT)
      .withNetwork(network)
      .withNetworkAliases("frontend");
}