test(elbv2): build the HTTPS, stickiness and host-header test ALBs with AlbFixtures (#7195)

This commit is contained in:
Abhigya authored and GitHub committed 2026-11-01 09:14:26 -04:00
1 parent ebe2a9ee11
commit e6b1f54cb4
4 files changed
+71 -264

No files matched your search

@@ -12,6 +12,7 @@ import io.github.hectorvent.floci.services.acm.model.CertificateStatus;
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
import io.github.hectorvent.floci.services.acm.model.ValidationMethod;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.testing.AlbFixtures;
import io.github.hectorvent.floci.testing.InlineMocks;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.arc.ClientProxy;
@@ -63,6 +64,11 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BooleanSupplier;
import static io.github.hectorvent.floci.testing.AlbFixtures.deleteListener;
import static io.github.hectorvent.floci.testing.AlbFixtures.deleteLoadBalancer;
import static io.github.hectorvent.floci.testing.AlbFixtures.deleteTargetGroup;
import static io.github.hectorvent.floci.testing.AlbFixtures.loadBalancerDnsName;
import static io.github.hectorvent.floci.testing.AlbFixtures.registerTarget;
import static io.restassured.RestAssured.given;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
@@ -179,9 +185,7 @@ class ElbV2HttpsDataPlaneIntegrationTest {
assertAll("Delete the local transport fixture after any failure",
() -> {
if (ownedLoadBalancer != null) {
given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", ownedLoadBalancer.arn())
.when().post("/").then().statusCode(200);
deleteLoadBalancer(ownedLoadBalancer.arn());
}
},
() -> {
@@ -218,12 +222,10 @@ class ElbV2HttpsDataPlaneIntegrationTest {
HttpsResult secondWire = awaitHttpsAtPort(loadBalancer.dnsName(), HTTP_PORT, current);
assertEquals("second", secondWire.body());
assertPeerCertificate(secondWire.session(), current, loadBalancer.dnsName());
given().header("Authorization", AUTH).formParam("Action", "DeleteListener")
.formParam("ListenerArn", second).when().post("/").then().statusCode(200);
deleteListener(second);
assertAcmConsumers(current.getArn(), List.of(loadBalancer.arn(), persistedConsumer));
assertAcmDeleteInUse(current.getArn());
given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", loadBalancer.arn()).when().post("/").then().statusCode(200);
deleteLoadBalancer(loadBalancer.arn());
assertAcmConsumers(current.getArn(), List.of(persistedConsumer));
assertAcmDeleteInUse(current.getArn());
acmService.removeInUseBy(current.getArn(), persistedConsumer, REGION);
@@ -238,8 +240,7 @@ class ElbV2HttpsDataPlaneIntegrationTest {
} finally {
boolean releasePersisted = persisted;
assertAll("Clean every association fixture resource",
() -> given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", loadBalancer.arn()).when().post("/").then().statusCode(200),
() -> deleteLoadBalancer(loadBalancer.arn()),
() -> { if (releasePersisted) { acmService.removeInUseBy(certificate.getArn(), persistedConsumer, REGION); } },
() -> {
try {
@@ -480,8 +481,7 @@ class ElbV2HttpsDataPlaneIntegrationTest {
.extract().xmlPath().getList("DescribeTagsResponse.DescribeTagsResult.TagDescriptions.member.Tags.member").isEmpty()),
() -> assertEquals("winner", awaitHttps(winner.dnsName(), certificate).body()),
() -> assertPlainResponse(first.dnsName(), HTTP_PORT, "unrelated"));
given().header("Authorization", AUTH).formParam("Action", "DeleteListener")
.formParam("ListenerArn", winnerArn).when().post("/").then().statusCode(200);
deleteListener(winnerArn);
awaitListenerPortClosed();
createFixedResponseListener(first.arn(), "HTTP", HTTPS_PORT, null, "retry");
awaitPlainResponse(first.dnsName(), HTTPS_PORT, "retry");
@@ -542,8 +542,7 @@ class ElbV2HttpsDataPlaneIntegrationTest {
+ "DefaultActions.member.FixedResponseConfig.MessageBody")),
() -> assertPlainResponse(first.dnsName(), HTTP_PORT, "original"),
() -> assertPlainResponse(winner.dnsName(), HTTPS_PORT, "winner"));
given().header("Authorization", AUTH).formParam("Action", "DeleteListener")
.formParam("ListenerArn", winnerArn).when().post("/").then().statusCode(200);
deleteListener(winnerArn);
awaitListenerPortClosed();
given().header("Authorization", AUTH).formParam("Action", "ModifyListener")
.formParam("ListenerArn", firstArn).formParam("Protocol", "HTTPS").formParam("Port", HTTPS_PORT)
@@ -633,8 +632,7 @@ class ElbV2HttpsDataPlaneIntegrationTest {
String progress = createFixedResponseListener(unrelated.arn(), "HTTP", HTTP_PORT, null, "progress");
awaitPlainResponse(unrelated.dnsName(), HTTP_PORT, "progress");
assertEquals("original", awaitHttps(loadBalancer.dnsName(), first).body());
given().header("Authorization", AUTH).formParam("Action", "DeleteListener")
.formParam("ListenerArn", progress).when().post("/").then().statusCode(200);
deleteListener(progress);
awaitListenerPortClosed(HTTP_PORT);
release.get().countDown();
assertEquals(200, moving.get(10, TimeUnit.SECONDS).statusCode());
@@ -681,10 +679,8 @@ class ElbV2HttpsDataPlaneIntegrationTest {
Certificate ownedFirst = first;
Certificate ownedAdded = added;
assertAll("Clean all material-retry resources after success or failure",
() -> given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", loadBalancer.arn()).when().post("/").then().statusCode(200),
() -> given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", unrelated.arn()).when().post("/").then().statusCode(200),
() -> deleteLoadBalancer(loadBalancer.arn()),
() -> deleteLoadBalancer(unrelated.arn()),
() -> awaitListenerPortClosed(HTTPS_PORT),
() -> awaitListenerPortClosed(HTTP_PORT),
() -> {
@@ -720,10 +716,8 @@ class ElbV2HttpsDataPlaneIntegrationTest {
private void cleanupProtocolFixtures(LoadBalancerRef first, LoadBalancerRef winner, Certificate certificate) {
assertAll("Remove both protocol-race fixtures even when the loser was published",
() -> given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", first.arn()).when().post("/").then().statusCode(200),
() -> given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", winner.arn()).when().post("/").then().statusCode(200),
() -> deleteLoadBalancer(first.arn()),
() -> deleteLoadBalancer(winner.arn()),
ElbV2HttpsDataPlaneIntegrationTest::awaitListenerPortClosed,
() -> acmService.deleteCertificate(certificate.getArn(), REGION));
}
@@ -736,13 +730,11 @@ class ElbV2HttpsDataPlaneIntegrationTest {
.when().post("/").then().statusCode(200).extract().xmlPath()
.getList("DescribeListenersResponse.DescribeListenersResult.Listeners.member.ListenerArn");
for (String listener : listeners) {
given().header("Authorization", AUTH).formParam("Action", "DeleteListener")
.formParam("ListenerArn", listener).when().post("/").then().statusCode(200);
deleteListener(listener);
}
awaitListenerPortClosed();
},
() -> given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", loadBalancer.arn()).when().post("/").then().statusCode(200),
() -> deleteLoadBalancer(loadBalancer.arn()),
() -> acmService.deleteCertificate(certificate.getArn(), REGION));
}
@@ -1145,14 +1137,8 @@ class ElbV2HttpsDataPlaneIntegrationTest {
Certificate ownedOriginal = original;
Certificate ownedReplacement = replacement;
assertAll("Delete all keep-alive fixture resources",
() -> {
if (ownedListener != null) {
given().header("Authorization", AUTH).formParam("Action", "DeleteListener")
.formParam("ListenerArn", ownedListener).when().post("/").then().statusCode(200);
}
},
() -> given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", loadBalancer.arn()).when().post("/").then().statusCode(200),
() -> deleteListener(ownedListener),
() -> deleteLoadBalancer(loadBalancer.arn()),
() -> {
if (ownedOriginal != null) {
acmService.deleteCertificate(ownedOriginal.getArn(), REGION);
@@ -1442,14 +1428,8 @@ class ElbV2HttpsDataPlaneIntegrationTest {
String ownedOriginal = originalArn;
String ownedReplacement = replacementArn;
assertAll("Delete stored IAM TLS fixture resources",
() -> {
if (ownedListener != null) {
given().header("Authorization", AUTH).formParam("Action", "DeleteListener")
.formParam("ListenerArn", ownedListener).when().post("/").then().statusCode(200);
}
},
() -> given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", loadBalancer.arn()).when().post("/").then().statusCode(200),
() -> deleteListener(ownedListener),
() -> deleteLoadBalancer(loadBalancer.arn()),
() -> {
if (ownedOriginal != null) {
given().header("Authorization", accountAuthorization("test", "iam"))
@@ -1544,22 +1524,8 @@ class ElbV2HttpsDataPlaneIntegrationTest {
}
private static LoadBalancerRef createLoadBalancer(String name) {
Response response = given()
.formParam("Action", "CreateLoadBalancer")
.formParam("Name", name)
.formParam("Type", "application")
.formParam("Subnets.member.1", Ec2Service.defaultSubnetId(REGION, "a"))
.formParam("Subnets.member.2", Ec2Service.defaultSubnetId(REGION, "b"))
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(200)
.extract()
.response();
return new LoadBalancerRef(
response.path("CreateLoadBalancerResponse.CreateLoadBalancerResult.LoadBalancers.member.LoadBalancerArn"),
response.path("CreateLoadBalancerResponse.CreateLoadBalancerResult.LoadBalancers.member.DNSName"));
String arn = AlbFixtures.createLoadBalancer(name);
return new LoadBalancerRef(arn, loadBalancerDnsName(arn));
}
private static String createFixedResponseListener(
@@ -1608,16 +1574,7 @@ class ElbV2HttpsDataPlaneIntegrationTest {
.extract()
.path("CreateTargetGroupResponse.CreateTargetGroupResult.TargetGroups.member.TargetGroupArn");
given()
.formParam("Action", "RegisterTargets")
.formParam("TargetGroupArn", targetGroupArn)
.formParam("Targets.member.1.Id", "127.0.0.1")
.formParam("Targets.member.1.Port", String.valueOf(targetPort))
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(200);
registerTarget(targetGroupArn, "127.0.0.1", targetPort);
return targetGroupArn;
}
@@ -1778,42 +1735,6 @@ class ElbV2HttpsDataPlaneIntegrationTest {
return false;
}
private static void deleteListener(String listenerArn) {
if (listenerArn == null) {
return;
}
given()
.formParam("Action", "DeleteListener")
.formParam("ListenerArn", listenerArn)
.header("Authorization", AUTH)
.when()
.post("/");
}
private static void deleteLoadBalancer(String lbArn) {
if (lbArn == null) {
return;
}
given()
.formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", lbArn)
.header("Authorization", AUTH)
.when()
.post("/");
}
private static void deleteTargetGroup(String targetGroupArn) {
if (targetGroupArn == null) {
return;
}
given()
.formParam("Action", "DeleteTargetGroup")
.formParam("TargetGroupArn", targetGroupArn)
.header("Authorization", AUTH)
.when()
.post("/");
}
private record LoadBalancerRef(String arn, String dnsName) {}
private record HttpResult(int statusCode, String body) {}
@@ -1,6 +1,5 @@
package io.github.hectorvent.floci.services.elbv2;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.testing.RealElbV2DataPlaneProfile;
import io.github.hectorvent.floci.testutil.FreePorts;
import io.quarkus.test.junit.QuarkusTest;
@@ -31,9 +30,16 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import static io.github.hectorvent.floci.testing.AlbFixtures.createListener;
import static io.github.hectorvent.floci.testing.AlbFixtures.createLoadBalancer;
import static io.github.hectorvent.floci.testing.AlbFixtures.createTargetGroup;
import static io.github.hectorvent.floci.testing.AlbFixtures.deleteListener;
import static io.github.hectorvent.floci.testing.AlbFixtures.deleteLoadBalancer;
import static io.github.hectorvent.floci.testing.AlbFixtures.deleteTargetGroup;
import static io.github.hectorvent.floci.testing.AlbFixtures.loadBalancerDnsName;
import static io.github.hectorvent.floci.testing.AlbFixtures.registerTarget;
import static io.restassured.RestAssured.given;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -65,10 +71,10 @@ class ElbV2PreserveHostHeaderIntegrationTest {
String targetGroupArn = null;
String listenerArn = null;
try {
loadBalancerArn = createLoadBalancer();
targetGroupArn = createTargetGroup(backend.actualPort());
registerTarget(targetGroupArn, backend.actualPort());
listenerArn = createListener(loadBalancerArn, targetGroupArn);
loadBalancerArn = createLoadBalancer("preserve-host-header-lb");
targetGroupArn = createTargetGroup("preserve-host-header-tg", "ip", backend.actualPort());
registerTarget(targetGroupArn, "127.0.0.1", backend.actualPort());
listenerArn = createListener(loadBalancerArn, targetGroupArn, LISTENER_PORT);
await().atMost(Duration.ofSeconds(3)).untilAsserted(() -> {
Response response = given().baseUri("http://127.0.0.1").port(LISTENER_PORT).get("/headers");
assertEquals(200, response.statusCode());
@@ -121,10 +127,10 @@ class ElbV2PreserveHostHeaderIntegrationTest {
String targetGroupArn = null;
String listenerArn = null;
try {
loadBalancerArn = createLoadBalancer();
targetGroupArn = createTargetGroup(backend.actualPort());
registerTarget(targetGroupArn, backend.actualPort());
listenerArn = createListener(loadBalancerArn, targetGroupArn);
loadBalancerArn = createLoadBalancer("preserve-host-header-lb");
targetGroupArn = createTargetGroup("preserve-host-header-tg", "ip", backend.actualPort());
registerTarget(targetGroupArn, "127.0.0.1", backend.actualPort());
listenerArn = createListener(loadBalancerArn, targetGroupArn, LISTENER_PORT);
assertStreamsRequestAndResponse(loadBalancerArn);
assertForwardsLargeHeaders(loadBalancerArn);
@@ -155,10 +161,11 @@ class ElbV2PreserveHostHeaderIntegrationTest {
String listenerArn = null;
int failedPort = FreePorts.anyInterfacePort();
try {
loadBalancerArn = createLoadBalancer();
targetGroupArn = createTargetGroup(backend.actualPort());
registerTargets(targetGroupArn, failedPort, backend.actualPort());
listenerArn = createListener(loadBalancerArn, targetGroupArn);
loadBalancerArn = createLoadBalancer("preserve-host-header-lb");
targetGroupArn = createTargetGroup("preserve-host-header-tg", "ip", backend.actualPort());
registerTarget(targetGroupArn, "127.0.0.1", failedPort);
registerTarget(targetGroupArn, "127.0.0.1", backend.actualPort());
listenerArn = createListener(loadBalancerArn, targetGroupArn, LISTENER_PORT);
String host = loadBalancerDnsName(loadBalancerArn);
try (Socket socket = new Socket("127.0.0.1", LISTENER_PORT)) {
@@ -282,97 +289,6 @@ class ElbV2PreserveHostHeaderIntegrationTest {
}
}
private static String createLoadBalancer() {
return given()
.formParam("Action", "CreateLoadBalancer")
.formParam("Name", "preserve-host-header-lb")
.formParam("Type", "application")
.formParam("Subnets.member.1", Ec2Service.defaultSubnetId("us-east-1", "a"))
.formParam("Subnets.member.2", Ec2Service.defaultSubnetId("us-east-1", "b"))
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(200)
.extract()
.path("CreateLoadBalancerResponse.CreateLoadBalancerResult.LoadBalancers.member.LoadBalancerArn");
}
private static String loadBalancerDnsName(String loadBalancerArn) {
return given()
.formParam("Action", "DescribeLoadBalancers")
.formParam("LoadBalancerArns.member.1", loadBalancerArn)
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(200)
.extract()
.path("DescribeLoadBalancersResponse.DescribeLoadBalancersResult.LoadBalancers.member.DNSName");
}
private static String createTargetGroup(int backendPort) {
return given()
.formParam("Action", "CreateTargetGroup")
.formParam("Name", "preserve-host-header-tg")
.formParam("Protocol", "HTTP")
.formParam("Port", backendPort)
.formParam("TargetType", "ip")
.formParam("HealthCheckEnabled", "false")
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(200)
.extract()
.path("CreateTargetGroupResponse.CreateTargetGroupResult.TargetGroups.member.TargetGroupArn");
}
private static void registerTarget(String targetGroupArn, int backendPort) {
given()
.formParam("Action", "RegisterTargets")
.formParam("TargetGroupArn", targetGroupArn)
.formParam("Targets.member.1.Id", "127.0.0.1")
.formParam("Targets.member.1.Port", backendPort)
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(200);
}
private static void registerTargets(String targetGroupArn, int failedPort, int backendPort) {
given()
.formParam("Action", "RegisterTargets")
.formParam("TargetGroupArn", targetGroupArn)
.formParam("Targets.member.1.Id", "127.0.0.1")
.formParam("Targets.member.1.Port", failedPort)
.formParam("Targets.member.2.Id", "127.0.0.1")
.formParam("Targets.member.2.Port", backendPort)
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(200);
}
private static String createListener(String loadBalancerArn, String targetGroupArn) {
return given()
.formParam("Action", "CreateListener")
.formParam("LoadBalancerArn", loadBalancerArn)
.formParam("Protocol", "HTTP")
.formParam("Port", LISTENER_PORT)
.formParam("DefaultActions.member.1.Type", "forward")
.formParam("DefaultActions.member.1.TargetGroupArn", targetGroupArn)
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(200)
.extract()
.path("CreateListenerResponse.CreateListenerResult.Listeners.member.ListenerArn");
}
private static void enableHostHeaderPreservation(String loadBalancerArn) {
given()
.formParam("Action", "ModifyLoadBalancerAttributes")
@@ -398,42 +314,4 @@ class ElbV2PreserveHostHeaderIntegrationTest {
.body(equalTo(expectedHost)));
}
private static void deleteListener(String listenerArn) {
if (listenerArn != null) {
given()
.formParam("Action", "DeleteListener")
.formParam("ListenerArn", listenerArn)
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(anyOf(equalTo(200), equalTo(204)));
}
}
private static void deleteTargetGroup(String targetGroupArn) {
if (targetGroupArn != null) {
given()
.formParam("Action", "DeleteTargetGroup")
.formParam("TargetGroupArn", targetGroupArn)
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(anyOf(equalTo(200), equalTo(204)));
}
}
private static void deleteLoadBalancer(String loadBalancerArn) {
if (loadBalancerArn != null) {
given()
.formParam("Action", "DeleteLoadBalancer")
.formParam("LoadBalancerArn", loadBalancerArn)
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(anyOf(equalTo(200), equalTo(204)));
}
}
}
@@ -1,6 +1,5 @@
package io.github.hectorvent.floci.services.elbv2;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
import io.github.hectorvent.floci.testing.RealElbV2DataPlaneProfile;
import io.github.hectorvent.floci.testutil.FreePorts;
import io.quarkus.test.junit.QuarkusTest;
@@ -19,6 +18,11 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import static io.github.hectorvent.floci.testing.AlbFixtures.createListener;
import static io.github.hectorvent.floci.testing.AlbFixtures.createLoadBalancer;
import static io.github.hectorvent.floci.testing.AlbFixtures.deleteLoadBalancer;
import static io.github.hectorvent.floci.testing.AlbFixtures.deleteTargetGroup;
import static io.github.hectorvent.floci.testing.AlbFixtures.registerTarget;
import static io.restassured.RestAssured.given;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -48,31 +52,22 @@ class ElbV2StickinessIntegrationTest {
first = backend("first");
second = backend("second");
listenerPort = FreePorts.anyInterfacePort();
loadBalancerArn = query("CreateLoadBalancer", "Name", "sticky-lb", "Type", "application",
"Subnets.member.1", Ec2Service.defaultSubnetId("us-east-1", "a"),
"Subnets.member.2", Ec2Service.defaultSubnetId("us-east-1", "b"))
.xmlPath().getString("CreateLoadBalancerResponse.CreateLoadBalancerResult.LoadBalancers.member.LoadBalancerArn");
loadBalancerArn = createLoadBalancer("sticky-lb");
targetGroupArn = query("CreateTargetGroup", "Name", "sticky-tg", "Protocol", "HTTP",
"Port", first.actualPort(), "TargetType", "ip", "HealthCheckPath", "/health",
"HealthCheckIntervalSeconds", 1, "HealthyThresholdCount", 1, "UnhealthyThresholdCount", 1)
.xmlPath().getString("CreateTargetGroupResponse.CreateTargetGroupResult.TargetGroups.member.TargetGroupArn");
query("RegisterTargets", "TargetGroupArn", targetGroupArn,
"Targets.member.1.Id", "127.0.0.1", "Targets.member.1.Port", first.actualPort(),
"Targets.member.2.Id", "127.0.0.1", "Targets.member.2.Port", second.actualPort());
query("CreateListener", "LoadBalancerArn", loadBalancerArn, "Protocol", "HTTP", "Port", listenerPort,
"DefaultActions.member.1.Type", "forward", "DefaultActions.member.1.TargetGroupArn", targetGroupArn);
registerTarget(targetGroupArn, "127.0.0.1", first.actualPort());
registerTarget(targetGroupArn, "127.0.0.1", second.actualPort());
createListener(loadBalancerArn, targetGroupArn, listenerPort);
await().atMost(Duration.ofSeconds(3)).ignoreExceptions()
.untilAsserted(() -> assertEquals(200, request(null).statusCode()));
}
@AfterEach
void cleanUp() throws Exception {
if (loadBalancerArn != null) {
query("DeleteLoadBalancer", "LoadBalancerArn", loadBalancerArn);
}
if (targetGroupArn != null) {
query("DeleteTargetGroup", "TargetGroupArn", targetGroupArn);
}
deleteLoadBalancer(loadBalancerArn);
deleteTargetGroup(targetGroupArn);
for (HttpServer backend : List.of(first, second)) {
backend.close().toCompletionStage().toCompletableFuture().get(3, TimeUnit.SECONDS);
}
@@ -38,6 +38,19 @@ public final class AlbFixtures {
.path("CreateLoadBalancerResponse.CreateLoadBalancerResult.LoadBalancers.member.LoadBalancerArn");
}
public static String loadBalancerDnsName(String loadBalancerArn) {
return given()
.formParam("Action", "DescribeLoadBalancers")
.formParam("LoadBalancerArns.member.1", loadBalancerArn)
.header("Authorization", AUTH)
.when()
.post("/")
.then()
.statusCode(200)
.extract()
.path("DescribeLoadBalancersResponse.DescribeLoadBalancersResult.LoadBalancers.member.DNSName");
}
/** An HTTP target group with health checks off, so a target serves as soon as it is registered. */
public static String createTargetGroup(String name, String targetType, int targetPort) {
return given()