diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-28 14:17:55 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-28 15:27:08 +0200 |
commit | 16cbb0e2c3a6e0083f79f7ae1a4398838489305b (patch) | |
tree | 6efe2ad7e37d95a7daafa2e668eadc65d0c1e244 /controller-server | |
parent | d4667e29011ea3b39b188438199ec9a0400b70ed (diff) |
Include Copper Argos identity for tester
Diffstat (limited to 'controller-server')
2 files changed, 32 insertions, 1 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index 50912ada819..06d713b8184 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -3,7 +3,10 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.yahoo.component.Version; +import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.AthenzDomain; +import com.yahoo.config.provision.AthenzService; import com.yahoo.config.provision.SystemName; import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; @@ -33,6 +36,7 @@ import java.io.IOException; import java.io.PrintStream; import java.io.UncheckedIOException; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.List; import java.util.Map; @@ -413,9 +417,14 @@ public class InternalStepRunner implements StepRunner { byte[] testPackage = controller.applications().applicationStore().getTesterPackage(JobController.testerOf(id.application()), version.id()); byte[] servicesXml = servicesXml(controller.system()); + DeploymentSpec spec = controller.applications().require(id.application()).deploymentSpec(); + ZoneId zone = id.type().zone(controller.system()); + byte[] deploymentXml = deploymentXml(spec.athenzDomain().get(), spec.athenzService(zone.environment(), zone.region()).get()); + try (ZipBuilder zipBuilder = new ZipBuilder(testPackage.length + servicesXml.length + 1000)) { zipBuilder.add(testPackage); zipBuilder.add("services.xml", servicesXml); + zipBuilder.add("deployment.xml", deploymentXml); zipBuilder.close(); return new ApplicationPackage(zipBuilder.toByteArray()); } @@ -435,7 +444,8 @@ public class InternalStepRunner implements StepRunner { static byte[] servicesXml(SystemName systemName) { String domain = systemName == SystemName.main ? "vespa.vespa" : "vespa.vespa.cd"; - String servicesXml = "<?xml version='1.0' encoding='UTF-8'?>\n" + + String servicesXml = + "<?xml version='1.0' encoding='UTF-8'?>\n" + "<services xmlns:deploy='vespa' version='1.0'>\n" + " <container version='1.0' id='default'>\n" + "\n" + @@ -481,6 +491,14 @@ public class InternalStepRunner implements StepRunner { return servicesXml.getBytes(); } + /** Returns a dummy deployment xml which sets up the service identity for the tester. */ + static byte[] deploymentXml(AthenzDomain domain, AthenzService service) { + String deploymentSpec = + "<?xml version='1.0' encoding='UTF-8'?>\n" + + "<deployment version=\"1.0\" athenz-domain=\"" + domain.value() + "\" athenz-service=\"" + service.value() + "\" />"; + return deploymentSpec.getBytes(StandardCharsets.UTF_8); + } + /** Returns the config for the tests to run for the given job. */ private static byte[] testConfig(ApplicationId id, ZoneId testerZone, SystemName system, Map<ZoneId, List<URI>> deployments) { Slime slime = new Slime(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java index 94309711f7a..95ba36f2cb2 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java @@ -2,7 +2,10 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.yahoo.component.Version; +import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.AthenzDomain; +import com.yahoo.config.provision.AthenzService; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.SystemName; @@ -453,4 +456,14 @@ public class InternalStepRunnerTest { } } + @Test + public void deploymentSpecIsValid() { + AthenzDomain domain = AthenzDomain.from("domain"); + AthenzService service = AthenzService.from("service"); + DeploymentSpec spec = DeploymentSpec.fromXml(new String(InternalStepRunner.deploymentXml(domain, service))); + assertEquals(domain, spec.athenzDomain().get()); + ZoneId zone = JobType.systemTest.zone(tester.controller().system()); + assertEquals(service, spec.athenzService(zone.environment(), zone.region()).get()); + } + } |