diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-09-18 13:20:21 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-09-18 16:39:10 +0200 |
commit | a64c2bec5539a200769a973702ba6543ae621837 (patch) | |
tree | 0fd86ab8d14cca25018f2a5218becd47f413c61c /controller-server/src/test | |
parent | b6a52c8fda45d7d3f45a8606b419b5f4becfbaed (diff) |
Rename Application -> Instance
Diffstat (limited to 'controller-server/src/test')
22 files changed, 624 insertions, 624 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index d1b8fc183d2..b427ebb730e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -82,7 +82,7 @@ public class ControllerTest { // staging job - succeeding Version version1 = tester.defaultPlatformVersion(); - Application app1 = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app1 = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app1).uploadArtifact(applicationPackage).submit(); assertEquals("Application version is known from completion of initial job", ApplicationVersion.from(BuildJob.defaultSourceRevision, BuildJob.defaultBuildNumber), @@ -211,7 +211,7 @@ public class ControllerTest { @Test public void testDeploymentApplicationVersion() { - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") @@ -279,7 +279,7 @@ public class ControllerTest { @Test public void testDnsAliasRegistration() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -288,14 +288,14 @@ public class ControllerTest { .region("us-central-1") // Two deployments should result in each DNS alias being registered once .build(); - tester.deployCompletely(application, applicationPackage); - Collection<Deployment> deployments = tester.application(application.id()).deployments().values(); + tester.deployCompletely(instance, applicationPackage); + Collection<Deployment> deployments = tester.application(instance.id()).deployments().values(); assertFalse(deployments.isEmpty()); for (Deployment deployment : deployments) { assertEquals("Rotation names are passed to config server in " + deployment.zone(), Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), deployment.zone()))); + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), deployment.zone()))); } tester.flushDnsRequests(); @@ -309,7 +309,7 @@ public class ControllerTest { @Test public void testDnsAliasRegistrationLegacy() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -318,8 +318,8 @@ public class ControllerTest { .region("us-central-1") // Two deployments should result in each DNS alias being registered once .build(); - tester.deployCompletely(application, applicationPackage); - Collection<Deployment> deployments = tester.application(application.id()).deployments().values(); + tester.deployCompletely(instance, applicationPackage); + Collection<Deployment> deployments = tester.application(instance.id()).deployments().values(); assertFalse(deployments.isEmpty()); for (Deployment deployment : deployments) { assertEquals("Rotation names are passed to config server in " + deployment.zone(), @@ -327,7 +327,7 @@ public class ControllerTest { "app1--tenant1.global.vespa.oath.cloud", "app1.tenant1.global.vespa.yahooapis.com", "app1--tenant1.global.vespa.yahooapis.com"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), deployment.zone()))); + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), deployment.zone()))); } tester.flushDnsRequests(); assertEquals(3, tester.controllerTester().nameService().records().size()); @@ -350,7 +350,7 @@ public class ControllerTest { @Test public void testDnsAliasRegistrationWithEndpoints() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -362,8 +362,8 @@ public class ControllerTest { .region("us-central-1") .build(); - tester.deployCompletely(application, applicationPackage); - Collection<Deployment> deployments = tester.application(application.id()).deployments().values(); + tester.deployCompletely(instance, applicationPackage); + Collection<Deployment> deployments = tester.application(instance.id()).deployments().values(); assertFalse(deployments.isEmpty()); var notWest = Set.of( @@ -376,7 +376,7 @@ public class ControllerTest { for (Deployment deployment : deployments) { assertEquals("Rotation names are passed to config server in " + deployment.zone(), ZoneId.from("prod.us-west-1").equals(deployment.zone()) ? west : notWest, - tester.configServer().rotationNames().get(new DeploymentId(application.id(), deployment.zone()))); + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), deployment.zone()))); } tester.flushDnsRequests(); @@ -405,7 +405,7 @@ public class ControllerTest { @Test public void testDnsAliasRegistrationWithChangingZones() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -414,16 +414,16 @@ public class ControllerTest { .region("us-central-1") .build(); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); assertEquals( Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-west-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-west-1"))) ); assertEquals( Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-central-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-central-1"))) ); @@ -434,24 +434,24 @@ public class ControllerTest { .region("us-central-1") .build(); - tester.deployCompletely(application, applicationPackage2, BuildJob.defaultBuildNumber + 1); + tester.deployCompletely(instance, applicationPackage2, BuildJob.defaultBuildNumber + 1); assertEquals( Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-west-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-west-1"))) ); assertEquals( Set.of(), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-central-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-central-1"))) ); - assertEquals(Set.of(RegionName.from("us-west-1")), tester.application(application.id()).rotations().get(0).regions()); + assertEquals(Set.of(RegionName.from("us-west-1")), tester.application(instance.id()).rotations().get(0).regions()); } @Test public void testUnassignRotations() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -460,7 +460,7 @@ public class ControllerTest { .region("us-central-1") // Two deployments should result in each DNS alias being registered once .build(); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); ApplicationPackage applicationPackage2 = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -468,17 +468,17 @@ public class ControllerTest { .region("us-central-1") // Two deployments should result in each DNS alias being registered once .build(); - tester.deployCompletely(application, applicationPackage2, BuildJob.defaultBuildNumber + 1); + tester.deployCompletely(instance, applicationPackage2, BuildJob.defaultBuildNumber + 1); assertEquals( List.of(AssignedRotation.fromStrings("qrs", "default", "rotation-id-01", Set.of())), - tester.application(application.id()).rotations() + tester.application(instance.id()).rotations() ); assertEquals( Set.of(), - tester.configServer().rotationNames().get(new DeploymentId(application.id(), ZoneId.from("prod", "us-west-1"))) + tester.configServer().rotationNames().get(new DeploymentId(instance.id(), ZoneId.from("prod", "us-west-1"))) ); } @@ -486,7 +486,7 @@ public class ControllerTest { public void testUpdatesExistingDnsAlias() { // Application 1 is deployed and deleted { - Application app1 = tester.createApplication("app1", "tenant1", 1, 1L); + Instance app1 = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .endpoint("default", "foo") @@ -532,7 +532,7 @@ public class ControllerTest { // Application 2 is deployed and assigned same rotation as application 1 had before deletion { - Application app2 = tester.createApplication("app2", "tenant2", 2, 1L); + Instance app2 = tester.createApplication("app2", "tenant2", 2, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .endpoint("default", "foo") @@ -551,7 +551,7 @@ public class ControllerTest { // Application 1 is recreated, deployed and assigned a new rotation { tester.buildService().clear(); - Application app1 = tester.createApplication("app1", "tenant1", 1, 1L); + Instance app1 = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .endpoint("default", "foo") @@ -589,7 +589,7 @@ public class ControllerTest { .build(); // Create application - Application app = tester.createApplication("app1", "tenant1", 1, 2L); + Instance app = tester.createApplication("app1", "tenant1", 1, 2L); // Direct deploy is allowed when deployDirectly is true ZoneId zone = ZoneId.from("prod", "cd-us-central-1"); @@ -619,7 +619,7 @@ public class ControllerTest { .build(); // Create application - Application app = tester.createApplication("app1", "tenant1", 1, 2L); + Instance app = tester.createApplication("app1", "tenant1", 1, 2L); ZoneId zone = ZoneId.from("dev", "us-east-1"); // Deploy @@ -633,7 +633,7 @@ public class ControllerTest { @Test public void testSuspension() { - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") @@ -657,7 +657,7 @@ public class ControllerTest { // second time will not fail @Test public void testDeletingApplicationThatHasAlreadyBeenDeleted() { - Application app = tester.createApplication("app2", "tenant1", 1, 12L); + Instance app = tester.createApplication("app2", "tenant1", 1, 12L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-east-3") @@ -672,33 +672,33 @@ public class ControllerTest { @Test public void testDeployApplicationPackageWithApplicationDir() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") .build(true); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); } @Test public void testDeployApplicationWithWarnings() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") .build(); ZoneId zone = ZoneId.from("prod", "us-west-1"); int warnings = 3; - tester.configServer().generateWarnings(new DeploymentId(application.id(), zone), warnings); - tester.deployCompletely(application, applicationPackage); - assertEquals(warnings, tester.applications().require(application.id()).deployments().get(zone) + tester.configServer().generateWarnings(new DeploymentId(instance.id(), zone), warnings); + tester.deployCompletely(instance, applicationPackage); + assertEquals(warnings, tester.applications().require(instance.id()).deployments().get(zone) .metrics().warnings().get(DeploymentMetrics.Warning.all).intValue()); } @Test public void testDeploySelectivelyProvisionsCertificate() { ((InMemoryFlagSource) tester.controller().flagSource()).withBooleanFlag(Flags.PROVISION_APPLICATION_CERTIFICATE.id(), true); - Function<Application, Optional<ApplicationCertificate>> certificate = (application) -> tester.controller().curator().readApplicationCertificate(application.id()); + Function<Instance, Optional<ApplicationCertificate>> certificate = (application) -> tester.controller().curator().readApplicationCertificate(application.id()); // Create app1 var app1 = tester.createApplication("app1", "tenant1", 1, 2L); @@ -780,7 +780,7 @@ public class ControllerTest { private void runDeployment(DeploymentTester tester, ApplicationId application, ApplicationVersion version, ApplicationPackage applicationPackage, SourceRevision sourceRevision, long buildNumber) { - Application app = tester.applications().require(application); + Instance app = tester.applications().require(application); tester.jobCompletion(component) .application(app) .buildNumber(buildNumber) @@ -796,13 +796,13 @@ public class ControllerTest { } private void assertStatus(JobStatus expectedStatus, ApplicationId id, Controller controller) { - Application app = controller.applications().get(id).get(); + Instance app = controller.applications().get(id).get(); JobStatus existingStatus = app.deploymentJobs().jobStatus().get(expectedStatus.type()); assertNotNull("Status of type " + expectedStatus.type() + " is present", existingStatus); assertEquals(expectedStatus, existingStatus); } - private void runDeployment(DeploymentTester tester, Application app, ApplicationVersion version, + private void runDeployment(DeploymentTester tester, Instance app, ApplicationVersion version, Optional<Version> upgrade, Optional<ApplicationPackage> applicationPackage) { Version vespaVersion = upgrade.orElseGet(tester::defaultPlatformVersion); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java index a4e07bd74e8..52a8f5f5e27 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java @@ -126,8 +126,8 @@ public final class ControllerTester { .ifPresent(configureFunc); } - public static BuildService.BuildJob buildJob(Application application, JobType jobType) { - return BuildService.BuildJob.of(application.id(), application.deploymentJobs().projectId().getAsLong(), jobType.jobName()); + public static BuildService.BuildJob buildJob(Instance instance, JobType jobType) { + return BuildService.BuildJob.of(instance.id(), instance.deploymentJobs().projectId().getAsLong(), jobType.jobName()); } public Controller controller() { return controller; } @@ -157,37 +157,37 @@ public final class ControllerTester { } /** Creates the given tenant and application and deploys it */ - public Application createAndDeploy(String tenantName, String domainName, String applicationName, Environment environment, long projectId, Long propertyId) { + public Instance createAndDeploy(String tenantName, String domainName, String applicationName, Environment environment, long projectId, Long propertyId) { return createAndDeploy(tenantName, domainName, applicationName, toZone(environment), projectId, propertyId); } /** Creates the given tenant and application and deploys it */ - public Application createAndDeploy(String tenantName, String domainName, String applicationName, - String instanceName, ZoneId zone, long projectId, Long propertyId) { + public Instance createAndDeploy(String tenantName, String domainName, String applicationName, + String instanceName, ZoneId zone, long projectId, Long propertyId) { TenantName tenant = createTenant(tenantName, domainName, propertyId); - Application application = createApplication(tenant, applicationName, instanceName, projectId); - deploy(application, zone); - return application; + Instance instance = createApplication(tenant, applicationName, instanceName, projectId); + deploy(instance, zone); + return instance; } /** Creates the given tenant and application and deploys it */ - public Application createAndDeploy(String tenantName, String domainName, String applicationName, ZoneId zone, long projectId, Long propertyId) { + public Instance createAndDeploy(String tenantName, String domainName, String applicationName, ZoneId zone, long projectId, Long propertyId) { return createAndDeploy(tenantName, domainName, applicationName, "default", zone, projectId, propertyId); } /** Creates the given tenant and application and deploys it */ - public Application createAndDeploy(String tenantName, String domainName, String applicationName, Environment environment, long projectId) { + public Instance createAndDeploy(String tenantName, String domainName, String applicationName, Environment environment, long projectId) { return createAndDeploy(tenantName, domainName, applicationName, environment, projectId, null); } /** Create application from slime */ - public Application createApplication(Slime slime) { + public Instance createApplication(Slime slime) { ApplicationSerializer serializer = new ApplicationSerializer(); - Application application = serializer.fromSlime(slime); - try (Lock lock = controller().applications().lock(application.id())) { - controller().applications().store(new LockedApplication(application, lock)); + Instance instance = serializer.fromSlime(slime); + try (Lock lock = controller().applications().lock(instance.id())) { + controller().applications().store(new LockedApplication(instance, lock)); } - return application; + return instance; } public ZoneId toZone(Environment environment) { @@ -241,7 +241,7 @@ public final class ControllerTester { new OktaAccessToken("okta-token"))); } - public Application createApplication(TenantName tenant, String applicationName, String instanceName, long projectId) { + public Instance createApplication(TenantName tenant, String applicationName, String instanceName, long projectId) { ApplicationId applicationId = ApplicationId.from(tenant.value(), applicationName, instanceName); controller().applications().createApplication(applicationId, credentialsFor(applicationId)); controller().applications().lockOrThrow(applicationId, lockedApplication -> @@ -249,36 +249,36 @@ public final class ControllerTester { return controller().applications().require(applicationId); } - public void deploy(Application application, ZoneId zone) { - deploy(application, zone, new ApplicationPackage(new byte[0])); + public void deploy(Instance instance, ZoneId zone) { + deploy(instance, zone, new ApplicationPackage(new byte[0])); } - public void deploy(Application application, ZoneId zone, ApplicationPackage applicationPackage) { - deploy(application, zone, applicationPackage, false); + public void deploy(Instance instance, ZoneId zone, ApplicationPackage applicationPackage) { + deploy(instance, zone, applicationPackage, false); } - public void deploy(Application application, ZoneId zone, ApplicationPackage applicationPackage, boolean deployCurrentVersion) { - deploy(application, zone, Optional.of(applicationPackage), deployCurrentVersion); + public void deploy(Instance instance, ZoneId zone, ApplicationPackage applicationPackage, boolean deployCurrentVersion) { + deploy(instance, zone, Optional.of(applicationPackage), deployCurrentVersion); } - public void deploy(Application application, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion) { - deploy(application, zone, applicationPackage, deployCurrentVersion, Optional.empty()); + public void deploy(Instance instance, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion) { + deploy(instance, zone, applicationPackage, deployCurrentVersion, Optional.empty()); } - public void deploy(Application application, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion, Optional<Version> version) { - controller().applications().deploy(application.id(), + public void deploy(Instance instance, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion, Optional<Version> version) { + controller().applications().deploy(instance.id(), zone, applicationPackage, new DeployOptions(false, version, false, deployCurrentVersion)); } - public Supplier<Application> application(ApplicationId application) { + public Supplier<Instance> application(ApplicationId application) { return () -> controller().applications().require(application); } /** Used by ApplicationSerializerTest to avoid breaking encapsulation. Should not be used by anything else */ - public static LockedApplication writable(Application application) { - return new LockedApplication(application, new Lock("/test", new MockCurator())); + public static LockedApplication writable(Instance instance) { + return new LockedApplication(instance, new Lock("/test", new MockCurator())); } private static Controller createController(CuratorDb curator, RotationsConfig rotationsConfig, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java index afe4a1dba1f..7b2aba296a4 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision; @@ -51,10 +51,10 @@ public class BuildJob { return this; } - public BuildJob application(Application application) { - this.applicationId = application.id(); - if (application.deploymentJobs().projectId().isPresent()) { - this.projectId = application.deploymentJobs().projectId().getAsLong(); + public BuildJob application(Instance instance) { + this.applicationId = instance.id(); + if (instance.deploymentJobs().projectId().isPresent()) { + this.projectId = instance.deploymentJobs().projectId().getAsLong(); } return this; } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java index cc5e22d775b..02b45b77769 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java @@ -7,7 +7,7 @@ import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.zone.ZoneApi; import com.yahoo.test.ManualClock; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.ControllerTester; @@ -112,11 +112,11 @@ public class DeploymentTester { public ConfigServerMock configServer() { return tester.serviceRegistry().configServerMock(); } - public Application application(String name) { + public Instance application(String name) { return application(ApplicationId.from("tenant1", name, "default")); } - public Application application(ApplicationId application) { + public Instance application(ApplicationId application) { return controller().applications().require(application); } @@ -169,11 +169,11 @@ public class DeploymentTester { return configServer().initialVersion(); } - public Application createApplication(String applicationName, String tenantName, long projectId, long propertyId) { + public Instance createApplication(String applicationName, String tenantName, long projectId, long propertyId) { return createApplication("default", applicationName, tenantName, projectId, propertyId); } - public Application createApplication(String instanceName, String applicationName, String tenantName, long projectId, long propertyId) { + public Instance createApplication(String instanceName, String applicationName, String tenantName, long projectId, long propertyId) { TenantName tenant = tester.createTenant(tenantName, UUID.randomUUID().toString(), propertyId); return tester.createApplication(tenant, applicationName, instanceName, projectId); } @@ -191,134 +191,134 @@ public class DeploymentTester { } /** Simulate the full lifecycle of an application deployment as declared in given application package */ - public Application createAndDeploy(String applicationName, int projectId, ApplicationPackage applicationPackage) { + public Instance createAndDeploy(String applicationName, int projectId, ApplicationPackage applicationPackage) { TenantName tenant = tester.createTenant("tenant1", "domain1", 1L); return createAndDeploy(tenant, applicationName, projectId, applicationPackage); } /** Simulate the full lifecycle of an application deployment as declared in given application package */ - public Application createAndDeploy(TenantName tenant, String applicationName, int projectId, ApplicationPackage applicationPackage) { - Application application = tester.createApplication(tenant, applicationName, "default", projectId); - deployCompletely(application, applicationPackage); - return applications().require(application.id()); + public Instance createAndDeploy(TenantName tenant, String applicationName, int projectId, ApplicationPackage applicationPackage) { + Instance instance = tester.createApplication(tenant, applicationName, "default", projectId); + deployCompletely(instance, applicationPackage); + return applications().require(instance.id()); } /** Simulate the full lifecycle of an application deployment to prod.us-west-1 with the given upgrade policy */ - public Application createAndDeploy(String applicationName, int projectId, String upgradePolicy) { + public Instance createAndDeploy(String applicationName, int projectId, String upgradePolicy) { return createAndDeploy(applicationName, projectId, applicationPackage(upgradePolicy)); } /** Simulate the full lifecycle of an application deployment to prod.us-west-1 with the given upgrade policy */ - public Application createAndDeploy(TenantName tenant, String applicationName, int projectId, String upgradePolicy) { + public Instance createAndDeploy(TenantName tenant, String applicationName, int projectId, String upgradePolicy) { return createAndDeploy(tenant, applicationName, projectId, applicationPackage(upgradePolicy)); } /** Deploy application completely using the given application package */ - public void deployCompletely(Application application, ApplicationPackage applicationPackage) { - deployCompletely(application, applicationPackage, BuildJob.defaultBuildNumber); + public void deployCompletely(Instance instance, ApplicationPackage applicationPackage) { + deployCompletely(instance, applicationPackage, BuildJob.defaultBuildNumber); } - public void completeDeploymentWithError(Application application, ApplicationPackage applicationPackage, long buildNumber, JobType failOnJob) { - jobCompletion(JobType.component).application(application) + public void completeDeploymentWithError(Instance instance, ApplicationPackage applicationPackage, long buildNumber, JobType failOnJob) { + jobCompletion(JobType.component).application(instance) .buildNumber(buildNumber) .uploadArtifact(applicationPackage) .submit(); - completeDeployment(application, applicationPackage, Optional.ofNullable(failOnJob)); + completeDeployment(instance, applicationPackage, Optional.ofNullable(failOnJob)); } - public void deployCompletely(Application application, ApplicationPackage applicationPackage, long buildNumber) { - completeDeploymentWithError(application, applicationPackage, buildNumber, null); + public void deployCompletely(Instance instance, ApplicationPackage applicationPackage, long buildNumber) { + completeDeploymentWithError(instance, applicationPackage, buildNumber, null); } - private void completeDeployment(Application application, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) { - assertTrue(application.id() + " has pending changes to deploy", applications().require(application.id()).change().hasTargets()); + private void completeDeployment(Instance instance, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) { + assertTrue(instance.id() + " has pending changes to deploy", applications().require(instance.id()).change().hasTargets()); DeploymentSteps steps = controller().applications().deploymentTrigger().steps(applicationPackage.deploymentSpec()); List<JobType> jobs = steps.jobs(); for (JobType job : jobs) { boolean failJob = failOnJob.map(j -> j.equals(job)).orElse(false); - deployAndNotify(application, applicationPackage, ! failJob, job); + deployAndNotify(instance, applicationPackage, ! failJob, job); if (failJob) { break; } } if (failOnJob.isPresent()) { - assertTrue(applications().require(application.id()).change().hasTargets()); - assertTrue(applications().require(application.id()).deploymentJobs().hasFailures()); + assertTrue(applications().require(instance.id()).change().hasTargets()); + assertTrue(applications().require(instance.id()).deploymentJobs().hasFailures()); } else { - assertFalse(applications().require(application.id()).change().hasTargets()); + assertFalse(applications().require(instance.id()).change().hasTargets()); } if (updateDnsAutomatically) { flushDnsRequests(); } } - public void completeUpgrade(Application application, Version version, String upgradePolicy) { - completeUpgrade(application, version, applicationPackage(upgradePolicy)); + public void completeUpgrade(Instance instance, Version version, String upgradePolicy) { + completeUpgrade(instance, version, applicationPackage(upgradePolicy)); } - public void completeUpgrade(Application application, Version version, ApplicationPackage applicationPackage) { - assertTrue(application + " has a change", applications().require(application.id()).change().hasTargets()); - assertEquals(Change.of(version), applications().require(application.id()).change()); - completeDeployment(application, applicationPackage, Optional.empty()); + public void completeUpgrade(Instance instance, Version version, ApplicationPackage applicationPackage) { + assertTrue(instance + " has a change", applications().require(instance.id()).change().hasTargets()); + assertEquals(Change.of(version), applications().require(instance.id()).change()); + completeDeployment(instance, applicationPackage, Optional.empty()); } - public void completeUpgradeWithError(Application application, Version version, String upgradePolicy, JobType failOnJob) { - completeUpgradeWithError(application, version, applicationPackage(upgradePolicy), Optional.of(failOnJob)); + public void completeUpgradeWithError(Instance instance, Version version, String upgradePolicy, JobType failOnJob) { + completeUpgradeWithError(instance, version, applicationPackage(upgradePolicy), Optional.of(failOnJob)); } - public void completeUpgradeWithError(Application application, Version version, ApplicationPackage applicationPackage, JobType failOnJob) { - completeUpgradeWithError(application, version, applicationPackage, Optional.of(failOnJob)); + public void completeUpgradeWithError(Instance instance, Version version, ApplicationPackage applicationPackage, JobType failOnJob) { + completeUpgradeWithError(instance, version, applicationPackage, Optional.of(failOnJob)); } - private void completeUpgradeWithError(Application application, Version version, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) { - assertTrue(applications().require(application.id()).change().hasTargets()); - assertEquals(Change.of(version), applications().require(application.id()).change()); - completeDeployment(application, applicationPackage, failOnJob); + private void completeUpgradeWithError(Instance instance, Version version, ApplicationPackage applicationPackage, Optional<JobType> failOnJob) { + assertTrue(applications().require(instance.id()).change().hasTargets()); + assertEquals(Change.of(version), applications().require(instance.id()).change()); + completeDeployment(instance, applicationPackage, failOnJob); } - public void deploy(JobType job, Application application, ApplicationPackage applicationPackage) { - deploy(job, application, Optional.of(applicationPackage), false); + public void deploy(JobType job, Instance instance, ApplicationPackage applicationPackage) { + deploy(job, instance, Optional.of(applicationPackage), false); } - public void deploy(JobType job, Application application, ApplicationPackage applicationPackage, + public void deploy(JobType job, Instance instance, ApplicationPackage applicationPackage, boolean deployCurrentVersion) { - deploy(job, application, Optional.of(applicationPackage), deployCurrentVersion); + deploy(job, instance, Optional.of(applicationPackage), deployCurrentVersion); } - public void deploy(JobType job, Application application, Optional<ApplicationPackage> applicationPackage, + public void deploy(JobType job, Instance instance, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion) { - tester.deploy(application, job.zone(controller().system()), applicationPackage, deployCurrentVersion); + tester.deploy(instance, job.zone(controller().system()), applicationPackage, deployCurrentVersion); } - public void deployAndNotify(Application application, String upgradePolicy, boolean success, JobType job) { - deployAndNotify(application, applicationPackage(upgradePolicy), success, job); + public void deployAndNotify(Instance instance, String upgradePolicy, boolean success, JobType job) { + deployAndNotify(instance, applicationPackage(upgradePolicy), success, job); } - public void deployAndNotify(Application application, ApplicationPackage applicationPackage, boolean success, JobType job) { - deployAndNotify(application, Optional.of(applicationPackage), success, job); + public void deployAndNotify(Instance instance, ApplicationPackage applicationPackage, boolean success, JobType job) { + deployAndNotify(instance, Optional.of(applicationPackage), success, job); } - public void deployAndNotify(Application application, boolean success, JobType job) { - deployAndNotify(application, Optional.empty(), success, job); + public void deployAndNotify(Instance instance, boolean success, JobType job) { + deployAndNotify(instance, Optional.empty(), success, job); } - public void deployAndNotify(Application application, Optional<ApplicationPackage> applicationPackage, boolean success, JobType job) { + public void deployAndNotify(Instance instance, Optional<ApplicationPackage> applicationPackage, boolean success, JobType job) { if (success) { // Staging deploys twice, once with current version and once with new version if (job == JobType.stagingTest) { - deploy(job, application, applicationPackage, true); + deploy(job, instance, applicationPackage, true); } - deploy(job, application, applicationPackage, false); + deploy(job, instance, applicationPackage, false); } // Deactivate test deployments after deploy. This replicates the behaviour of the tenant pipeline if (job.isTest()) { - controller().applications().deactivate(application.id(), job.zone(controller().system())); + controller().applications().deactivate(instance.id(), job.zone(controller().system())); } - jobCompletion(job).application(application).success(success).submit(); + jobCompletion(job).application(instance).success(success).submit(); } - public Optional<JobStatus.JobRun> firstFailing(Application application, JobType job) { - return tester.controller().applications().require(application.id()) + public Optional<JobStatus.JobRun> firstFailing(Instance instance, JobType job) { + return tester.controller().applications().require(instance.id()) .deploymentJobs().jobStatus().get(job).firstFailing(); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java index f8e7026d9d5..7cb520f0fd9 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java @@ -7,7 +7,7 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.SlimeUtils; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.BuildService; @@ -68,7 +68,7 @@ public class DeploymentTriggerTest { @Test public void testTriggerFailing() { - Application app = tester.createApplication("app1", "tenant1", 1, 1L); + Instance app = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .upgradePolicy("default") .environment(Environment.prod) @@ -109,8 +109,8 @@ public class DeploymentTriggerTest { @Test public void testIndependentInstances() { - Application instance1 = tester.createApplication("instance1", "app", "tenant", 1, 1L); - Application instance2 = tester.createApplication("instance2", "app", "tenant", 2, 1L); + Instance instance1 = tester.createApplication("instance1", "app", "tenant", 1, 1L); + Instance instance2 = tester.createApplication("instance2", "app", "tenant", 2, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .upgradePolicy("default") .environment(Environment.prod) @@ -152,7 +152,7 @@ public class DeploymentTriggerTest { InternalDeploymentTester iTester = new InternalDeploymentTester(); DeploymentTester tester = iTester.tester(); - Application app = iTester.app(); + Instance app = iTester.app(); ApplicationPackage applicationPackage = InternalDeploymentTester.applicationPackage; tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); @@ -213,7 +213,7 @@ public class DeploymentTriggerTest { public void deploymentSpecDecidesTriggerOrder() { TenantName tenant = tester.controllerTester().createTenant("tenant1", "domain1", 1L); MockBuildService mockBuildService = tester.buildService(); - Application application = tester.controllerTester().createApplication(tenant, "app1", "default", 1L); + Instance instance = tester.controllerTester().createApplication(tenant, "app1", "default", 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-east-3") @@ -222,21 +222,21 @@ public class DeploymentTriggerTest { .build(); // Component job finishes - tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).uploadArtifact(applicationPackage).submit(); // Application is deployed to all test environments and declared zones - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsEast3); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsWest1); assertTrue("All jobs consumed", mockBuildService.jobs().isEmpty()); } @Test public void deploymentsSpecWithDelays() { MockBuildService mockBuildService = tester.buildService(); - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -249,11 +249,11 @@ public class DeploymentTriggerTest { .build(); // Component job finishes - tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).uploadArtifact(applicationPackage).submit(); // Test jobs pass - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); tester.deploymentTrigger().triggerReadyJobs(); // No jobs have started yet, as 30 seconds have not yet passed. @@ -263,16 +263,16 @@ public class DeploymentTriggerTest { // 30 seconds later, the first jobs may trigger. assertEquals(1, mockBuildService.jobs().size()); - tester.assertRunning(productionUsWest1, application.id()); + tester.assertRunning(productionUsWest1, instance.id()); // 3 minutes pass, delayed trigger does nothing as us-west-1 is still in progress tester.clock().advance(Duration.ofMinutes(3)); tester.deploymentTrigger().triggerReadyJobs(); assertEquals(1, mockBuildService.jobs().size()); - tester.assertRunning(productionUsWest1, application.id()); + tester.assertRunning(productionUsWest1, instance.id()); // us-west-1 completes - tester.deployAndNotify(application, applicationPackage, true, productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, productionUsWest1); // Delayed trigger does nothing as not enough time has passed after us-west-1 completion tester.deploymentTrigger().triggerReadyJobs(); @@ -286,7 +286,7 @@ public class DeploymentTriggerTest { // 4 minutes pass, us-central-1 is triggered tester.clock().advance(Duration.ofMinutes(1)); tester.deploymentTrigger().triggerReadyJobs(); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); assertTrue("All jobs consumed", mockBuildService.jobs().isEmpty()); // Delayed trigger job runs again, with nothing to trigger @@ -297,7 +297,7 @@ public class DeploymentTriggerTest { @Test public void deploymentSpecWithParallelDeployments() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) @@ -307,75 +307,75 @@ public class DeploymentTriggerTest { .build(); // Component job finishes - tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).uploadArtifact(applicationPackage).submit(); // Test jobs pass - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); // Deploys in first region assertEquals(1, tester.buildService().jobs().size()); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); // Deploys in two regions in parallel assertEquals(2, tester.buildService().jobs().size()); - tester.assertRunning(productionUsEast3, application.id()); - tester.assertRunning(productionUsWest1, application.id()); + tester.assertRunning(productionUsEast3, instance.id()); + tester.assertRunning(productionUsWest1, instance.id()); - tester.deploy(JobType.productionUsWest1, application, applicationPackage, false); - tester.jobCompletion(JobType.productionUsWest1).application(application).submit(); + tester.deploy(JobType.productionUsWest1, instance, applicationPackage, false); + tester.jobCompletion(JobType.productionUsWest1).application(instance).submit(); assertEquals("One job still running.", JobType.productionUsEast3.jobName(), tester.buildService().jobs().get(0).jobName()); - tester.deploy(JobType.productionUsEast3, application, applicationPackage, false); - tester.jobCompletion(JobType.productionUsEast3).application(application).submit(); + tester.deploy(JobType.productionUsEast3, instance, applicationPackage, false); + tester.jobCompletion(JobType.productionUsEast3).application(instance).submit(); // Last region completes assertEquals(1, tester.buildService().jobs().size()); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionEuWest1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionEuWest1); assertTrue("All jobs consumed", tester.buildService().jobs().isEmpty()); } @Test public void testNoOtherChangesDuringSuspension() { // Application is deployed in 3 regions: - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") .parallel("us-west-1", "us-east-3") .build(); tester.jobCompletion(component) - .application(application) + .application(instance) .uploadArtifact(applicationPackage) .submit(); - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsWest1); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsEast3); // The first production zone is suspended: - tester.configServer().setSuspended(new DeploymentId(application.id(), JobType.productionUsCentral1.zone(tester.controller().system())), true); + tester.configServer().setSuspended(new DeploymentId(instance.id(), JobType.productionUsCentral1.zone(tester.controller().system())), true); // A new change needs to be pushed out, but should not go beyond the suspended zone: tester.jobCompletion(component) - .application(application) + .application(instance) .nextBuildNumber() .sourceRevision(new SourceRevision("repository1", "master", "cafed00d")) .uploadArtifact(applicationPackage) .submit(); - tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.systemTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsCentral1); tester.triggerUntilQuiescence(); - tester.assertNotRunning(JobType.productionUsEast3, application.id()); - tester.assertNotRunning(JobType.productionUsWest1, application.id()); + tester.assertNotRunning(JobType.productionUsEast3, instance.id()); + tester.assertNotRunning(JobType.productionUsWest1, instance.id()); // The zone is unsuspended so jobs start: - tester.configServer().setSuspended(new DeploymentId(application.id(), JobType.productionUsCentral1.zone(tester.controller().system())), false); + tester.configServer().setSuspended(new DeploymentId(instance.id(), JobType.productionUsCentral1.zone(tester.controller().system())), false); tester.triggerUntilQuiescence(); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsWest1); - tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, JobType.productionUsEast3); } @Test @@ -385,7 +385,7 @@ public class DeploymentTriggerTest { .parallel("us-east-3", "us-west-1") .build(); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); // Test environments pass @@ -409,7 +409,7 @@ public class DeploymentTriggerTest { public void testSuccessfulDeploymentApplicationPackageChanged() { TenantName tenant = tester.controllerTester().createTenant("tenant1", "domain1", 1L); MockBuildService mockBuildService = tester.buildService(); - Application application = tester.controllerTester().createApplication(tenant, "app1", "default", 1L); + Instance instance = tester.controllerTester().createApplication(tenant, "app1", "default", 1L); ApplicationPackage previousApplicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-east-3") @@ -425,16 +425,16 @@ public class DeploymentTriggerTest { .build(); // Component job finishes - tester.jobCompletion(component).application(application).uploadArtifact(newApplicationPackage).submit(); + tester.jobCompletion(component).application(instance).uploadArtifact(newApplicationPackage).submit(); // Application is deployed to all test environments and declared zones - tester.deployAndNotify(application, newApplicationPackage, true, JobType.systemTest); - tester.deploy(JobType.stagingTest, application, previousApplicationPackage, true); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.stagingTest); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsEast3); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsCentral1); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsWest1); - tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionEuWest1); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.systemTest); + tester.deploy(JobType.stagingTest, instance, previousApplicationPackage, true); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.stagingTest); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.productionUsEast3); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.productionUsCentral1); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.productionUsWest1); + tester.deployAndNotify(instance, newApplicationPackage, true, JobType.productionEuWest1); assertTrue("All jobs consumed", mockBuildService.jobs().isEmpty()); } @@ -457,7 +457,7 @@ public class DeploymentTriggerTest { .region("us-central-1") .region("us-east-3"); - Application app = tester.createAndDeploy("app1", 1, applicationPackageBuilder.build()); + Instance app = tester.createAndDeploy("app1", 1, applicationPackageBuilder.build()); tester.clock().advance(Duration.ofHours(1)); // --------------- Enter block window: 18:30 @@ -506,7 +506,7 @@ public class DeploymentTriggerTest { .region("us-west-1") .region("us-east-3") .build(); - Application application = tester.createAndDeploy("app1", 1, applicationPackage); + Instance instance = tester.createAndDeploy("app1", 1, applicationPackage); // Application on (6.1, 1.0.42) Version v1 = Version.fromString("6.1"); @@ -514,48 +514,48 @@ public class DeploymentTriggerTest { // Application is mid-upgrade when block window begins, and has an outstanding change. Version v2 = Version.fromString("6.2"); tester.upgradeSystem(v2); - tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).nextBuildNumber().uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(application, applicationPackage, true, stagingTest); - tester.deployAndNotify(application, applicationPackage, true, systemTest); + tester.deployAndNotify(instance, applicationPackage, true, stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, systemTest); // Entering block window will keep the outstanding change in place. tester.clock().advance(Duration.ofHours(1)); tester.outstandingChangeDeployer().run(); - tester.deployAndNotify(application, applicationPackage, true, productionUsWest1); - assertEquals(BuildJob.defaultBuildNumber, tester.application(application.id()).deploymentJobs().jobStatus() - .get(productionUsWest1).lastSuccess().get().application().buildNumber().getAsLong()); - assertEquals((BuildJob.defaultBuildNumber + 1), tester.application(application.id()).outstandingChange().application().get().buildNumber().getAsLong()); + tester.deployAndNotify(instance, applicationPackage, true, productionUsWest1); + assertEquals(BuildJob.defaultBuildNumber, tester.application(instance.id()).deploymentJobs().jobStatus() + .get(productionUsWest1).lastSuccess().get().application().buildNumber().getAsLong()); + assertEquals((BuildJob.defaultBuildNumber + 1), tester.application(instance.id()).outstandingChange().application().get().buildNumber().getAsLong()); tester.readyJobTrigger().maintain(); // Platform upgrade keeps rolling, since it has already deployed in a production zone, and tests for the new revision have also started. assertEquals(3, tester.buildService().jobs().size()); - tester.deployAndNotify(application, applicationPackage, true, productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, productionUsEast3); assertEquals(2, tester.buildService().jobs().size()); // Upgrade is done, and oustanding change rolls out when block window ends. - assertEquals(Change.empty(), tester.application(application.id()).change()); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertTrue(tester.application(application.id()).outstandingChange().hasTargets()); + assertEquals(Change.empty(), tester.application(instance.id()).change()); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertTrue(tester.application(instance.id()).outstandingChange().hasTargets()); - tester.deployAndNotify(application, applicationPackage, true, stagingTest); - tester.deployAndNotify(application, applicationPackage, true, systemTest); + tester.deployAndNotify(instance, applicationPackage, true, stagingTest); + tester.deployAndNotify(instance, applicationPackage, true, systemTest); tester.clock().advance(Duration.ofHours(1)); tester.outstandingChangeDeployer().run(); - assertTrue(tester.application(application.id()).change().hasTargets()); - assertFalse(tester.application(application.id()).outstandingChange().hasTargets()); + assertTrue(tester.application(instance.id()).change().hasTargets()); + assertFalse(tester.application(instance.id()).outstandingChange().hasTargets()); tester.readyJobTrigger().run(); - tester.deployAndNotify(application, applicationPackage, true, productionUsWest1); - tester.deployAndNotify(application, applicationPackage, true, productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, true, productionUsWest1); + tester.deployAndNotify(instance, applicationPackage, true, productionUsEast3); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertFalse(tester.application(application.id()).outstandingChange().hasTargets()); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertFalse(tester.application(instance.id()).outstandingChange().hasTargets()); } @Test public void testJobPause() { - Application app = tester.createAndDeploy("app", 3, "default"); + Instance app = tester.createAndDeploy("app", 3, "default"); tester.upgradeSystem(new Version("9.8.7")); tester.applications().deploymentTrigger().pauseJob(app.id(), productionUsWest1, tester.clock().instant().plus(Duration.ofSeconds(1))); @@ -589,7 +589,7 @@ public class DeploymentTriggerTest { ReadyJobsTrigger readyJobsTrigger = new ReadyJobsTrigger(tester.controller(), Duration.ofHours(1), new JobControl(tester.controllerTester().curator())); - Application app = tester.createAndDeploy("default0", 3, "default"); + Instance app = tester.createAndDeploy("default0", 3, "default"); // Store that we are upgrading but don't start the system-tests job tester.controller().applications().lockOrThrow(app.id(), locked -> { tester.controller().applications().store(locked.withChange(Change.of(Version.fromString("6.2")))); @@ -602,58 +602,58 @@ public class DeploymentTriggerTest { @Test public void applicationVersionIsNotDowngraded() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); - Supplier<Application> app = () -> tester.application(application.id()); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); + Supplier<Instance> app = () -> tester.application(instance.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") .region("eu-west-1") .build(); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // productionUsCentral1 fails after deployment, causing a mismatch between deployed and successful state. - tester.completeDeploymentWithError(application, applicationPackage, BuildJob.defaultBuildNumber + 1, productionUsCentral1); + tester.completeDeploymentWithError(instance, applicationPackage, BuildJob.defaultBuildNumber + 1, productionUsCentral1); // deployAndNotify doesn't actually deploy if the job fails, so we need to do that manually. - tester.deployAndNotify(application, false, productionUsCentral1); - tester.deploy(productionUsCentral1, application, Optional.empty(), false); + tester.deployAndNotify(instance, false, productionUsCentral1); + tester.deploy(productionUsCentral1, instance, Optional.empty(), false); ApplicationVersion appVersion1 = ApplicationVersion.from(BuildJob.defaultSourceRevision, BuildJob.defaultBuildNumber + 1); assertEquals(appVersion1, app.get().deployments().get(ZoneId.from("prod.us-central-1")).applicationVersion()); // Verify the application change is not removed when change is cancelled. - tester.deploymentTrigger().cancelChange(application.id(), PLATFORM); + tester.deploymentTrigger().cancelChange(instance.id(), PLATFORM); assertEquals(Change.of(appVersion1), app.get().change()); // Now cancel the change as is done through the web API. - tester.deploymentTrigger().cancelChange(application.id(), ALL); + tester.deploymentTrigger().cancelChange(instance.id(), ALL); assertEquals(Change.empty(), app.get().change()); // A new version is released, which should now deploy the currently deployed application version to avoid downgrades. Version version1 = new Version("6.2"); tester.upgradeSystem(version1); - tester.jobCompletion(productionUsCentral1).application(application).unsuccessful().submit(); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, false, productionUsCentral1); + tester.jobCompletion(productionUsCentral1).application(instance).unsuccessful().submit(); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, false, productionUsCentral1); // The last job has a different target, and the tests need to run again. // These may now start, since the first job has been triggered once, and thus is verified already. - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // Finally, the two production jobs complete, in order. - tester.deployAndNotify(application, true, productionUsCentral1); - tester.deployAndNotify(application, true, productionEuWest1); + tester.deployAndNotify(instance, true, productionUsCentral1); + tester.deployAndNotify(instance, true, productionEuWest1); assertEquals(appVersion1, app.get().deployments().get(ZoneId.from("prod.us-central-1")).applicationVersion()); } @Test public void stepIsCompletePreciselyWhenItShouldBe() { - Application application1 = tester.createApplication("app1", "tenant1", 1, 1L); - Application application2 = tester.createApplication("app2", "tenant2", 2, 2L); - Supplier<Application> app1 = () -> tester.application(application1.id()); + Instance instance1 = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance2 = tester.createApplication("app2", "tenant2", 2, 2L); + Supplier<Instance> app1 = () -> tester.application(instance1.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") @@ -663,23 +663,23 @@ public class DeploymentTriggerTest { // System upgrades to version0 and applications deploy on that version Version version0 = Version.fromString("7.0"); tester.upgradeSystem(version0); - tester.deployCompletely(application1, applicationPackage); - tester.deployCompletely(application2, applicationPackage); + tester.deployCompletely(instance1, applicationPackage); + tester.deployCompletely(instance2, applicationPackage); // version1 is released and application1 skips upgrading to that version Version version1 = Version.fromString("7.1"); tester.upgradeSystem(version1); // Deploy application2 to keep this version present in the system - tester.deployCompletely(application2, applicationPackage); - tester.applications().deploymentTrigger().cancelChange(application1.id(), ALL); + tester.deployCompletely(instance2, applicationPackage); + tester.applications().deploymentTrigger().cancelChange(instance1.id(), ALL); tester.buildService().clear(); // Clear stale build jobs for cancelled change // version2 is released and application1 starts upgrading Version version2 = Version.fromString("7.2"); tester.upgradeSystem(version2); - tester.completeUpgradeWithError(application1, version2, applicationPackage, productionUsCentral1); - tester.deploy(productionUsCentral1, application1, applicationPackage); - tester.deployAndNotify(application1, applicationPackage, false, productionUsCentral1); + tester.completeUpgradeWithError(instance1, version2, applicationPackage, productionUsCentral1); + tester.deploy(productionUsCentral1, instance1, applicationPackage); + tester.deployAndNotify(instance1, applicationPackage, false, productionUsCentral1); assertEquals(version2, app1.get().deployments().get(productionUsCentral1.zone(main)).version()); // version2 becomes broken and upgrade targets latest non-broken @@ -687,34 +687,34 @@ public class DeploymentTriggerTest { tester.computeVersionStatus(); tester.upgrader().maintain(); // Cancel upgrades to broken version assertEquals("Change becomes latest non-broken version", Change.of(version1), app1.get().change()); - tester.deployAndNotify(application1, applicationPackage, false, productionUsCentral1); + tester.deployAndNotify(instance1, applicationPackage, false, productionUsCentral1); Instant triggered = app1.get().deploymentJobs().jobStatus().get(productionUsCentral1).lastTriggered().get().at(); tester.clock().advance(Duration.ofHours(1)); // version1 proceeds 'til the last job, where it fails; us-central-1 is skipped, as current change is strictly dominated by what's deployed there. - tester.deployAndNotify(application1, applicationPackage, true, systemTest); - tester.deployAndNotify(application1, applicationPackage, true, stagingTest); + tester.deployAndNotify(instance1, applicationPackage, true, systemTest); + tester.deployAndNotify(instance1, applicationPackage, true, stagingTest); assertEquals(triggered, app1.get().deploymentJobs().jobStatus().get(productionUsCentral1).lastTriggered().get().at()); - tester.deployAndNotify(application1, applicationPackage, false, productionEuWest1); + tester.deployAndNotify(instance1, applicationPackage, false, productionEuWest1); //Eagerly triggered system and staging tests complete. - tester.deployAndNotify(application1, applicationPackage, true, systemTest); - tester.deployAndNotify(application1, applicationPackage, true, stagingTest); + tester.deployAndNotify(instance1, applicationPackage, true, systemTest); + tester.deployAndNotify(instance1, applicationPackage, true, stagingTest); // Roll out a new application version, which gives a dual change -- this should trigger us-central-1, but only as long as it hasn't yet deployed there. - tester.jobCompletion(component).application(application1).nextBuildNumber().uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(application1, applicationPackage, false, productionEuWest1); - tester.deployAndNotify(application1, applicationPackage, true, systemTest); - tester.deployAndNotify(application1, applicationPackage, true, stagingTest); + tester.jobCompletion(component).application(instance1).nextBuildNumber().uploadArtifact(applicationPackage).submit(); + tester.deployAndNotify(instance1, applicationPackage, false, productionEuWest1); + tester.deployAndNotify(instance1, applicationPackage, true, systemTest); + tester.deployAndNotify(instance1, applicationPackage, true, stagingTest); - tester.assertRunning(productionUsCentral1, application1.id()); + tester.assertRunning(productionUsCentral1, instance1.id()); assertEquals(version2, app1.get().deployments().get(productionUsCentral1.zone(main)).version()); assertEquals(42, app1.get().deployments().get(productionUsCentral1.zone(main)).applicationVersion().buildNumber().getAsLong()); assertNotEquals(triggered, app1.get().deploymentJobs().jobStatus().get(productionUsCentral1).lastTriggered().get().at()); // Change has a higher application version than what is deployed -- deployment should trigger. - tester.deployAndNotify(application1, applicationPackage, false, productionUsCentral1); - tester.deploy(productionUsCentral1, application1, applicationPackage); + tester.deployAndNotify(instance1, applicationPackage, false, productionUsCentral1); + tester.deploy(productionUsCentral1, instance1, applicationPackage); assertEquals(version2, app1.get().deployments().get(productionUsCentral1.zone(main)).version()); assertEquals(43, app1.get().deployments().get(productionUsCentral1.zone(main)).applicationVersion().buildNumber().getAsLong()); @@ -722,67 +722,67 @@ public class DeploymentTriggerTest { tester.clock().advance(Duration.ofHours(2).plus(Duration.ofSeconds(1))); // Enough time for retry tester.readyJobTrigger().maintain(); // Failing job is not retried as change has been deployed - tester.assertNotRunning(productionUsCentral1, application1.id()); + tester.assertNotRunning(productionUsCentral1, instance1.id()); // Last job has a different deployment target, so tests need to run again. - tester.deployAndNotify(application1, true, systemTest); - tester.deployAndNotify(application1, true, stagingTest); - tester.deployAndNotify(application1, applicationPackage, true, productionEuWest1); + tester.deployAndNotify(instance1, true, systemTest); + tester.deployAndNotify(instance1, true, stagingTest); + tester.deployAndNotify(instance1, applicationPackage, true, productionEuWest1); assertFalse(app1.get().change().hasTargets()); assertFalse(app1.get().deploymentJobs().jobStatus().get(productionUsCentral1).isSuccess()); } @Test public void eachDeployTargetIsTested() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); - Supplier<Application> app = () -> tester.application(application.id()); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); + Supplier<Instance> app = () -> tester.application(instance.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .parallel("eu-west-1", "us-east-3") .build(); // Application version 42 and platform version 6.1. - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // Success in first prod zone, change cancelled between triggering and deployment to two parallel zones. // One of the parallel zones get a deployment, but both fail their jobs. Version v1 = new Version("6.1"); Version v2 = new Version("6.2"); tester.upgradeSystem(v2); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deploymentTrigger().cancelChange(application.id(), PLATFORM); - tester.deploy(productionEuWest1, application, applicationPackage); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deploymentTrigger().cancelChange(instance.id(), PLATFORM); + tester.deploy(productionEuWest1, instance, applicationPackage); assertEquals(v2, app.get().deployments().get(productionEuWest1.zone(main)).version()); assertEquals(v1, app.get().deployments().get(productionUsEast3.zone(main)).version()); // New application version should run system and staging tests against both 6.1 and 6.2, in no particular order. - tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit(); + tester.jobCompletion(component).application(instance).nextBuildNumber().uploadArtifact(applicationPackage).submit(); Version firstTested = app.get().deploymentJobs().jobStatus().get(systemTest).lastTriggered().get().platform(); assertEquals(firstTested, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // Tests are not re-triggered, because the deployments that were tested have not yet been triggered on the tested versions. assertEquals(firstTested, app.get().deploymentJobs().jobStatus().get(systemTest).lastTriggered().get().platform()); assertEquals(firstTested, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); // Finish old runs of the production jobs, which fail. - tester.deployAndNotify(application, applicationPackage, false, productionEuWest1); - tester.deployAndNotify(application, applicationPackage, false, productionUsEast3); + tester.deployAndNotify(instance, applicationPackage, false, productionEuWest1); + tester.deployAndNotify(instance, applicationPackage, false, productionUsEast3); tester.triggerUntilQuiescence(); // New upgrade is already tested for one of the jobs, which has now been triggered, and tests may run for the other job. assertNotEquals(firstTested, app.get().deploymentJobs().jobStatus().get(systemTest).lastTriggered().get().platform()); assertNotEquals(firstTested, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // Both jobs fail again, and must be re-triggered -- this is ok, as they are both already triggered on their current targets. - tester.deployAndNotify(application, false, productionEuWest1); - tester.deployAndNotify(application, false, productionUsEast3); - tester.deployAndNotify(application, true, productionUsEast3); - tester.deployAndNotify(application, true, productionEuWest1); + tester.deployAndNotify(instance, false, productionEuWest1); + tester.deployAndNotify(instance, false, productionUsEast3); + tester.deployAndNotify(instance, true, productionUsEast3); + tester.deployAndNotify(instance, true, productionEuWest1); assertFalse(app.get().change().hasTargets()); assertEquals(43, app.get().deploymentJobs().jobStatus().get(productionEuWest1).lastSuccess().get().application().buildNumber().getAsLong()); assertEquals(43, app.get().deploymentJobs().jobStatus().get(productionUsEast3).lastSuccess().get().application().buildNumber().getAsLong()); @@ -790,98 +790,98 @@ public class DeploymentTriggerTest { @Test public void eachDifferentUpgradeCombinationIsTested() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); - Supplier<Application> app = () -> tester.application(application.id()); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); + Supplier<Instance> app = () -> tester.application(instance.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") .parallel("eu-west-1", "us-east-3") .build(); // Application version 42 and platform version 6.1. - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // Application partially upgrades, then a new version is released. Version v1 = new Version("6.1"); Version v2 = new Version("6.2"); tester.upgradeSystem(v2); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsCentral1); - tester.deployAndNotify(application, true, productionEuWest1); - tester.deployAndNotify(application, false, productionUsEast3); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsCentral1); + tester.deployAndNotify(instance, true, productionEuWest1); + tester.deployAndNotify(instance, false, productionUsEast3); assertEquals(v2, app.get().deployments().get(ZoneId.from("prod", "us-central-1")).version()); assertEquals(v2, app.get().deployments().get(ZoneId.from("prod", "eu-west-1")).version()); assertEquals(v1, app.get().deployments().get(ZoneId.from("prod", "us-east-3")).version()); Version v3 = new Version("6.3"); tester.upgradeSystem(v3); - tester.deployAndNotify(application, false, productionUsEast3); + tester.deployAndNotify(instance, false, productionUsEast3); // See that sources for staging are: first v2, then v1. - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); assertEquals(v2, app.get().deploymentJobs().jobStatus().get(stagingTest).lastSuccess().get().sourcePlatform().get()); - tester.deployAndNotify(application, true, productionUsCentral1); + tester.deployAndNotify(instance, true, productionUsCentral1); assertEquals(v1, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().sourcePlatform().get()); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionEuWest1); - tester.deployAndNotify(application, true, productionUsEast3); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionEuWest1); + tester.deployAndNotify(instance, true, productionUsEast3); } @Test public void retriesFailingJobs() { - Application application = tester.createApplication("app1", "tenant1", 1, 1L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") .build(); // Deploy completely on default application and platform versions - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // New application change is deployed and fails in system-test for a while - tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(application, false, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.jobCompletion(component).application(instance).nextBuildNumber().uploadArtifact(applicationPackage).submit(); + tester.deployAndNotify(instance, false, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // Retries immediately in the first minute after failing tester.clock().advance(Duration.ofSeconds(59)); - tester.jobCompletion(systemTest).application(application).unsuccessful().submit(); + tester.jobCompletion(systemTest).application(instance).unsuccessful().submit(); tester.readyJobTrigger().maintain(); - tester.assertRunning(systemTest, application.id()); + tester.assertRunning(systemTest, instance.id()); // Stops immediate retry after failing for 1 minute tester.clock().advance(Duration.ofSeconds(1)); - tester.jobCompletion(systemTest).application(application).unsuccessful().submit(); + tester.jobCompletion(systemTest).application(instance).unsuccessful().submit(); tester.readyJobTrigger().maintain(); - tester.assertNotRunning(systemTest, application.id()); + tester.assertNotRunning(systemTest, instance.id()); // Retries after 10 minutes since previous completion as we failed within the last hour tester.clock().advance(Duration.ofMinutes(10).plus(Duration.ofSeconds(1))); tester.readyJobTrigger().maintain(); - tester.assertRunning(systemTest, application.id()); + tester.assertRunning(systemTest, instance.id()); // Retries less frequently after 1 hour of failure tester.clock().advance(Duration.ofMinutes(50)); - tester.jobCompletion(systemTest).application(application).unsuccessful().submit(); + tester.jobCompletion(systemTest).application(instance).unsuccessful().submit(); tester.readyJobTrigger().maintain(); - tester.assertNotRunning(systemTest, application.id()); + tester.assertNotRunning(systemTest, instance.id()); // Retries after two hours pass since last completion tester.clock().advance(Duration.ofHours(2).plus(Duration.ofSeconds(1))); tester.readyJobTrigger().maintain(); - tester.assertRunning(systemTest, application.id()); + tester.assertRunning(systemTest, instance.id()); // Still fails and is not retried - tester.jobCompletion(systemTest).application(application).unsuccessful().submit(); + tester.jobCompletion(systemTest).application(instance).unsuccessful().submit(); tester.readyJobTrigger().maintain(); - tester.assertNotRunning(systemTest, application.id()); + tester.assertNotRunning(systemTest, instance.id()); // Another application change is deployed and fixes system-test. Change is triggered immediately as target changes - tester.jobCompletion(component).application(application).nextBuildNumber(2).uploadArtifact(applicationPackage).submit(); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsCentral1); + tester.jobCompletion(component).application(instance).nextBuildNumber(2).uploadArtifact(applicationPackage).submit(); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsCentral1); assertTrue("Deployment completed", tester.buildService().jobs().isEmpty()); } @@ -895,7 +895,7 @@ public class DeploymentTriggerTest { Version version = Version.fromString("6.2"); tester.upgradeSystem(version); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); @@ -954,7 +954,7 @@ public class DeploymentTriggerTest { Version version = Version.fromString("6.2"); tester.upgradeSystem(version); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); tester.deployAndNotify(app, applicationPackage, true, JobType.systemTest); tester.deployAndNotify(app, applicationPackage, true, JobType.stagingTest); @@ -988,7 +988,7 @@ public class DeploymentTriggerTest { @Test public void testUpdatesFailingJobStatus() { // Setup application - Application app = tester.createApplication("app1", "foo", 1, 1L); + Instance app = tester.createApplication("app1", "foo", 1, 1L); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") @@ -1058,7 +1058,7 @@ public class DeploymentTriggerTest { .build(); Version version1 = tester.controller().versionStatus().systemVersion().get().versionNumber(); - Application app1 = tester.createApplication("application1", "tenant1", 1, 1L); + Instance app1 = tester.createApplication("application1", "tenant1", 1, 1L); // First deployment: An application change tester.jobCompletion(component).application(app1).uploadArtifact(applicationPackage).submit(); @@ -1124,9 +1124,9 @@ public class DeploymentTriggerTest { long project1 = 1; long project2 = 2; long project3 = 3; - Application app1 = tester.createApplication("app1", "tenant1", project1, 1L); - Application app2 = tester.createApplication("app2", "tenant2", project2, 1L); - Application app3 = tester.createApplication("app3", "tenant3", project3, 1L); + Instance app1 = tester.createApplication("app1", "tenant1", project1, 1L); + Instance app2 = tester.createApplication("app2", "tenant2", project2, 1L); + Instance app3 = tester.createApplication("app3", "tenant3", project3, 1L); MockBuildService mockBuildService = tester.buildService(); // all applications: system-test completes successfully with some time in between, to determine trigger order. diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java index 879007494db..b6315bc6780 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java @@ -11,7 +11,7 @@ import com.yahoo.security.KeyUtils; import com.yahoo.security.SignatureAlgorithm; import com.yahoo.security.X509CertificateBuilder; import com.yahoo.test.ManualClock; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ApplicationController; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; @@ -86,7 +86,7 @@ public class InternalDeploymentTester { public ConfigServerMock configServer() { return tester.configServer(); } public ApplicationController applications() { return tester.applications(); } public ManualClock clock() { return tester.clock(); } - public Application app() { return tester.application(appId); } + public Instance app() { return tester.application(appId); } public InternalDeploymentTester() { tester = new DeploymentTester(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java index f9c8b66acda..98e8eff508e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmerTest.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.organization.ApplicationSummary; import com.yahoo.vespa.hosted.controller.api.integration.organization.Contact; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; @@ -44,12 +44,12 @@ public class ApplicationOwnershipConfirmerTest { Optional<Contact> contact = Optional.of(tester.controllerTester().serviceRegistry().contactRetrieverMock().contact()); TenantName property = tester.controllerTester().createTenant("property", "domain", 1L, contact); tester.createAndDeploy(property, "application", 1, "default"); - Supplier<Application> propertyApp = () -> tester.controller().applications().require(ApplicationId.from("property", "application", "default")); + Supplier<Instance> propertyApp = () -> tester.controller().applications().require(ApplicationId.from("property", "application", "default")); UserTenant user = UserTenant.create("by-user", contact); tester.controller().tenants().createUser(user); tester.createAndDeploy(user.name(), "application", 2, "default"); - Supplier<Application> userApp = () -> tester.controller().applications().require(ApplicationId.from("by-user", "application", "default")); + Supplier<Instance> userApp = () -> tester.controller().applications().require(ApplicationId.from("by-user", "application", "default")); assertFalse("No issue is initially stored for a new application.", propertyApp.get().ownershipIssueId().isPresent()); assertFalse("No issue is initially stored for a new application.", userApp.get().ownershipIssueId().isPresent()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirerTest.java index 730b2943431..b2ac44bf23b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentExpirerTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -33,8 +33,8 @@ public class DeploymentExpirerTest { ); DeploymentExpirer expirer = new DeploymentExpirer(tester.controller(), Duration.ofDays(10), new JobControl(new MockCuratorDb())); - Application devApp = tester.createApplication("app1", "tenant1", 123L, 1L); - Application prodApp = tester.createApplication("app2", "tenant2", 456L, 2L); + Instance devApp = tester.createApplication("app1", "tenant1", 123L, 1L); + Instance prodApp = tester.createApplication("app2", "tenant2", 456L, 2L); // Deploy dev tester.controllerTester().deploy(devApp, tester.controllerTester().toZone(Environment.dev)); @@ -60,11 +60,11 @@ public class DeploymentExpirerTest { assertEquals(1, permanentDeployments(prodApp).size()); } - private List<Deployment> permanentDeployments(Application application) { - return tester.controller().applications().get(application.id()).get().deployments().values().stream() - .filter(deployment -> deployment.zone().environment() != Environment.test && + private List<Deployment> permanentDeployments(Instance instance) { + return tester.controller().applications().get(instance.id()).get().deployments().values().stream() + .filter(deployment -> deployment.zone().environment() != Environment.test && deployment.zone().environment() != Environment.staging) - .collect(Collectors.toList()); + .collect(Collectors.toList()); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java index 7da1064cb23..d20ccdf5963 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.organization.Contact; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; import com.yahoo.vespa.hosted.controller.api.integration.stubs.LoggingDeploymentIssues; @@ -78,9 +78,9 @@ public class DeploymentIssueReporterTest { tester.controllerTester().createTenant("tenant3", "domain3", 1L, contact); // Create and deploy one application for each of three tenants. - Application app1 = tester.createApplication("application1", "tenant1", projectId1, propertyId1); - Application app2 = tester.createApplication("application2", "tenant2", projectId2, propertyId2); - Application app3 = tester.createApplication("application3", "tenant3", projectId3, propertyId3); + Instance app1 = tester.createApplication("application1", "tenant1", projectId1, propertyId1); + Instance app2 = tester.createApplication("application2", "tenant2", projectId2, propertyId2); + Instance app3 = tester.createApplication("application3", "tenant3", projectId3, propertyId3); // NOTE: All maintenance should be idempotent within a small enough time interval, so maintain is called twice in succession throughout. diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java index c8b3cd01fe8..c4a835cd7e7 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java @@ -6,7 +6,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.application.v4.model.ClusterMetrics; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; @@ -40,7 +40,7 @@ public class DeploymentMetricsMaintainerTest { deploy(application, Version.fromString("7.1")); DeploymentMetricsMaintainer maintainer = maintainer(tester.controller()); - Supplier<Application> app = () -> tester.application(application.id()); + Supplier<Instance> app = () -> tester.application(application.id()); Supplier<Deployment> deployment = () -> app.get().deployments().values().stream().findFirst().get(); // No metrics gathered yet @@ -127,8 +127,8 @@ public class DeploymentMetricsMaintainerTest { return new DeploymentMetricsMaintainer(controller, Duration.ofDays(1), new JobControl(controller.curator())); } - private void deploy(Application application, Version version) { - tester.controllerTester().deploy(application, + private void deploy(Instance instance, Version version) { + tester.controllerTester().deploy(instance, ZoneId.from(Environment.dev, RegionName.from("us-east-1")), Optional.of(new ApplicationPackage(new byte[0])), false, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java index 148be3f258e..46e6d9c3f50 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.Version; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; @@ -46,10 +46,10 @@ public class MetricsReporterTest { assertEquals(0.0, metrics.getMetric(MetricsReporter.DEPLOYMENT_FAIL_METRIC)); // Deploy all apps successfully - Application app1 = tester.createApplication("app1", "tenant1", 1, 11L); - Application app2 = tester.createApplication("app2", "tenant1", 2, 22L); - Application app3 = tester.createApplication("app3", "tenant1", 3, 33L); - Application app4 = tester.createApplication("app4", "tenant1", 4, 44L); + Instance app1 = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app2 = tester.createApplication("app2", "tenant1", 2, 22L); + Instance app3 = tester.createApplication("app3", "tenant1", 3, 33L); + Instance app4 = tester.createApplication("app4", "tenant1", 4, 44L); tester.deployCompletely(app1, applicationPackage); tester.deployCompletely(app2, applicationPackage); tester.deployCompletely(app3, applicationPackage); @@ -76,7 +76,7 @@ public class MetricsReporterTest { MetricsReporter reporter = createReporter(tester.controller()); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.deployCompletely(app, applicationPackage); reporter.maintain(); assertEquals(Duration.ZERO, getAverageDeploymentDuration(app)); // An exceptionally fast deployment :-) @@ -117,7 +117,7 @@ public class MetricsReporterTest { .build(); MetricsReporter reporter = createReporter(tester.controller()); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); // Initial deployment without failures tester.deployCompletely(app, applicationPackage); @@ -168,12 +168,12 @@ public class MetricsReporterTest { .region("us-east-3") .build(); MetricsReporter reporter = createReporter(tester.controller()); - Application application = tester.createApplication("app1", "tenant1", 1, 11L); - tester.configServer().generateWarnings(new DeploymentId(application.id(), ZoneId.from("prod", "us-west-1")), 3); - tester.configServer().generateWarnings(new DeploymentId(application.id(), ZoneId.from("prod", "us-east-3")), 4); - tester.deployCompletely(application, applicationPackage); + Instance instance = tester.createApplication("app1", "tenant1", 1, 11L); + tester.configServer().generateWarnings(new DeploymentId(instance.id(), ZoneId.from("prod", "us-west-1")), 3); + tester.configServer().generateWarnings(new DeploymentId(instance.id(), ZoneId.from("prod", "us-east-3")), 4); + tester.deployCompletely(instance, applicationPackage); reporter.maintain(); - assertEquals(4, getDeploymentWarnings(application)); + assertEquals(4, getDeploymentWarnings(instance)); } @Test @@ -198,11 +198,11 @@ public class MetricsReporterTest { .region("us-east-3") .build(); MetricsReporter reporter = createReporter(tester.controller()); - Application application = tester.createApplication("app1", "tenant1", 1, 11L); + Instance instance = tester.createApplication("app1", "tenant1", 1, 11L); reporter.maintain(); assertEquals("Queue is empty initially", 0, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue()); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); reporter.maintain(); assertEquals("Deployment queues name services requests", 6, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue()); @@ -211,31 +211,31 @@ public class MetricsReporterTest { assertEquals("Queue consumed", 0, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue()); } - private Duration getAverageDeploymentDuration(Application application) { - return Duration.ofSeconds(getMetric(MetricsReporter.DEPLOYMENT_AVERAGE_DURATION, application).longValue()); + private Duration getAverageDeploymentDuration(Instance instance) { + return Duration.ofSeconds(getMetric(MetricsReporter.DEPLOYMENT_AVERAGE_DURATION, instance).longValue()); } - private int getDeploymentsFailingUpgrade(Application application) { - return getMetric(MetricsReporter.DEPLOYMENT_FAILING_UPGRADES, application).intValue(); + private int getDeploymentsFailingUpgrade(Instance instance) { + return getMetric(MetricsReporter.DEPLOYMENT_FAILING_UPGRADES, instance).intValue(); } - private int getDeploymentWarnings(Application application) { - return getMetric(MetricsReporter.DEPLOYMENT_WARNINGS, application).intValue(); + private int getDeploymentWarnings(Instance instance) { + return getMetric(MetricsReporter.DEPLOYMENT_WARNINGS, instance).intValue(); } - private Number getMetric(String name, Application application) { - return metrics.getMetric((dimensions) -> application.id().tenant().value().equals(dimensions.get("tenant")) && - appDimension(application).equals(dimensions.get("app")), + private Number getMetric(String name, Instance instance) { + return metrics.getMetric((dimensions) -> instance.id().tenant().value().equals(dimensions.get("tenant")) && + appDimension(instance).equals(dimensions.get("app")), name) - .orElseThrow(() -> new RuntimeException("Expected metric to exist for " + application.id())); + .orElseThrow(() -> new RuntimeException("Expected metric to exist for " + instance.id())); } private MetricsReporter createReporter(Controller controller) { return new MetricsReporter(controller, metrics, new JobControl(new MockCuratorDb())); } - private static String appDimension(Application application) { - return application.id().application().value() + "." + application.id().instance().value(); + private static String appDimension(Instance instance) { + return instance.id().application().value() + "." + instance.id().instance().value(); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java index 3a7c62c900a..4bd1bfcffae 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployerTest.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.Version; import com.yahoo.config.provision.Environment; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.BuildService; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; @@ -53,7 +53,7 @@ public class OutstandingChangeDeployerTest { .uploadArtifact(applicationPackage) .submit(); - Application app = tester.application("app1"); + Instance app = tester.application("app1"); assertTrue(app.outstandingChange().hasTargets()); assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id()); assertEquals(2, tester.buildService().jobs().size()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java index f0b12cb48b6..7f97f1bc4a9 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -42,7 +42,7 @@ public class RotationStatusUpdaterTest { .build(); tester.deployCompletely(application, applicationPackage); - Supplier<Application> app = () -> tester.application(application.id()); + Supplier<Instance> app = () -> tester.application(application.id()); Supplier<Deployment> deployment1 = () -> app.get().deployments().get(zone1); Supplier<Deployment> deployment2 = () -> app.get().deployments().get(zone2); Supplier<Deployment> deployment3 = () -> app.get().deployments().get(zone3); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java index 0dee5fcb78c..1763ff74fb0 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java @@ -5,7 +5,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.configserver.LoadBalancer; import com.yahoo.vespa.hosted.controller.api.integration.dns.Record; @@ -38,8 +38,8 @@ public class RoutingPoliciesTest { private final DeploymentTester tester = new DeploymentTester(); - private final Application app1 = tester.createApplication("app1", "tenant1", 1, 1L); - private final Application app2 = tester.createApplication("app2", "tenant1", 1, 1L); + private final Instance app1 = tester.createApplication("app1", "tenant1", 1, 1L); + private final Instance app2 = tester.createApplication("app2", "tenant1", 1, 1L); private final ZoneId zone1 = ZoneId.from("prod", "us-west-1"); private final ZoneId zone2 = ZoneId.from("prod", "us-central-1"); @@ -238,8 +238,8 @@ public class RoutingPoliciesTest { tester.controller().applications().clusterEndpoints(new DeploymentId(app1.id(), zone1))); } - private Set<RoutingPolicy> policies(Application application) { - return tester.controller().curator().readRoutingPolicies(application.id()); + private Set<RoutingPolicy> policies(Instance instance) { + return tester.controller().curator().readRoutingPolicies(instance.id()); } private Set<String> recordNames() { 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 ab4d4987d6a..a54d6f3ece7 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 @@ -5,7 +5,7 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; @@ -54,12 +54,12 @@ public class UpgraderTest { assertEquals("No applications: Nothing to do", 0, tester.buildService().jobs().size()); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application conservative0 = tester.createAndDeploy("conservative0", 6, "conservative"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance conservative0 = tester.createAndDeploy("conservative0", 6, "conservative"); tester.upgrader().maintain(); tester.triggerUntilQuiescence(); @@ -183,8 +183,8 @@ public class UpgraderTest { // --- Starting upgrading to a new version which breaks, causing upgrades to commence on the previous version Version version4 = Version.fromString("6.6"); - Application default3 = tester.createAndDeploy("default3", 7, "default"); // need 4 to break a version - Application default4 = tester.createAndDeploy("default4", 8, "default"); + Instance default3 = tester.createAndDeploy("default3", 7, "default"); // need 4 to break a version + Instance default4 = tester.createAndDeploy("default4", 8, "default"); tester.upgradeSystem(version4); tester.upgrader().maintain(); // cause canary upgrades to new version tester.triggerUntilQuiescence(); @@ -271,18 +271,18 @@ public class UpgraderTest { assertEquals("No applications: Nothing to do", 0, tester.buildService().jobs().size()); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application default3 = tester.createAndDeploy("default3", 6, "default"); - Application default4 = tester.createAndDeploy("default4", 7, "default"); - Application default5 = tester.createAndDeploy("default5", 8, "default"); - Application default6 = tester.createAndDeploy("default6", 9, "default"); - Application default7 = tester.createAndDeploy("default7", 10, "default"); - Application default8 = tester.createAndDeploy("default8", 11, "default"); - Application default9 = tester.createAndDeploy("default9", 12, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance default3 = tester.createAndDeploy("default3", 6, "default"); + Instance default4 = tester.createAndDeploy("default4", 7, "default"); + Instance default5 = tester.createAndDeploy("default5", 8, "default"); + Instance default6 = tester.createAndDeploy("default6", 9, "default"); + Instance default7 = tester.createAndDeploy("default7", 10, "default"); + Instance default8 = tester.createAndDeploy("default8", 11, "default"); + Instance default9 = tester.createAndDeploy("default9", 12, "default"); tester.upgrader().maintain(); tester.triggerUntilQuiescence(); @@ -338,7 +338,7 @@ public class UpgraderTest { Version version = Version.fromString("6.2"); tester.upgradeSystem(version); - Application app = tester.createApplication("app1", "tenant1", 1, 11L); + Instance app = tester.createApplication("app1", "tenant1", 1, 11L); tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit(); tester.deployAndNotify(app, applicationPackage, true, systemTest); tester.deployAndNotify(app, applicationPackage, true, stagingTest); @@ -389,13 +389,13 @@ public class UpgraderTest { tester.upgradeSystem(version); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application default3 = tester.createAndDeploy("default3", 6, "default"); - Application default4 = tester.createAndDeploy("default4", 7, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance default3 = tester.createAndDeploy("default3", 6, "default"); + Instance default4 = tester.createAndDeploy("default4", 7, "default"); // New version is released version = Version.fromString("6.3"); @@ -455,13 +455,13 @@ public class UpgraderTest { tester.upgradeSystem(v0); // Setup applications on V0 - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application default3 = tester.createAndDeploy("default3", 6, "default"); - Application default4 = tester.createAndDeploy("default4", 7, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance default3 = tester.createAndDeploy("default3", 6, "default"); + Instance default4 = tester.createAndDeploy("default4", 7, "default"); // V1 is released Version v1 = Version.fromString("6.3"); @@ -542,13 +542,13 @@ public class UpgraderTest { ApplicationPackage defaultPolicy = DeploymentTester.applicationPackage("default"); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, canaryPolicy); - Application canary1 = tester.createAndDeploy("canary1", 2, canaryPolicy); - Application default0 = tester.createAndDeploy("default0", 3, defaultPolicy); - Application default1 = tester.createAndDeploy("default1", 4, defaultPolicy); - Application default2 = tester.createAndDeploy("default2", 5, defaultPolicy); - Application default3 = tester.createAndDeploy("default3", 6, defaultPolicy); - Application default4 = tester.createAndDeploy("default4", 7, defaultPolicy); + Instance canary0 = tester.createAndDeploy("canary0", 1, canaryPolicy); + Instance canary1 = tester.createAndDeploy("canary1", 2, canaryPolicy); + Instance default0 = tester.createAndDeploy("default0", 3, defaultPolicy); + Instance default1 = tester.createAndDeploy("default1", 4, defaultPolicy); + Instance default2 = tester.createAndDeploy("default2", 5, defaultPolicy); + Instance default3 = tester.createAndDeploy("default3", 6, defaultPolicy); + Instance default4 = tester.createAndDeploy("default4", 7, defaultPolicy); // New version is released version = Version.fromString("6.3"); @@ -600,7 +600,7 @@ public class UpgraderTest { .region("us-west-1") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); // New version is released version = Version.fromString("6.3"); @@ -643,7 +643,7 @@ public class UpgraderTest { .region("us-east-3") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); // New version is released version = Version.fromString("6.3"); @@ -680,7 +680,7 @@ public class UpgraderTest { .region("us-east-3") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); // New version is released version = Version.fromString("6.3"); @@ -758,13 +758,13 @@ public class UpgraderTest { .build(); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, canaryApplicationPackage); - Application canary1 = tester.createAndDeploy("canary1", 2, canaryApplicationPackage); - Application default0 = tester.createAndDeploy("default0", 3, defaultApplicationPackage); - Application default1 = tester.createAndDeploy("default1", 4, defaultApplicationPackage); - Application default2 = tester.createAndDeploy("default2", 5, defaultApplicationPackage); - Application default3 = tester.createAndDeploy("default3", 6, defaultApplicationPackage); - Application default4 = tester.createAndDeploy("default4", 7, defaultApplicationPackage); + Instance canary0 = tester.createAndDeploy("canary0", 1, canaryApplicationPackage); + Instance canary1 = tester.createAndDeploy("canary1", 2, canaryApplicationPackage); + Instance default0 = tester.createAndDeploy("default0", 3, defaultApplicationPackage); + Instance default1 = tester.createAndDeploy("default1", 4, defaultApplicationPackage); + Instance default2 = tester.createAndDeploy("default2", 5, defaultApplicationPackage); + Instance default3 = tester.createAndDeploy("default3", 6, defaultApplicationPackage); + Instance default4 = tester.createAndDeploy("default4", 7, defaultApplicationPackage); assertEquals(version, default0.oldestDeployedPlatform().get()); @@ -810,7 +810,7 @@ public class UpgraderTest { tester.jobCompletion(stagingTest).application(default4).unsuccessful().submit(); // 5th app never reports back and has a dead job, but no ongoing change - Application deadLocked = tester.applications().require(default4.id()); + Instance deadLocked = tester.applications().require(default4.id()); tester.assertRunning(systemTest, deadLocked.id()); assertFalse("No change present", deadLocked.change().hasTargets()); @@ -857,15 +857,15 @@ public class UpgraderTest { upgrader.setUpgradesPerMinute(0.2); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application default0 = tester.createAndDeploy("default0", 3, "default"); - Application default1 = tester.createAndDeploy("default1", 4, "default"); - Application default2 = tester.createAndDeploy("default2", 5, "default"); - Application default3 = tester.createAndDeploy("default3", 6, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance default0 = tester.createAndDeploy("default0", 3, "default"); + Instance default1 = tester.createAndDeploy("default1", 4, "default"); + Instance default2 = tester.createAndDeploy("default2", 5, "default"); + Instance default3 = tester.createAndDeploy("default3", 6, "default"); // Dev deployment which should be ignored - Application dev0 = tester.createApplication("dev0", "tenant1", 7, 1L); + Instance dev0 = tester.createApplication("dev0", "tenant1", 7, 1L); tester.controllerTester().deploy(dev0, ZoneId.from(Environment.dev, RegionName.from("dev-region"))); // New version is released and canaries upgrade @@ -910,8 +910,8 @@ public class UpgraderTest { .build(); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application default0 = tester.createAndDeploy("default0", 2, version6ApplicationPackage); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance default0 = tester.createAndDeploy("default0", 2, version6ApplicationPackage); // New major version is released version = Version.fromString("7.0"); @@ -944,8 +944,8 @@ public class UpgraderTest { .build(); // Setup applications - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application default0 = tester.createAndDeploy("default0", 2, default0ApplicationPackage); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance default0 = tester.createAndDeploy("default0", 2, default0ApplicationPackage); tester.applications().lockOrThrow(default0.id(), a -> tester.applications().store(a.withMajorVersion(6))); assertEquals(OptionalInt.of(6), tester.applications().get(default0.id()).get().majorVersion()); @@ -987,9 +987,9 @@ public class UpgraderTest { .build(); // Setup applications - Application canary0 = tester.createAndDeploy("canary", 1, version7CanaryApplicationPackage); - Application default0 = tester.createAndDeploy("default0", 2, version7DefaultApplicationPackage); - Application default1 = tester.createAndDeploy("default1", 3, "default"); + Instance canary0 = tester.createAndDeploy("canary", 1, version7CanaryApplicationPackage); + Instance default0 = tester.createAndDeploy("default0", 2, version7DefaultApplicationPackage); + Instance default1 = tester.createAndDeploy("default1", 3, "default"); // New major version is released, but we don't want to upgrade to it yet tester.upgrader().setTargetMajorVersion(Optional.of(6)); @@ -1034,7 +1034,7 @@ public class UpgraderTest { .region("us-west-1") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); // New version is released version = Version.fromString("6.3"); @@ -1087,7 +1087,7 @@ public class UpgraderTest { .region("us-east-3") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); tester.jobCompletion(component).application(app).nextBuildNumber().uploadArtifact(applicationPackage).submit(); @@ -1139,7 +1139,7 @@ public class UpgraderTest { .region("us-east-3") .build(); - Application app = tester.createAndDeploy("app1", 1, applicationPackage); + Instance app = tester.createAndDeploy("app1", 1, applicationPackage); tester.jobCompletion(component).application(app).nextBuildNumber().uploadArtifact(applicationPackage).submit(); @@ -1183,61 +1183,61 @@ public class UpgraderTest { tester.upgradeSystem(version0); // Create an application with pinned platform version. - Application application = tester.createApplication("application", "tenant", 2, 3); + Instance instance = tester.createApplication("application", "tenant", 2, 3); ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod) .region("us-east-3") .region("us-west-1") .build(); - tester.deploymentTrigger().forceChange(application.id(), Change.empty().withPin()); + tester.deploymentTrigger().forceChange(instance.id(), Change.empty().withPin()); - tester.deployCompletely(application, applicationPackage); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertTrue(tester.application(application.id()).change().isPinned()); - assertEquals(2, tester.application(application.id()).deployments().size()); + tester.deployCompletely(instance, applicationPackage); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertTrue(tester.application(instance.id()).change().isPinned()); + assertEquals(2, tester.application(instance.id()).deployments().size()); // Application does not upgrade. Version version1 = Version.fromString("6.3"); tester.upgradeSystem(version1); tester.upgrader().maintain(); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertTrue(tester.application(application.id()).change().isPinned()); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertTrue(tester.application(instance.id()).change().isPinned()); // New application package is deployed. - tester.deployCompletely(application, applicationPackage, BuildJob.defaultBuildNumber + 1); - assertFalse(tester.application(application.id()).change().hasTargets()); - assertTrue(tester.application(application.id()).change().isPinned()); + tester.deployCompletely(instance, applicationPackage, BuildJob.defaultBuildNumber + 1); + assertFalse(tester.application(instance.id()).change().hasTargets()); + assertTrue(tester.application(instance.id()).change().isPinned()); // Application upgrades to new version when pin is removed. - tester.deploymentTrigger().cancelChange(application.id(), PIN); + tester.deploymentTrigger().cancelChange(instance.id(), PIN); tester.upgrader().maintain(); - assertTrue(tester.application(application.id()).change().hasTargets()); - assertFalse(tester.application(application.id()).change().isPinned()); + assertTrue(tester.application(instance.id()).change().hasTargets()); + assertFalse(tester.application(instance.id()).change().isPinned()); // Application is pinned to new version, and upgrade is therefore not cancelled, even though confidence is broken. - tester.deploymentTrigger().forceChange(application.id(), Change.empty().withPin()); + tester.deploymentTrigger().forceChange(instance.id(), Change.empty().withPin()); tester.upgrader().maintain(); tester.readyJobTrigger().maintain(); - assertEquals(version1, tester.application(application.id()).change().platform().get()); + assertEquals(version1, tester.application(instance.id()).change().platform().get()); // Application fails upgrade after one zone is complete, and is pinned again to the old version. - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsEast3); - tester.deploy(productionUsWest1, application, Optional.empty(), false); - tester.deployAndNotify(application, false, productionUsWest1); - tester.deploymentTrigger().cancelChange(application.id(), ALL); - tester.deploymentTrigger().forceChange(application.id(), Change.of(version0).withPin()); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsEast3); + tester.deploy(productionUsWest1, instance, Optional.empty(), false); + tester.deployAndNotify(instance, false, productionUsWest1); + tester.deploymentTrigger().cancelChange(instance.id(), ALL); + tester.deploymentTrigger().forceChange(instance.id(), Change.of(version0).withPin()); tester.buildService().clear(); - assertEquals(version0, tester.application(application.id()).change().platform().get()); + assertEquals(version0, tester.application(instance.id()).change().platform().get()); // Application downgrades to pinned version. tester.readyJobTrigger().maintain(); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsEast3); - assertTrue(tester.application(application.id()).change().hasTargets()); - tester.deployAndNotify(application, true, productionUsWest1); - assertFalse(tester.application(application.id()).change().hasTargets()); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsEast3); + assertTrue(tester.application(instance.id()).change().hasTargets()); + tester.deployAndNotify(instance, true, productionUsWest1); + assertFalse(tester.application(instance.id()).change().hasTargets()); } @Test @@ -1250,8 +1250,8 @@ public class UpgraderTest { tester.upgrader().setTargetMajorVersion(Optional.of(6)); // All applications deploy on current version - Application app1 = tester.createAndDeploy("app1", 1, "default"); - Application app2 = tester.createAndDeploy("app2", 1, "default"); + Instance app1 = tester.createAndDeploy("app1", 1, "default"); + Instance app2 = tester.createAndDeploy("app2", 1, "default"); // Keep app 1 on current version tester.controller().applications().lockIfPresent(app1.id(), app -> tester.controller().applications().store(app.withChange(app.get().change().withPin()))); @@ -1283,8 +1283,8 @@ public class UpgraderTest { @Test public void testsEachUpgradeCombinationWithFailingDeployments() { DeploymentTester tester = new DeploymentTester(); - Application application = tester.createApplication("app1", "tenant1", 1, 1L); - Supplier<Application> app = () -> tester.application(application.id()); + Instance instance = tester.createApplication("app1", "tenant1", 1, 1L); + Supplier<Instance> app = () -> tester.application(instance.id()); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") @@ -1294,22 +1294,22 @@ public class UpgraderTest { // Application deploys on system version Version v1 = Version.fromString("6.1"); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // Next version is released and 2/3 deployments upgrade Version v2 = Version.fromString("6.2"); tester.upgradeSystem(v2); tester.upgrader().maintain(); assertEquals(Change.of(v2), app.get().change()); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); - tester.deployAndNotify(application, true, productionUsCentral1); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); + tester.deployAndNotify(instance, true, productionUsCentral1); // While second deployment completes upgrade, version confidence becomes broken and upgrade is cancelled tester.upgrader().overrideConfidence(v2, VespaVersion.Confidence.broken); tester.computeVersionStatus(); tester.upgrader().maintain(); - tester.deployAndNotify(application, true, productionUsWest1); + tester.deployAndNotify(instance, true, productionUsWest1); assertTrue(app.get().change().isEmpty()); // Next version is released @@ -1317,21 +1317,21 @@ public class UpgraderTest { tester.upgradeSystem(v3); tester.upgrader().maintain(); assertEquals(Change.of(v3), app.get().change()); - tester.deployAndNotify(application, true, systemTest); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, systemTest); + tester.deployAndNotify(instance, true, stagingTest); // First deployment starts upgrading - tester.deploy(productionUsCentral1, application, applicationPackage); + tester.deploy(productionUsCentral1, instance, applicationPackage); // Before deployment completes, v1->v3 combination is tested as us-east-3 is still on v1 tester.readyJobTrigger().maintain(); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, stagingTest); assertEquals(v1, app.get().deploymentJobs().jobStatus().get(stagingTest).lastSuccess().get().sourcePlatform().get()); assertEquals(v3, app.get().deploymentJobs().jobStatus().get(stagingTest).lastSuccess().get().platform()); // First deployment fails and then successfully upgrades to v3 - tester.jobCompletion(productionUsCentral1).application(application).unsuccessful().submit(); - tester.jobCompletion(productionUsCentral1).application(application).submit(); + tester.jobCompletion(productionUsCentral1).application(instance).unsuccessful().submit(); + tester.jobCompletion(productionUsCentral1).application(instance).submit(); // Deployments are now on 3 versions assertEquals(v3, app.get().deployments().get(productionUsCentral1.zone(main)).version()); @@ -1342,19 +1342,19 @@ public class UpgraderTest { tester.readyJobTrigger().maintain(); assertEquals(v2, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().sourcePlatform().get()); assertEquals(v3, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, stagingTest); // Second deployment upgrades - tester.deployAndNotify(application, true, productionUsWest1); + tester.deployAndNotify(instance, true, productionUsWest1); // ... now we have to test v1->v3 again :( tester.readyJobTrigger().maintain(); assertEquals(v1, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().sourcePlatform().get()); assertEquals(v3, app.get().deploymentJobs().jobStatus().get(stagingTest).lastTriggered().get().platform()); - tester.deployAndNotify(application, true, stagingTest); + tester.deployAndNotify(instance, true, stagingTest); // Upgrade completes - tester.deployAndNotify(application, true, productionUsEast3); + tester.deployAndNotify(instance, true, productionUsEast3); assertTrue("Upgrade complete", app.get().change().isEmpty()); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java index 16f57a61916..25193688d85 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java @@ -8,7 +8,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.config.SlimeUtils; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision; @@ -104,22 +104,22 @@ public class ApplicationSerializerTest { Map.of(ZoneId.from("prod", "us-west-1"), RotationState.in, ZoneId.from("prod", "us-east-3"), RotationState.out))); - Application original = new Application(ApplicationId.from("t1", "a1", "i1"), - Instant.now().truncatedTo(ChronoUnit.MILLIS), - deploymentSpec, - validationOverrides, - deployments, deploymentJobs, - Change.of(Version.fromString("6.7")).withPin(), - Change.of(ApplicationVersion.from(new SourceRevision("repo", "master", "deadcafe"), 42)), - Optional.of(IssueId.from("1234")), - Optional.of(User.from("by-username")), - OptionalInt.of(7), - new ApplicationMetrics(0.5, 0.9), - Optional.of("-----BEGIN PUBLIC KEY-----\n∠( ᐛ 」∠)_\n-----END PUBLIC KEY-----"), - List.of(AssignedRotation.fromStrings("foo", "default", "my-rotation", Set.of())), - rotationStatus); - - Application serialized = applicationSerializer.fromSlime(applicationSerializer.toSlime(original)); + Instance original = new Instance(ApplicationId.from("t1", "a1", "i1"), + Instant.now().truncatedTo(ChronoUnit.MILLIS), + deploymentSpec, + validationOverrides, + deployments, deploymentJobs, + Change.of(Version.fromString("6.7")).withPin(), + Change.of(ApplicationVersion.from(new SourceRevision("repo", "master", "deadcafe"), 42)), + Optional.of(IssueId.from("1234")), + Optional.of(User.from("by-username")), + OptionalInt.of(7), + new ApplicationMetrics(0.5, 0.9), + Optional.of("-----BEGIN PUBLIC KEY-----\n∠( ᐛ 」∠)_\n-----END PUBLIC KEY-----"), + List.of(AssignedRotation.fromStrings("foo", "default", "my-rotation", Set.of())), + rotationStatus); + + Instance serialized = applicationSerializer.fromSlime(applicationSerializer.toSlime(original)); assertEquals(original.id(), serialized.id()); assertEquals(original.createdAt(), serialized.createdAt()); @@ -183,27 +183,27 @@ public class ApplicationSerializerTest { assertEquals(original.deployments().get(zone2).metrics().instant(), serialized.deployments().get(zone2).metrics().instant()); assertEquals(original.deployments().get(zone2).metrics().warnings(), serialized.deployments().get(zone2).metrics().warnings()); { // test more deployment serialization cases - Application original2 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 42))).get(); - Application serialized2 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original2)); + Instance original2 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 42))).get(); + Instance serialized2 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original2)); assertEquals(original2.change(), serialized2.change()); assertEquals(serialized2.change().application().get().source(), original2.change().application().get().source()); - Application original3 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); - Application serialized3 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original3)); + Instance original3 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); + Instance serialized3 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original3)); assertEquals(original3.change(), serialized3.change()); assertEquals(serialized3.change().application().get().source(), original3.change().application().get().source()); - Application original4 = writable(original).withChange(Change.empty()).get(); - Application serialized4 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original4)); + Instance original4 = writable(original).withChange(Change.empty()).get(); + Instance serialized4 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original4)); assertEquals(original4.change(), serialized4.change()); - Application original5 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); - Application serialized5 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original5)); + Instance original5 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); + Instance serialized5 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original5)); assertEquals(original5.change(), serialized5.change()); - Application original6 = writable(original).withOutstandingChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); - Application serialized6 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original6)); + Instance original6 = writable(original).withOutstandingChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42))).get(); + Instance serialized6 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original6)); assertEquals(original6.outstandingChange(), serialized6.outstandingChange()); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java index ea051efcd02..b8a0610bedd 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java @@ -11,7 +11,7 @@ import com.yahoo.vespa.athenz.api.AthenzDomain; import com.yahoo.vespa.athenz.api.AthenzPrincipal; import com.yahoo.vespa.athenz.api.AthenzUser; import com.yahoo.vespa.athenz.api.OktaAccessToken; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; @@ -64,11 +64,11 @@ public class ContainerControllerTester { /** Returns the wrapped generic container tester */ public ContainerTester containerTester() { return containerTester; } - public Application createApplication() { + public Instance createApplication() { return createApplication("domain1","tenant1", "application1", "default"); } - public Application createApplication(String athensDomain, String tenant, String application, String instance) { + public Instance createApplication(String athensDomain, String tenant, String application, String instance) { AthenzDomain domain1 = addTenantAthenzDomain(athensDomain, "user"); AthenzPrincipal user = new AthenzPrincipal(new AthenzUser("user")); AthenzCredentials credentials = new AthenzCredentials(user, domain1, new OktaAccessToken("okta-token")); @@ -82,15 +82,15 @@ public class ContainerControllerTester { return controller().applications().createApplication(app, Optional.of(credentials)); } - public Application deploy(Application application, ApplicationPackage applicationPackage, ZoneId zone) { - controller().applications().deploy(application.id(), zone, Optional.of(applicationPackage), + public Instance deploy(Instance instance, ApplicationPackage applicationPackage, ZoneId zone) { + controller().applications().deploy(instance.id(), zone, Optional.of(applicationPackage), new DeployOptions(false, Optional.empty(), false, false)); - return application; + return instance; } - public void deployCompletely(Application application, ApplicationPackage applicationPackage, long projectId, + public void deployCompletely(Instance instance, ApplicationPackage applicationPackage, long projectId, boolean failStaging) { - jobCompletion(JobType.component).application(application) + jobCompletion(JobType.component).application(instance) .projectId(projectId) .uploadArtifact(applicationPackage) .submit(); @@ -99,14 +99,14 @@ public class ContainerControllerTester { for (var job : steps.jobs()) { if (!succeeding) return; var zone = job.zone(controller().system()); - deploy(application, applicationPackage, zone); + deploy(instance, applicationPackage, zone); if (failStaging && zone.environment() == Environment.staging) { succeeding = false; } if (zone.environment().isTest()) { - controller().applications().deactivate(application.id(), zone); + controller().applications().deactivate(instance.id(), zone); } - jobCompletion(job).application(application).success(succeeding).projectId(projectId).submit(); + jobCompletion(job).application(instance).success(succeeding).projectId(projectId).submit(); } } @@ -128,13 +128,13 @@ public class ContainerControllerTester { /* * Authorize action on tenantDomain/application for a given screwdriverId */ - public void authorize(AthenzDomain tenantDomain, ScrewdriverId screwdriverId, ApplicationAction action, Application application) { + public void authorize(AthenzDomain tenantDomain, ScrewdriverId screwdriverId, ApplicationAction action, Instance instance) { AthenzClientFactoryMock mock = (AthenzClientFactoryMock) containerTester.container().components() .getComponent(AthenzClientFactoryMock.class.getName()); mock.getSetup() .domains.get(tenantDomain) - .applications.get(new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(application.id().application().value())) + .applications.get(new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(instance.id().application().value())) .addRoleMember(action, HostedAthenzIdentities.from(screwdriverId)); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 8013987c772..b2494be65b1 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -21,7 +21,7 @@ import com.yahoo.vespa.athenz.api.AthenzIdentity; import com.yahoo.vespa.athenz.api.AthenzUser; import com.yahoo.vespa.athenz.api.OktaAccessToken; import com.yahoo.vespa.config.SlimeUtils; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.LockedTenant; import com.yahoo.vespa.hosted.controller.api.application.v4.EnvironmentResource; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; @@ -1238,12 +1238,12 @@ public class ApplicationApiTest extends ControllerContainerTest { createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); configureAthenzIdentity(new com.yahoo.vespa.athenz.api.AthenzService(new AthenzDomain("another.domain"), "service"), true); - Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); + Instance instance = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); ScrewdriverId screwdriverId = new ScrewdriverId(Long.toString(screwdriverProjectId)); - controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application); + controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, instance); controllerTester.jobCompletion(JobType.component) - .application(application.id()) + .application(instance.id()) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) .submit(); @@ -1270,12 +1270,12 @@ public class ApplicationApiTest extends ControllerContainerTest { createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); configureAthenzIdentity(new com.yahoo.vespa.athenz.api.AthenzService(ATHENZ_TENANT_DOMAIN, "service"), true); - Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); - controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application); + Instance instance = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); + controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, instance); // Allow systemtest to succeed by notifying completion of system test controllerTester.jobCompletion(JobType.component) - .application(application.id()) + .application(instance.id()) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) .submit(); @@ -1367,12 +1367,12 @@ public class ApplicationApiTest extends ControllerContainerTest { createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); configureAthenzIdentity(new com.yahoo.vespa.athenz.api.AthenzService(ATHENZ_TENANT_DOMAIN, "service"), false); - Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); - controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application); + Instance instance = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); + controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, instance); // Allow systemtest to succeed by notifying completion of system test controllerTester.jobCompletion(JobType.component) - .application(application.id()) + .application(instance.id()) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) .submit(); @@ -1404,12 +1404,12 @@ public class ApplicationApiTest extends ControllerContainerTest { createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); configureAthenzIdentity(new com.yahoo.vespa.athenz.api.AthenzService(ATHENZ_TENANT_DOMAIN, "service"), true); - Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); - controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application); + Instance instance = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1", "default"); + controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, instance); // Allow systemtest to succeed by notifying completion of system test controllerTester.jobCompletion(JobType.component) - .application(application.id()) + .application(instance.id()) .projectId(screwdriverProjectId) .uploadArtifact(applicationPackage) .submit(); @@ -1430,7 +1430,7 @@ public class ApplicationApiTest extends ControllerContainerTest { addUserToHostedOperatorRole(HostedAthenzIdentities.from(HOSTED_VESPA_OPERATOR)); tester.computeVersionStatus(); long projectId = 1; - Application app = controllerTester.createApplication(); + Instance app = controllerTester.createApplication(); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") @@ -1482,7 +1482,7 @@ public class ApplicationApiTest extends ControllerContainerTest { controllerTester.containerTester().computeVersionStatus(); long projectId = 1; - Application app = controllerTester.createApplication(); + Instance app = controllerTester.createApplication(); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-central-1") @@ -1511,7 +1511,7 @@ public class ApplicationApiTest extends ControllerContainerTest { @Test public void applicationWithRoutingPolicy() { - Application app = controllerTester.createApplication(); + Instance app = controllerTester.createApplication(); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .environment(Environment.prod) .region("us-west-1") @@ -1715,11 +1715,11 @@ public class ApplicationApiTest extends ControllerContainerTest { * This sets these values as if the maintainers has been ran. */ private void setDeploymentMaintainedInfo(ContainerControllerTester controllerTester) { - for (Application application : controllerTester.controller().applications().asList()) { - controllerTester.controller().applications().lockOrThrow(application.id(), lockedApplication -> { + for (Instance instance : controllerTester.controller().applications().asList()) { + controllerTester.controller().applications().lockOrThrow(instance.id(), lockedApplication -> { lockedApplication = lockedApplication.with(new ApplicationMetrics(0.5, 0.7)); - for (Deployment deployment : application.deployments().values()) { + for (Deployment deployment : instance.deployments().values()) { Map<ClusterSpec.Id, ClusterInfo> clusterInfo = new HashMap<>(); List<String> hostnames = new ArrayList<>(); hostnames.add("host1"); @@ -1752,8 +1752,8 @@ public class ApplicationApiTest extends ControllerContainerTest { new RotationStatusUpdater(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator())).run(); } - private RotationStatus rotationStatus(Application application) { - return controllerTester.controller().applications().rotationRepository().getRotation(application) + private RotationStatus rotationStatus(Instance instance) { + return controllerTester.controller().applications().rotationRepository().getRotation(instance) .map(rotation -> { var rotationStatus = controllerTester.controller().serviceRegistry().globalRoutingService().getHealthStatus(rotation.name()); var statusMap = new LinkedHashMap<ZoneId, RotationState>(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java index 35ec5b0e37e..09555dd9f2e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.controller.restapi.deployment; import com.yahoo.config.provision.AthenzService; import com.yahoo.config.provision.Environment; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -20,13 +20,13 @@ public class BadgeApiTest extends ControllerContainerTest { @Test public void testBadgeApi() { ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles); - Application application = tester.createApplication("domain", "tenant", "application", "default"); + Instance instance = tester.createApplication("domain", "tenant", "application", "default"); ApplicationPackage packageWithService = new ApplicationPackageBuilder() .environment(Environment.prod) .athenzIdentity(com.yahoo.config.provision.AthenzDomain.from("domain"), AthenzService.from("service")) .region("us-west-1") .build(); - tester.controller().jobController().submit(application.id(), + tester.controller().jobController().submit(instance.id(), new SourceRevision("repository", "branch", "commit"), "foo@bar", 123, diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java index d6620733efe..adf48ea37cb 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java @@ -6,7 +6,7 @@ import com.yahoo.component.Version; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -39,15 +39,15 @@ public class DeploymentApiTest extends ControllerContainerTest { .build(); // 3 applications deploy on current system version - Application failingApplication = tester.createApplication("domain1", "tenant1", "application1", "default"); - Application productionApplication = tester.createApplication("domain2", "tenant2", "application2", "default"); - Application applicationWithoutDeployment = tester.createApplication("domain3", "tenant3", "application3", "default"); - tester.deployCompletely(failingApplication, applicationPackage, 1L, false); - tester.deployCompletely(productionApplication, applicationPackage, 2L, false); + Instance failingInstance = tester.createApplication("domain1", "tenant1", "application1", "default"); + Instance productionInstance = tester.createApplication("domain2", "tenant2", "application2", "default"); + Instance instanceWithoutDeployment = tester.createApplication("domain3", "tenant3", "application3", "default"); + tester.deployCompletely(failingInstance, applicationPackage, 1L, false); + tester.deployCompletely(productionInstance, applicationPackage, 2L, false); // Deploy once so that job information is stored, then remove the deployment - tester.deployCompletely(applicationWithoutDeployment, applicationPackage, 3L, false); - tester.controller().applications().deactivate(applicationWithoutDeployment.id(), ZoneId.from("prod", "us-west-1")); + tester.deployCompletely(instanceWithoutDeployment, applicationPackage, 3L, false); + tester.controller().applications().deactivate(instanceWithoutDeployment.id(), ZoneId.from("prod", "us-west-1")); // New version released version = Version.fromString("5.1"); @@ -57,8 +57,8 @@ public class DeploymentApiTest extends ControllerContainerTest { tester.upgrader().maintain(); tester.controller().applications().deploymentTrigger().triggerReadyJobs(); tester.controller().applications().deploymentTrigger().triggerReadyJobs(); - tester.deployCompletely(failingApplication, applicationPackage, 1L, true); - tester.deployCompletely(productionApplication, applicationPackage, 2L, false); + tester.deployCompletely(failingInstance, applicationPackage, 1L, true); + tester.deployCompletely(productionInstance, applicationPackage, 2L, false); tester.controller().updateVersionStatus(censorConfigServers(VersionStatus.compute(tester.controller()), tester.controller())); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java index 4e93922784e..78f36fdf4a3 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.controller.rotation; import com.yahoo.config.provision.SystemName; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.AssignedRotation; @@ -50,27 +50,27 @@ public class RotationRepositoryTest { private DeploymentTester tester; private RotationRepository repository; - private Application application; + private Instance instance; @Before public void before() { tester = new DeploymentTester(new ControllerTester(rotationsConfig)); repository = tester.controller().applications().rotationRepository(); - application = tester.createApplication("app1", "tenant1", 11L,1L); + instance = tester.createApplication("app1", "tenant1", 11L, 1L); } @Test public void assigns_and_reuses_rotation() { // Deploying assigns a rotation - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); Rotation expected = new Rotation(new RotationId("foo-1"), "foo-1.com"); - application = tester.applications().require(application.id()); - assertEquals(List.of(expected.id()), rotationIds(application.rotations())); + instance = tester.applications().require(instance.id()); + assertEquals(List.of(expected.id()), rotationIds(instance.rotations())); assertEquals(URI.create("https://app1--tenant1.global.vespa.oath.cloud:4443/"), - application.endpointsIn(SystemName.main).main().get().url()); + instance.endpointsIn(SystemName.main).main().get().url()); try (RotationLock lock = repository.lock()) { - Rotation rotation = repository.getOrAssignRotation(tester.applications().require(application.id()), lock); + Rotation rotation = repository.getOrAssignRotation(tester.applications().require(instance.id()), lock); assertEquals(expected, rotation); } @@ -81,21 +81,21 @@ public class RotationRepositoryTest { .region("us-west-1") .searchDefinition("search foo { }") // Update application package so there is something to deploy .build(); - tester.deployCompletely(application, applicationPackage, 43); - assertEquals(List.of(expected.id()), rotationIds(tester.applications().require(application.id()).rotations())); + tester.deployCompletely(instance, applicationPackage, 43); + assertEquals(List.of(expected.id()), rotationIds(tester.applications().require(instance.id()).rotations())); } @Test public void strips_whitespace_in_rotation_fqdn() { DeploymentTester tester = new DeploymentTester(new ControllerTester(rotationsConfigWhitespaces)); RotationRepository repository = tester.controller().applications().rotationRepository(); - Application application = tester.createApplication("app2", "tenant2", 22L, - 2L); - tester.deployCompletely(application, applicationPackage); - application = tester.applications().require(application.id()); + Instance instance = tester.createApplication("app2", "tenant2", 22L, + 2L); + tester.deployCompletely(instance, applicationPackage); + instance = tester.applications().require(instance.id()); try (RotationLock lock = repository.lock()) { - Rotation rotation = repository.getOrAssignRotation(application, lock); + Rotation rotation = repository.getOrAssignRotation(instance, lock); Rotation assignedRotation = new Rotation(new RotationId("foo-1"), "foo-1.com"); assertEquals(assignedRotation, rotation); } @@ -104,19 +104,19 @@ public class RotationRepositoryTest { @Test public void out_of_rotations() { // Assigns 1 rotation - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); // Assigns 1 more - Application application2 = tester.createApplication("app2", "tenant2", 22L, - 2L); - tester.deployCompletely(application2, applicationPackage); + Instance instance2 = tester.createApplication("app2", "tenant2", 22L, + 2L); + tester.deployCompletely(instance2, applicationPackage); // We're now out of rotations thrown.expect(IllegalStateException.class); thrown.expectMessage("no rotations available"); - Application application3 = tester.createApplication("app3", "tenant3", 33L, - 3L); - tester.deployCompletely(application3, applicationPackage); + Instance instance3 = tester.createApplication("app3", "tenant3", 33L, + 3L); + tester.deployCompletely(instance3, applicationPackage); } @Test @@ -125,11 +125,11 @@ public class RotationRepositoryTest { .globalServiceId("foo") .region("us-east-3") .build(); - Application application = tester.createApplication("app2", "tenant2", 22L, - 2L); + Instance instance = tester.createApplication("app2", "tenant2", 22L, + 2L); thrown.expect(RuntimeException.class); thrown.expectMessage("less than 2 prod zones are defined"); - tester.deployCompletely(application, applicationPackage); + tester.deployCompletely(instance, applicationPackage); } @Test @@ -138,8 +138,8 @@ public class RotationRepositoryTest { .region("us-east-3") .region("us-west-1") .build(); - tester.deployCompletely(application, applicationPackage); - Application app = tester.applications().require(application.id()); + tester.deployCompletely(instance, applicationPackage); + Instance app = tester.applications().require(instance.id()); assertTrue(app.rotations().isEmpty()); } @@ -150,11 +150,11 @@ public class RotationRepositoryTest { .region("us-east-3") .region("us-west-1") .build(); - Application application = tester.createApplication("app2", "tenant2", 22L, - 2L); - tester.deployCompletely(application, applicationPackage); - assertEquals(List.of(new RotationId("foo-1")), rotationIds(tester.applications().require(application.id()).rotations())); - assertEquals("https://cd--app2--tenant2.global.vespa.oath.cloud:4443/", tester.applications().require(application.id()) + Instance instance = tester.createApplication("app2", "tenant2", 22L, + 2L); + tester.deployCompletely(instance, applicationPackage); + assertEquals(List.of(new RotationId("foo-1")), rotationIds(tester.applications().require(instance.id()).rotations())); + assertEquals("https://cd--app2--tenant2.global.vespa.oath.cloud:4443/", tester.applications().require(instance.id()) .endpointsIn(SystemName.cd).main().get().url().toString()); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java index 94201832adb..3d12fe382ce 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/versions/VersionStatusTest.java @@ -7,7 +7,7 @@ import com.yahoo.component.Vtag; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneApi; -import com.yahoo.vespa.hosted.controller.Application; +import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; @@ -135,9 +135,9 @@ public class VersionStatusTest { tester.upgradeSystem(version1); // Setup applications - Application app1 = tester.createAndDeploy("app1", 11, applicationPackage); - Application app2 = tester.createAndDeploy("app2", 22, applicationPackage); - Application app3 = tester.createAndDeploy("app3", 33, applicationPackage); + Instance app1 = tester.createAndDeploy("app1", 11, applicationPackage); + Instance app2 = tester.createAndDeploy("app2", 22, applicationPackage); + Instance app3 = tester.createAndDeploy("app3", 33, applicationPackage); // version2 is released tester.upgradeSystem(version2); @@ -175,25 +175,25 @@ public class VersionStatusTest { tester.upgradeSystem(version0); // Setup applications - all running on version0 - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 2, "canary"); - Application canary2 = tester.createAndDeploy("canary2", 3, "canary"); - Application default0 = tester.createAndDeploy("default0", 4, "default"); - Application default1 = tester.createAndDeploy("default1", 5, "default"); - Application default2 = tester.createAndDeploy("default2", 6, "default"); - Application default3 = tester.createAndDeploy("default3", 7, "default"); - Application default4 = tester.createAndDeploy("default4", 8, "default"); - Application default5 = tester.createAndDeploy("default5", 9, "default"); - Application default6 = tester.createAndDeploy("default6", 10, "default"); - Application default7 = tester.createAndDeploy("default7", 11, "default"); - Application default8 = tester.createAndDeploy("default8", 12, "default"); - Application default9 = tester.createAndDeploy("default9", 13, "default"); - Application conservative0 = tester.createAndDeploy("conservative1", 14, "conservative"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 2, "canary"); + Instance canary2 = tester.createAndDeploy("canary2", 3, "canary"); + Instance default0 = tester.createAndDeploy("default0", 4, "default"); + Instance default1 = tester.createAndDeploy("default1", 5, "default"); + Instance default2 = tester.createAndDeploy("default2", 6, "default"); + Instance default3 = tester.createAndDeploy("default3", 7, "default"); + Instance default4 = tester.createAndDeploy("default4", 8, "default"); + Instance default5 = tester.createAndDeploy("default5", 9, "default"); + Instance default6 = tester.createAndDeploy("default6", 10, "default"); + Instance default7 = tester.createAndDeploy("default7", 11, "default"); + Instance default8 = tester.createAndDeploy("default8", 12, "default"); + Instance default9 = tester.createAndDeploy("default9", 13, "default"); + Instance conservative0 = tester.createAndDeploy("conservative1", 14, "conservative"); // Applications that do not affect confidence calculation: // Application without deployment - Application ignored0 = tester.createApplication("ignored0", "tenant1", 1000, 1000L); + Instance ignored0 = tester.createApplication("ignored0", "tenant1", 1000, 1000L); assertEquals("All applications running on this version: High", Confidence.high, confidence(tester.controller(), version0)); @@ -310,7 +310,7 @@ public class VersionStatusTest { tester.upgradeSystem(version0); // Create and deploy application on current version - Application app = tester.createAndDeploy("app", 1, "canary"); + Instance app = tester.createAndDeploy("app", 1, "canary"); tester.computeVersionStatus(); assertEquals(Confidence.high, confidence(tester.controller(), version0)); @@ -368,9 +368,9 @@ public class VersionStatusTest { assertEquals(5, tester.hourOfDayAfter(Duration.ZERO)); Version version0 = Version.fromString("7.1"); tester.upgradeSystem(version0); - Application canary0 = tester.createAndDeploy("canary0", 1, "canary"); - Application canary1 = tester.createAndDeploy("canary1", 1, "canary"); - Application default0 = tester.createAndDeploy("default0", 1, "default"); + Instance canary0 = tester.createAndDeploy("canary0", 1, "canary"); + Instance canary1 = tester.createAndDeploy("canary1", 1, "canary"); + Instance default0 = tester.createAndDeploy("default0", 1, "default"); tester.computeVersionStatus(); assertSame(Confidence.high, tester.controller().versionStatus().version(version0).confidence()); |