feat(elbv2): make backend HTTP connection reuse configurable (#7557)

Expose backend keep-alive and idle-pool timeout controls while retaining the existing defaults. Preserve target failures without replaying uncertain requests, and document target timeout hints and local transport limits.

Validate negative idle timeouts with a Floci-specific error before creating clients, and attempt every fixture cleanup step while preserving aggregated failures. Cover negative, zero and positive configuration values and real-listener connection behavior.

Closes #7524

test(elbv2): replace timer-dependent backend checks
This commit is contained in:
jwoa95 authored and GitHub committed 2026-11-06 19:11:17 -04:00
1 parent 2df2a1e149
commit 983fdecc79
10 files changed
+313

No files matched your search

@@ -3700,6 +3700,14 @@ public interface EmulatorConfig {
@WithDefault("false")
boolean mock();
/** Reuse backend HTTP/1.x connections between ordinary forwarded requests. */
@WithDefault("true")
boolean backendKeepAlive();
/** Default idle-pool timeout in seconds; zero disables expiry. Target Keep-Alive may override it. */
@WithDefault("60")
int backendKeepAliveTimeoutSeconds();
}
interface EksServiceConfig {
@@ -237,6 +237,11 @@ public class ElbV2DataPlane {
@PostConstruct
void init() {
int keepAliveTimeoutSeconds = config.services().elbv2().backendKeepAliveTimeoutSeconds();
if (keepAliveTimeoutSeconds < 0) {
throw new IllegalArgumentException(
"floci.services.elbv2.backend-keep-alive-timeout-seconds must be non-negative");
}
proxyClient = vertx.createHttpClient(new HttpClientOptions()
.setTrustAll(true)
.setVerifyHost(false)
@@ -245,6 +250,7 @@ public class ElbV2DataPlane {
.setSslHandshakeTimeout(10)
.setSslHandshakeTimeoutUnit(TimeUnit.SECONDS)
.setKeepAlive(true)
.setKeepAliveTimeout(keepAliveTimeoutSeconds)
.setMaxHeaderSize(MAX_RESPONSE_HEADER_SIZE));
tcpClient = vertx.createNetClient(new NetClientOptions().setConnectTimeout(5000)
.setTcpKeepAlive(true));
@@ -1470,6 +1476,9 @@ public class ElbV2DataPlane {
if (hostHeader != null) {
clientReq.putHeader("Host", hostHeader);
}
if (!config.services().elbv2().backendKeepAlive()) {
clientReq.putHeader("Connection", "close");
}
AtomicBoolean responseStarted = new AtomicBoolean();
AtomicBoolean requestFailed = new AtomicBoolean();
clientReq.response().onSuccess(resp -> {