Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: enable on-demand Toxiproxy usage in integration tests
  • Loading branch information
robfrank committed Apr 28, 2026
commit c5afc1f00674dd1db36d8474c113d07116b9dbbc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
@Testcontainers
class NetworkDelayIT extends ContainersTestTemplate {

@Override
protected boolean useToxiproxy() {
return true;
}


// Proxy ports for Raft (consensus) traffic per node
private static final int RAFT_PROXY_PORT_0 = 8660;
private static final int RAFT_PROXY_PORT_1 = 8661;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
@Testcontainers
class PacketLossIT extends ContainersTestTemplate {

@Override
protected boolean useToxiproxy() {
return true;
}


// Proxy ports for Raft (consensus) traffic per node
private static final int RAFT_PROXY_PORT_0 = 8660;
private static final int RAFT_PROXY_PORT_1 = 8661;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,35 @@ public Duration step() {
// NETWORK
network = Network.newNetwork();

// Toxiproxy
logger.info("Creating a Toxiproxy container");
toxiproxy = new ToxiproxyContainer("ghcr.io/shopify/toxiproxy:2.12.0")
.withNetwork(network)
.withNetworkAliases("proxy");
Startables.deepStart(toxiproxy).join();
toxiproxyClient = new ToxiproxyClient(toxiproxy.getHost(), toxiproxy.getControlPort());
// Toxiproxy — only started when the subclass declares it needs fault injection
if (useToxiproxy()) {
logger.info("Creating a Toxiproxy container");
toxiproxy = new ToxiproxyContainer("ghcr.io/shopify/toxiproxy:2.12.0")
.withNetwork(network)
.withNetworkAliases("proxy");
Startables.deepStart(toxiproxy).join();
toxiproxyClient = new ToxiproxyClient(toxiproxy.getHost(), toxiproxy.getControlPort());
}

}

/**
* Override and return {@code true} in subclasses that inject network faults via Toxiproxy.
* When {@code false} (the default), no Toxiproxy container is started, reducing resource
* usage and eliminating spurious startup failures on resource-constrained CI runners.
*/
protected boolean useToxiproxy() {
return false;
}

@AfterEach
public void tearDown() {
stopContainers();

logger.info("Stopping the Toxiproxy container");
toxiproxy.stop();
if (toxiproxy != null) {
logger.info("Stopping the Toxiproxy container");
toxiproxy.stop();
}

deleteContainersDirectories();

Expand Down
Loading