diff options
author | jonmv <venstad@gmail.com> | 2023-02-01 16:27:48 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2023-02-01 16:27:48 +0100 |
commit | 4f76988e35d72006f29db1ba16e9610d70fe4864 (patch) | |
tree | 899ee2d768f690a755971a5e60ccd1ddb0266a3b /controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java | |
parent | f6fdb2f2a5385881af69de5e760c11bc4ddae7c1 (diff) |
Run DNS challenges asynchronously, and check from job runner
Diffstat (limited to 'controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java')
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java index 2932860efaa..94cffb94184 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java @@ -26,6 +26,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.dns.Record.Type; import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordData; import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName; import com.yahoo.vespa.hosted.controller.api.integration.dns.VpcEndpointService.DnsChallenge; +import com.yahoo.vespa.hosted.controller.api.integration.dns.VpcEndpointService.State; import com.yahoo.vespa.hosted.controller.application.Endpoint; import com.yahoo.vespa.hosted.controller.application.EndpointId; import com.yahoo.vespa.hosted.controller.application.EndpointList; @@ -57,6 +58,7 @@ import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -515,39 +517,33 @@ public class RoutingPoliciesTest { void private_dns_for_vpc_endpoint() { // Challenge answered for endpoint RoutingPoliciesTester tester = new RoutingPoliciesTester(); - Map<RecordName, RecordData> challenges = new ConcurrentHashMap<>(); - tester.tester.controllerTester().serviceRegistry().vpcEndpointService().delegate = (name, cluster, account) -> { - RecordName recordName = RecordName.from("challenge--" + name.value()); - if (challenges.containsKey(recordName)) return Optional.empty(); - RecordData recordData = RecordData.from(account.map(CloudAccount::value).orElse("system")); - return Optional.of(new DnsChallenge(recordName, recordData, () -> challenges.put(recordName, recordData))); - }; + tester.tester.controllerTester().serviceRegistry().vpcEndpointService().enabled.set(true); DeploymentContext app = tester.newDeploymentContext("t", "a", "default"); ApplicationPackage appPackage = applicationPackageBuilder().region(zone3.region()).build(); app.submit(appPackage); - AtomicBoolean done = new AtomicBoolean(); - new Thread(() -> { - while ( ! done.get()) { - app.flushDnsUpdates(Integer.MAX_VALUE); - try { Thread.sleep(10); } catch (InterruptedException e) { break; } - } - }).start(); app.deploy(); - done.set(true); - - assertEquals(Map.of( RecordName.from("challenge--a.t.aws-us-east-1a.vespa.oath.cloud"), - RecordData.from("system"), - RecordName.from("challenge--a.t.us-east-1.test.vespa.oath.cloud"), - RecordData.from("system"), - RecordName.from("challenge--a.t.us-east-3.staging.vespa.oath.cloud"), - RecordData.from("system")), - challenges); + + // TXT records are cleaned up as we go—the last challenge is the last to go here, and we must flush it ourselves. + assertEquals(Set.of("a.t.aws-us-east-1a.vespa.oath.cloud", + "challenge--a.t.aws-us-east-1a.vespa.oath.cloud"), + tester.recordNames()); + app.flushDnsUpdates(); assertEquals(Set.of(new Record(Type.CNAME, RecordName.from("a.t.aws-us-east-1a.vespa.oath.cloud"), RecordData.from("lb-0--t.a.default--prod.aws-us-east-1a."))), tester.controllerTester().nameService().records()); + + + tester.tester.controllerTester().serviceRegistry().vpcEndpointService().outcomes + .put(RecordName.from("challenge--a.t.aws-us-east-1a.vespa.oath.cloud"), State.running); + + // Deployment fails because challenge is not answered (immediately). + assertEquals("Status of run 2 of production-aws-us-east-1a for t.a ==> expected: <succeeded> but was: <unfinished>", + assertThrows(AssertionError.class, + () -> app.submit(appPackage).deploy()) + .getMessage()); } @Test |