refactor(elbv2): compare DescribeTargetHealth's targets through sameTarget (#8246)

DescribeTargetHealth checked a Targets filter against the registered
targets by comparing the Id and effective port itself. It now uses
ElbV2HealthChecker.sameTarget, as RegisterTargets and DeregisterTargets
do since #8199, so all three tell registrations apart the same way.
No behaviour change.
This commit is contained in:
Suja Shaj authored and GitHub committed 2026-11-13 22:29:53 -04:00
1 parent 3e02ff995f
commit 55a7d95146
2 files changed
+18 -4

No files matched your search

@@ -1075,6 +1075,21 @@ class ElbV2ServiceTest {
assertEquals("Target is not registered to the target group", health.getDescription());
}
@Test
void describeTargetHealthMatchesAFilterTargetWithoutPortOnTheGroupPort() {
String tgArn = createTargetGroup("filter-default-port-tg");
service.registerTargets(REGION, tgArn, List.of(target("i-default", 9999)));
when(healthChecker.getHealth(tgArn, "i-default", 9999))
.thenReturn(new ElbV2HealthChecker.TargetHealthStatus("healthy", null, null));
TargetHealth health = service.describeTargetHealth(
REGION, tgArn, List.of(target("i-default", null))).getFirst();
assertEquals("healthy", health.getState());
assertNull(health.getReason());
assertEquals("9999", health.getHealthCheckPort());
}
@Test
void registerTargetsRejectsLinkLocalAndMetadataAddresses() {
String tgArn = createTargetGroup("metadata-tg");