diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-11-20 18:09:57 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-12-15 12:28:56 +0100 |
commit | 499af4b68d603f1bd1d4e8094dee83ee644bcbaf (patch) | |
tree | d7acffad6b8f930bc967fc56ccfaa0126f44e176 /controller-server | |
parent | f5ba48c4110dcc3b73154c7e9c014f479b795a88 (diff) |
Construct only the relevant application package
Diffstat (limited to 'controller-server')
4 files changed, 25 insertions, 14 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java index a42dbe7fbde..ec303c069f1 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java @@ -1,6 +1,8 @@ // Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.deployment; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.AthenzDomain; @@ -73,23 +75,25 @@ import static org.junit.Assert.assertTrue; */ public class DeploymentContext { - public static final ApplicationPackage applicationPackage = new ApplicationPackageBuilder() + // Application packages are expensive to construct, and a given test typically only needs to the test in the context + // of a single system. Construct them lazily. + private static final Supplier<ApplicationPackage> applicationPackage = Suppliers.memoize(() -> new ApplicationPackageBuilder() .athenzIdentity(AthenzDomain.from("domain"), AthenzService.from("service")) .upgradePolicy("default") .region("us-central-1") .parallel("us-west-1", "us-east-3") .emailRole("author") .emailAddress("b@a") - .build(); + .build()); - public static final ApplicationPackage publicCdApplicationPackage = new ApplicationPackageBuilder() + private static final Supplier<ApplicationPackage> publicCdApplicationPackage = Suppliers.memoize(() -> new ApplicationPackageBuilder() .athenzIdentity(AthenzDomain.from("domain"), AthenzService.from("service")) .upgradePolicy("default") .region("aws-us-east-1c") .emailRole("author") .emailAddress("b@a") .trust(generateCertificate()) - .build(); + .build()); public static final SourceRevision defaultSourceRevision = new SourceRevision("repository1", "master", "commit1"); @@ -113,6 +117,14 @@ public class DeploymentContext { createTenantAndApplication(); } + public static ApplicationPackage applicationPackage() { + return applicationPackage.get(); + } + + public static ApplicationPackage publicApplicationPackage() { + return publicCdApplicationPackage.get(); + } + private void createTenantAndApplication() { try { var tenant = tester.controllerTester().createTenant(instanceId.tenant().value()); @@ -251,7 +263,7 @@ public class DeploymentContext { /** Submit the default application package for deployment */ public DeploymentContext submit() { - return submit(tester.controller().system().isPublic() ? publicCdApplicationPackage : applicationPackage); + return submit(tester.controller().system().isPublic() ? publicApplicationPackage() : applicationPackage()); } /** Trigger all outstanding jobs, if any */ 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 d54971f5b1d..9f246f44a81 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 @@ -54,7 +54,6 @@ import static com.yahoo.vespa.hosted.controller.api.integration.LogEntry.Type.er import static com.yahoo.vespa.hosted.controller.api.integration.LogEntry.Type.info; import static com.yahoo.vespa.hosted.controller.api.integration.LogEntry.Type.warning; import static com.yahoo.vespa.hosted.controller.deployment.DeploymentContext.applicationPackage; -import static com.yahoo.vespa.hosted.controller.deployment.DeploymentContext.publicCdApplicationPackage; import static com.yahoo.vespa.hosted.controller.deployment.DeploymentTester.instanceId; import static com.yahoo.vespa.hosted.controller.deployment.RunStatus.deploymentFailed; import static com.yahoo.vespa.hosted.controller.deployment.RunStatus.installationFailed; @@ -110,7 +109,7 @@ public class InternalStepRunnerTest { ConfigServerException.ErrorCode.APPLICATION_LOCK_FAILURE, new RuntimeException("Retry me")); tester.configServer().throwOnNextPrepare(exception); - tester.jobs().deploy(app.instanceId(), JobType.devUsEast1, Optional.empty(), applicationPackage); + tester.jobs().deploy(app.instanceId(), JobType.devUsEast1, Optional.empty(), applicationPackage()); assertEquals(unfinished, tester.jobs().last(app.instanceId(), JobType.devUsEast1).get().stepStatuses().get(Step.deployReal)); tester.configServer().throwOnNextPrepare(exception); @@ -346,14 +345,14 @@ public class InternalStepRunnerTest { @Test public void deployToDev() { ZoneId zone = JobType.devUsEast1.zone(system()); - tester.jobs().deploy(app.instanceId(), JobType.devUsEast1, Optional.empty(), applicationPackage); + tester.jobs().deploy(app.instanceId(), JobType.devUsEast1, Optional.empty(), applicationPackage()); tester.runner().run(); RunId id = tester.jobs().last(app.instanceId(), JobType.devUsEast1).get().id(); assertEquals(unfinished, tester.jobs().run(id).get().stepStatuses().get(Step.installReal)); Version version = new Version("7.8.9"); Future<?> concurrentDeployment = Executors.newSingleThreadExecutor().submit(() -> { - tester.jobs().deploy(app.instanceId(), JobType.devUsEast1, Optional.of(version), applicationPackage); + tester.jobs().deploy(app.instanceId(), JobType.devUsEast1, Optional.of(version), applicationPackage()); }); while ( ! concurrentDeployment.isDone()) tester.runner().run(); @@ -365,7 +364,7 @@ public class InternalStepRunnerTest { tester.runner().run(); // Job run order determined by JobType enum order per application. tester.configServer().convergeServices(app.instanceId(), zone); assertEquals(unfinished, tester.jobs().run(id).get().stepStatuses().get(Step.installReal)); - assertEquals(applicationPackage.hash(), tester.configServer().application(app.instanceId(), zone).get().applicationPackage().hash()); + assertEquals(applicationPackage().hash(), tester.configServer().application(app.instanceId(), zone).get().applicationPackage().hash()); assertEquals(otherPackage.hash(), tester.configServer().application(app.instanceId(), JobType.perfUsEast3.zone(system())).get().applicationPackage().hash()); tester.configServer().setVersion(version, app.instanceId(), zone); @@ -423,7 +422,7 @@ public class InternalStepRunnerTest { tester.configServer().bootstrap(tester.controllerTester().zoneRegistry().zones().all().ids(), SystemApplication.values()); RunId id = app.startSystemTestTests(); - List<X509Certificate> trusted = new ArrayList<>(publicCdApplicationPackage.trustedCertificates()); + List<X509Certificate> trusted = new ArrayList<>(DeploymentContext.publicApplicationPackage().trustedCertificates()); trusted.add(tester.jobs().run(id).get().testerCertificate().get()); assertEquals(trusted, tester.configServer().application(app.instanceId(), id.type().zone(system())).get().applicationPackage().trustedCertificates()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java index a6acfce877a..5efc3335089 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java @@ -629,7 +629,7 @@ public class UpgraderTest { // Dev deployment which should be ignored var dev0 = tester.newDeploymentContext("tenant1", "dev0", "default") - .runJob(devUsEast1, DeploymentContext.applicationPackage); + .runJob(devUsEast1, DeploymentContext.applicationPackage()); // New version is released and canaries upgrade version = Version.fromString("6.3"); @@ -739,7 +739,7 @@ public class UpgraderTest { // Setup applications var canary0 = tester.newDeploymentContext("tenant1", "canary0", "default").submit(version7CanaryApplicationPackage).deploy(); var default0 = tester.newDeploymentContext("tenant1", "default0", "default").submit(version7DefaultApplicationPackage).deploy(); - var default1 = tester.newDeploymentContext("tenant1", "default1", "default").submit(DeploymentContext.applicationPackage).deploy(); + var default1 = tester.newDeploymentContext("tenant1", "default1", "default").submit(DeploymentContext.applicationPackage()).deploy(); // New major version is released, but we don't want to upgrade to it yet tester.upgrader().setTargetMajorVersion(Optional.of(6)); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelperTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelperTest.java index b3ffb54b255..828e2856cae 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelperTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelperTest.java @@ -152,7 +152,7 @@ public class JobControllerApiHandlerHelperTest { tester.clock().setInstant(Instant.EPOCH); ZoneId zone = JobType.devUsEast1.zone(tester.controller().system()); - tester.jobs().deploy(app.instanceId(), JobType.devUsEast1, Optional.empty(), applicationPackage); + tester.jobs().deploy(app.instanceId(), JobType.devUsEast1, Optional.empty(), applicationPackage()); tester.configServer().setLogStream("1554970337.935104\t17491290-v6-1.ostk.bm2.prod.ne1.yahoo.com\t5480\tcontainer\tstdout\tinfo\tERROR: Bundle canary-application [71] Unable to get module class path. (java.lang.NullPointerException)\n"); assertResponse(JobControllerApiHandlerHelper.runDetailsResponse(tester.jobs(), tester.jobs().last(app.instanceId(), devUsEast1).get().id(), null), "dev-us-east-1-log-first-part.json"); |