From fa983c52ee08bf6a88ccda621e5aa510a6e9efab Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Thu, 31 Oct 2019 14:18:57 +0100 Subject: Move defaultSourceRevision to DeploymentContext --- .../java/com/yahoo/vespa/hosted/controller/ControllerTest.java | 3 ++- .../com/yahoo/vespa/hosted/controller/deployment/BuildJob.java | 5 ++--- .../vespa/hosted/controller/deployment/DeploymentContext.java | 3 ++- .../hosted/controller/deployment/InternalDeploymentTester.java | 2 +- .../controller/restapi/application/ApplicationApiTest.java | 9 +++++---- 5 files changed, 12 insertions(+), 10 deletions(-) (limited to 'controller-server/src/test') 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 efce8642294..192c71094a5 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 @@ -31,6 +31,7 @@ import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics; import com.yahoo.vespa.hosted.controller.application.JobStatus; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.BuildJob; +import com.yahoo.vespa.hosted.controller.deployment.DeploymentContext; import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester; import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock; import com.yahoo.vespa.hosted.controller.rotation.RotationId; @@ -83,7 +84,7 @@ public class ControllerTest { var context = tester.deploymentContext(); context.submit(applicationPackage); assertEquals("Application version is known from completion of initial job", - ApplicationVersion.from(BuildJob.defaultSourceRevision, 1, "a@b", new Version("6.1"), Instant.ofEpochSecond(1)), + ApplicationVersion.from(DeploymentContext.defaultSourceRevision, 1, "a@b", new Version("6.1"), Instant.ofEpochSecond(1)), context.application().change().application().get()); context.runJob(systemTest); context.runJob(stagingTest); 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 ce733d60a77..d1303c4a7ed 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 @@ -23,16 +23,15 @@ import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobTy * * @author mpolden */ + public class BuildJob { - public static final SourceRevision defaultSourceRevision = new SourceRevision("repository1", - "master", "commit1"); public static final long defaultBuildNumber = 42; private JobType job; private ApplicationId applicationId; private Optional jobError = Optional.empty(); - private Optional sourceRevision = Optional.of(defaultSourceRevision); + private Optional sourceRevision = Optional.of(DeploymentContext.defaultSourceRevision); private long projectId; private long buildNumber = defaultBuildNumber; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java index a8e7d96710f..95934b528e0 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java @@ -83,6 +83,7 @@ public class DeploymentContext { .emailAddress("b@a") .trust(generateCertificate()) .build(); + public static final SourceRevision defaultSourceRevision = new SourceRevision("repository1", "master", "commit1"); private final TenantAndApplicationId applicationId; private final ApplicationId instanceId; @@ -196,7 +197,7 @@ public class DeploymentContext { /** Submit given application package for deployment */ public DeploymentContext submit(ApplicationPackage applicationPackage) { - return submit(applicationPackage, BuildJob.defaultSourceRevision); + return submit(applicationPackage, defaultSourceRevision); } /** Submit given application package for deployment */ 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 d8261d2d79f..fc38d9d1f52 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 @@ -164,7 +164,7 @@ public class InternalDeploymentTester { } public ApplicationVersion newSubmission(TenantAndApplicationId id, ApplicationPackage applicationPackage) { - return newSubmission(id, applicationPackage, BuildJob.defaultSourceRevision); + return newSubmission(id, applicationPackage, DeploymentContext.defaultSourceRevision); } /** 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 f7af8ff4ce4..54f95078f15 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 @@ -62,6 +62,7 @@ import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId; import com.yahoo.vespa.hosted.controller.athenz.HostedAthenzIdentities; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.BuildJob; +import com.yahoo.vespa.hosted.controller.deployment.DeploymentContext; import com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger; import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; import com.yahoo.vespa.hosted.controller.integration.ServiceRegistryMock; @@ -315,7 +316,7 @@ public class ApplicationApiTest extends ControllerContainerTest { // POST an application deployment to a production zone - operator emergency deployment - fails since package is unknown entity = createApplicationDeployData(Optional.empty(), - Optional.of(ApplicationVersion.from(BuildJob.defaultSourceRevision, + Optional.of(ApplicationVersion.from(DeploymentContext.defaultSourceRevision, BuildJob.defaultBuildNumber - 1)), true); tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-central-1/instance/instance1/", POST) @@ -326,7 +327,7 @@ public class ApplicationApiTest extends ControllerContainerTest { // POST an application deployment to a production zone - operator emergency deployment - works with known package entity = createApplicationDeployData(Optional.empty(), - Optional.of(ApplicationVersion.from(BuildJob.defaultSourceRevision, + Optional.of(ApplicationVersion.from(DeploymentContext.defaultSourceRevision, BuildJob.defaultBuildNumber)), true); tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-central-1/instance/instance1/", POST) @@ -731,7 +732,7 @@ public class ApplicationApiTest extends ControllerContainerTest { 1234, 123, Optional.empty(), - BuildJob.defaultSourceRevision))), + DeploymentContext.defaultSourceRevision))), "{\"error-code\":\"BAD_REQUEST\",\"message\":\"" + app1 + " is set up to be deployed from internally," + " and no longer accepts submissions from Screwdriver v3 jobs. If you need to revert " + "to the old pipeline, please file a ticket at yo/vespa-support and request this.\"}", @@ -769,7 +770,7 @@ public class ApplicationApiTest extends ControllerContainerTest { 1234, 123, Optional.empty(), - BuildJob.defaultSourceRevision))), + DeploymentContext.defaultSourceRevision))), "{\"message\":\"ok\"}"); // PUT (create) the authenticated user -- cgit v1.2.3 From 19fc6955a0d3674fdb8d8637a01b757a837cbe19 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Thu, 31 Oct 2019 14:20:09 +0100 Subject: Assign rotations on submission --- .../com/yahoo/vespa/hosted/controller/ApplicationController.java | 9 ++++++--- .../vespa/hosted/controller/maintenance/MetricsReporterTest.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'controller-server/src/test') diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java index 0eca30ddeec..7c718518129 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java @@ -10,6 +10,7 @@ import com.yahoo.config.application.api.ValidationId; import com.yahoo.config.application.api.ValidationOverrides; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; +import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.zone.ZoneId; @@ -403,9 +404,6 @@ public class ApplicationController { application = storeWithUpdatedConfig(application, applicationPackage); } - if (zone.environment().isProduction()) // Assign and register endpoints - application = withRotation(applicationPackage.deploymentSpec(), application, instance); - endpoints = registerEndpointsInDns(applicationPackage.deploymentSpec(), application.get().require(instanceId.instance()), zone); } // Release application lock while doing the deployment, which is a lengthy task. @@ -481,6 +479,11 @@ public class ApplicationController { application = application.with(name, instance -> withoutUnreferencedDeploymentJobs(deploymentSpec, instance)); } } + + for (InstanceName instance : declaredInstances) + if (applicationPackage.deploymentSpec().requireInstance(instance).deploysTo(Environment.prod)) + application = withRotation(applicationPackage.deploymentSpec(), application, instance); + store(application); return application; } 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 af6017c1188..d35d6d1d4a0 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 @@ -214,7 +214,7 @@ public class MetricsReporterTest { context.submit(applicationPackage).deploy(); reporter.maintain(); - assertEquals("Deployment queues name services requests", 6, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue()); + assertEquals("Deployment queues name services requests", 15, metrics.getMetric(MetricsReporter.NAME_SERVICE_REQUESTS_QUEUED).intValue()); context.flushDnsUpdates(); reporter.maintain(); -- cgit v1.2.3 From 2fe6aa0c3c53bc7a8c8b6a0feed85f53248de1de Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Thu, 31 Oct 2019 14:20:16 +0100 Subject: Update RotationRepositoryTest --- .../rotation/RotationRepositoryTest.java | 82 +++++++++------------- 1 file changed, 35 insertions(+), 47 deletions(-) (limited to 'controller-server/src/test') 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 b298cfcc889..70775bc9c00 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,13 +2,12 @@ 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; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; -import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; +import com.yahoo.vespa.hosted.controller.deployment.DeploymentContext; +import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester; import com.yahoo.vespa.hosted.rotation.config.RotationsConfig; import org.junit.Before; import org.junit.Rule; @@ -39,7 +38,7 @@ public class RotationRepositoryTest { private final RotationsConfig rotationsConfigWhitespaces = new RotationsConfig( new RotationsConfig.Builder() - .rotations("foo-1", "\n foo-1.com \n") + .rotations("foo-1", "\n \t foo-1.com \n") .rotations("foo-2", "foo-2.com") ); @@ -49,58 +48,48 @@ public class RotationRepositoryTest { .region("us-west-1") .build(); - private DeploymentTester tester; + private InternalDeploymentTester tester; private RotationRepository repository; - private Application application; - private Instance instance; - + private DeploymentContext application; + @Before public void before() { - tester = new DeploymentTester(new ControllerTester(rotationsConfig)); - repository = tester.controller().applications().rotationRepository(); - application = tester.createApplication("app1", "tenant1", 11L, 1L); - instance = tester.defaultInstance(application.id()); + tester = new InternalDeploymentTester(new ControllerTester(rotationsConfig)); + repository = tester.applications().rotationRepository(); + application = tester.newDeploymentContext("tenant1", "app1", "default"); } @Test public void assigns_and_reuses_rotation() { - // Deploying assigns a rotation - tester.deployCompletely(application, applicationPackage); + // Submitting assigns a rotation + application.submit(applicationPackage); Rotation expected = new Rotation(new RotationId("foo-1"), "foo-1.com"); - instance = tester.applications().requireInstance(instance.id()); - assertEquals(List.of(expected.id()), rotationIds(instance.rotations())); + assertEquals(List.of(expected.id()), rotationIds(application.instance().rotations())); assertEquals(URI.create("https://app1--tenant1.global.vespa.oath.cloud:4443/"), - instance.endpointsIn(SystemName.main).main().get().url()); + application.instance().endpointsIn(SystemName.main).main().get().url()); try (RotationLock lock = repository.lock()) { - List rotations = repository.getOrAssignRotations(application.deploymentSpec(), - tester.applications().requireInstance(instance.id()), + List rotations = repository.getOrAssignRotations(application.application().deploymentSpec(), + application.instance(), lock); assertSingleRotation(expected, rotations, repository); } - // Deploying once more assigns same rotation - ApplicationPackage applicationPackage = new ApplicationPackageBuilder() - .globalServiceId("foo") - .region("us-east-3") - .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().requireInstance(instance.id()).rotations())); + // Submitting once more assigns same rotation + application.submit(applicationPackage); + assertEquals(List.of(expected.id()), rotationIds(application.instance().rotations())); } @Test public void strips_whitespace_in_rotation_fqdn() { - DeploymentTester tester = new DeploymentTester(new ControllerTester(rotationsConfigWhitespaces)); + tester = new InternalDeploymentTester(new ControllerTester(rotationsConfigWhitespaces)); RotationRepository repository = tester.controller().applications().rotationRepository(); - Application application2 = tester.createApplication("app2", "tenant2", 22L, 2L); + var application2 = tester.newDeploymentContext("tenant1", "app2", "default"); - tester.deployCompletely(application2, applicationPackage); - Instance instance2 = tester.defaultInstance(application2.id()); + application2.submit(applicationPackage); try (RotationLock lock = repository.lock()) { - List rotations = repository.getOrAssignRotations(application2.deploymentSpec(), instance2, lock); + List rotations = repository.getOrAssignRotations(application2.application().deploymentSpec(), application2.instance(), lock); Rotation assignedRotation = new Rotation(new RotationId("foo-1"), "foo-1.com"); assertSingleRotation(assignedRotation, rotations, repository); } @@ -109,17 +98,17 @@ public class RotationRepositoryTest { @Test public void out_of_rotations() { // Assigns 1 rotation - tester.deployCompletely(application, applicationPackage); + application.submit(applicationPackage); // Assigns 1 more - Application application2 = tester.createApplication("app2", "tenant2", 22L, 2L); - tester.deployCompletely(application2, applicationPackage); + var application2 = tester.newDeploymentContext("tenant2", "app2", "default"); + application2.submit(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); + var application3 = tester.newDeploymentContext("tenant3", "app3", "default"); + application3.submit(applicationPackage); } @Test @@ -128,10 +117,9 @@ public class RotationRepositoryTest { .globalServiceId("foo") .region("us-east-3") .build(); - Application application2 = tester.createApplication("app2", "tenant2", 22L, 2L); thrown.expect(RuntimeException.class); thrown.expectMessage("less than 2 prod zones are defined"); - tester.deployCompletely(application2, applicationPackage); + application.submit(applicationPackage); } @Test @@ -140,8 +128,8 @@ public class RotationRepositoryTest { .region("us-east-3") .region("us-west-1") .build(); - tester.deployCompletely(application, applicationPackage); - assertTrue(tester.defaultInstance(application.id()).rotations().isEmpty()); + application.submit(applicationPackage); + assertTrue(application.instance().rotations().isEmpty()); } @Test @@ -151,11 +139,11 @@ public class RotationRepositoryTest { .region("us-east-3") .region("us-west-1") .build(); - Application application2 = tester.createApplication("app2", "tenant2", 22L, 2L); - tester.deployCompletely(application2, applicationPackage); - assertEquals(List.of(new RotationId("foo-1")), rotationIds(tester.defaultInstance(application2.id()).rotations())); - assertEquals("https://cd--app2--tenant2.global.vespa.oath.cloud:4443/", tester.defaultInstance(application2.id()) - .endpointsIn(SystemName.cd).main().get().url().toString()); + var application2 = tester.newDeploymentContext("tenant2", "app2", "default"); + application2.submit(applicationPackage); + assertEquals(List.of(new RotationId("foo-1")), rotationIds(application2.instance().rotations())); + assertEquals("https://cd--app2--tenant2.global.vespa.oath.cloud:4443/", + application2.instance().endpointsIn(SystemName.cd).main().get().url().toString()); } private void assertSingleRotation(Rotation expected, List assignedRotations, RotationRepository repository) { -- cgit v1.2.3 From 9f3db74fb5199cefaf94961b70374e6c2d3243f7 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Thu, 31 Oct 2019 14:27:13 +0100 Subject: Update DeploymentMetricsMaintainerTest --- .../controller/deployment/DeploymentContext.java | 9 ++++-- .../DeploymentMetricsMaintainerTest.java | 32 +++++++++------------- .../maintenance/RotationStatusUpdaterTest.java | 6 ---- .../maintenance/RoutingPoliciesTest.java | 1 - 4 files changed, 20 insertions(+), 28 deletions(-) (limited to 'controller-server/src/test') diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java index 95934b528e0..b0adebfbb19 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java @@ -275,10 +275,15 @@ public class DeploymentContext { return this; } + /** Runs a deployment of the given package to the given dev/perf job, on the given version. */ + public DeploymentContext runJob(JobType type, ApplicationPackage applicationPackage, Version vespaVersion) { + jobs.deploy(instanceId, type, Optional.ofNullable(vespaVersion), applicationPackage); + return runJob(type); + } + /** Runs a deployment of the given package to the given dev/perf job. */ public DeploymentContext runJob(JobType type, ApplicationPackage applicationPackage) { - jobs.deploy(instanceId, type, Optional.empty(), applicationPackage); - return runJob(type); + return runJob(type, applicationPackage, null); } /** Pulls the ready job trigger, and then runs the whole of the given job, successfully. */ 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 73ddeeaa0c6..e88452bd54e 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 @@ -11,9 +11,11 @@ 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; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; +import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester; import org.junit.Test; import java.time.Duration; @@ -33,17 +35,17 @@ import static org.junit.Assert.assertFalse; */ public class DeploymentMetricsMaintainerTest { - private final DeploymentTester tester = new DeploymentTester(); + private final InternalDeploymentTester tester = new InternalDeploymentTester(); @Test public void updates_metrics() { - var application = tester.createApplication("app1", "tenant1", 123L, 1L); - deploy(application.id().defaultInstance(), Version.fromString("7.1")); + var application = tester.deploymentContext(); + application.runJob(JobType.devUsEast1, new ApplicationPackage(new byte[0]), Version.fromString("7.1")); DeploymentMetricsMaintainer maintainer = maintainer(tester.controller()); - Supplier app = () -> tester.application(application.id()); - Supplier instance = () -> tester.defaultInstance(application.id()); - Supplier deployment = () -> instance.get().deployments().values().stream().findFirst().get(); + Supplier app = application::application; + Supplier instance = application::instance; + Supplier deployment = () -> application.deployment(ZoneId.from("dev", "us-east-1")); // No metrics gathered yet assertEquals(0, app.get().metrics().queryServiceQuality(), 0); @@ -53,7 +55,7 @@ public class DeploymentMetricsMaintainerTest { assertFalse("Never received any writes", deployment.get().activity().lastWritten().isPresent()); // Only get application metrics for old version - deploy(application.id().defaultInstance(), Version.fromString("6.3.3")); + application.runJob(JobType.devUsEast1, new ApplicationPackage(new byte[0]), Version.fromString("6.3.3")); maintainer.maintain(); assertEquals(0, app.get().metrics().queryServiceQuality(), 0); assertEquals(0, deployment.get().metrics().documentCount(), 0); @@ -62,13 +64,13 @@ public class DeploymentMetricsMaintainerTest { assertFalse("Never received any writes", deployment.get().activity().lastWritten().isPresent()); // Metrics are gathered and saved to application - deploy(application.id().defaultInstance(), Version.fromString("7.5.5")); + application.runJob(JobType.devUsEast1, new ApplicationPackage(new byte[0]), Version.fromString("7.5.5")); var metrics0 = Map.of(ClusterMetrics.QUERIES_PER_SECOND, 1D, ClusterMetrics.FEED_PER_SECOND, 2D, ClusterMetrics.DOCUMENT_COUNT, 3D, ClusterMetrics.QUERY_LATENCY, 4D, ClusterMetrics.FEED_LATENCY, 5D); - setMetrics(application.id().defaultInstance(), metrics0); + setMetrics(application.application().id().defaultInstance(), metrics0); maintainer.maintain(); Instant t1 = tester.clock().instant().truncatedTo(MILLIS); assertEquals(0.0, app.get().metrics().queryServiceQuality(), Double.MIN_VALUE); @@ -98,7 +100,7 @@ public class DeploymentMetricsMaintainerTest { var metrics1 = new HashMap<>(metrics0); metrics1.put(ClusterMetrics.QUERIES_PER_SECOND, 0D); metrics1.put(ClusterMetrics.FEED_PER_SECOND, 5D); - setMetrics(application.id().defaultInstance(), metrics1); + setMetrics(application.application().id().defaultInstance(), metrics1); maintainer.maintain(); assertEquals(t2, deployment.get().activity().lastQueried().get()); assertEquals(t3, deployment.get().activity().lastWritten().get()); @@ -109,7 +111,7 @@ public class DeploymentMetricsMaintainerTest { tester.clock().advance(Duration.ofHours(1)); var metrics2 = new HashMap<>(metrics1); metrics2.put(ClusterMetrics.FEED_PER_SECOND, 0D); - setMetrics(application.id().defaultInstance(), metrics2); + setMetrics(application.application().id().defaultInstance(), metrics2); maintainer.maintain(); assertEquals(t2, deployment.get().activity().lastQueried().get()); assertEquals(t3, deployment.get().activity().lastWritten().get()); @@ -129,12 +131,4 @@ public class DeploymentMetricsMaintainerTest { return new DeploymentMetricsMaintainer(controller, Duration.ofDays(1), new JobControl(controller.curator())); } - private void deploy(ApplicationId id, Version version) { - tester.controllerTester().deploy(id, - ZoneId.from(Environment.dev, RegionName.from("us-east-1")), - Optional.of(new ApplicationPackage(new byte[0])), - false, - Optional.of(version)); - } - } 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 127104724a5..fde6db37d62 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 @@ -4,19 +4,13 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.ControllerTester; -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; -import com.yahoo.vespa.hosted.controller.deployment.BuildJob; -import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester; import com.yahoo.vespa.hosted.controller.rotation.RotationState; import org.junit.Test; import java.time.Duration; -import java.util.function.Supplier; import static org.junit.Assert.assertEquals; 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 1aa88dde258..b7671cf47c2 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 @@ -18,7 +18,6 @@ import com.yahoo.vespa.hosted.controller.application.RoutingPolicy; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.BuildJob; import com.yahoo.vespa.hosted.controller.deployment.DeploymentContext; -import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester; import org.junit.Test; -- cgit v1.2.3