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);
}
}
}
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;
}
Aggregations