Search in sources :

Example 6 with ToxiproxyContainer

use of org.testcontainers.containers.ToxiproxyContainer in project hazelcast by hazelcast.

the class MySqlCdcNetworkIntegrationTest method when_networkDisconnectDuringSnapshotting_then_jetSourceIsStuckUntilReconnect.

@Test
public void when_networkDisconnectDuringSnapshotting_then_jetSourceIsStuckUntilReconnect() throws Exception {
    try (Network network = initNetwork();
        ToxiproxyContainer toxiproxy = initToxiproxy(network)) {
        mysql = initMySql(network, null);
        ToxiproxyContainer.ContainerProxy proxy = initProxy(toxiproxy, mysql);
        Pipeline pipeline = initPipeline(proxy.getContainerIpAddress(), proxy.getProxyPort());
        // when job starts
        HazelcastInstance hz = createHazelcastInstances(2)[0];
        Job job = hz.getJet().newJob(pipeline);
        assertJobStatusEventually(job, RUNNING);
        // and snapshotting is ongoing (we have no exact way of identifying
        // the moment, but random sleep will catch it at least some of the time)
        MILLISECONDS.sleep(ThreadLocalRandom.current().nextInt(0, 500));
        // and connection is cut
        proxy.setConnectionCut(true);
        // and some time passes
        MILLISECONDS.sleep(2 * RECONNECT_INTERVAL_MS);
        // and connection recovers
        proxy.setConnectionCut(false);
        // then connector manages to reconnect and finish snapshot
        try {
            assertEqualsEventually(() -> hz.getMap("results").size(), 4);
        } finally {
            abortJob(job);
        }
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ToxiproxyContainer(org.testcontainers.containers.ToxiproxyContainer) Network(org.testcontainers.containers.Network) Job(com.hazelcast.jet.Job) Pipeline(com.hazelcast.jet.pipeline.Pipeline) AbstractCdcIntegrationTest(com.hazelcast.jet.cdc.AbstractCdcIntegrationTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 7 with ToxiproxyContainer

use of org.testcontainers.containers.ToxiproxyContainer in project hazelcast by hazelcast.

the class MySqlCdcNetworkIntegrationTest method initToxiproxy.

private ToxiproxyContainer initToxiproxy(Network network) {
    ToxiproxyContainer toxiproxy = namedTestContainer(new ToxiproxyContainer().withNetwork(network));
    toxiproxy.start();
    return toxiproxy;
}
Also used : ToxiproxyContainer(org.testcontainers.containers.ToxiproxyContainer)

Aggregations

ToxiproxyContainer (org.testcontainers.containers.ToxiproxyContainer)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 Job (com.hazelcast.jet.Job)4 AbstractCdcIntegrationTest (com.hazelcast.jet.cdc.AbstractCdcIntegrationTest)4 Pipeline (com.hazelcast.jet.pipeline.Pipeline)4 NightlyTest (com.hazelcast.test.annotation.NightlyTest)4 Test (org.junit.Test)4 Network (org.testcontainers.containers.Network)4 AwsConfig (com.hazelcast.jet.kinesis.impl.AwsConfig)1 BeforeClass (org.junit.BeforeClass)1 LocalStackContainer (org.testcontainers.containers.localstack.LocalStackContainer)1