use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class RotationTest method strips_whitespace_in_rotation_fqdn.
@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());
try (RotationLock lock = repository.lock()) {
Rotation rotation = repository.getRotation(application, lock);
Rotation assignedRotation = new Rotation(new RotationId("foo-1"), "foo-1.com");
assertEquals(assignedRotation, rotation);
}
}
use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class DeploymentTriggerTest method testBlockRevisionChange.
@Test
public void testBlockRevisionChange() {
// Tuesday, 17:30
ManualClock clock = new ManualClock(Instant.parse("2017-09-26T17:30:00.00Z"));
DeploymentTester tester = new DeploymentTester(new ControllerTester(clock));
ReadyJobsTrigger readyJobsTrigger = new ReadyJobsTrigger(tester.controller(), Duration.ofHours(1), new JobControl(tester.controllerTester().curator()));
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
ApplicationPackageBuilder applicationPackageBuilder = new ApplicationPackageBuilder().upgradePolicy("canary").blockChange(true, false, "tue", "18-19", "UTC").region("us-west-1").region("us-central-1").region("us-east-3");
Application app = tester.createAndDeploy("app1", 1, applicationPackageBuilder.build());
// --------------- Enter block window: 18:30
tester.clock().advance(Duration.ofHours(1));
readyJobsTrigger.run();
assertEquals(0, tester.deploymentQueue().jobs().size());
String searchDefinition = "search test {\n" + " document test {\n" + " field test type string {\n" + " }\n" + " }\n" + "}\n";
ApplicationPackage changedApplication = applicationPackageBuilder.searchDefinition(searchDefinition).build();
tester.jobCompletion(component).application(app).nextBuildNumber().sourceRevision(new SourceRevision("repository1", "master", "cafed00d")).uploadArtifact(changedApplication).submit();
assertTrue(tester.applications().require(app.id()).change().isPresent());
tester.deployAndNotify(app, changedApplication, true, systemTest);
tester.deployAndNotify(app, changedApplication, true, stagingTest);
readyJobsTrigger.run();
assertEquals(0, tester.deploymentQueue().jobs().size());
// ---------------- Exit block window: 20:30
tester.clock().advance(Duration.ofHours(2));
// Schedules the blocked production job(s)
tester.deploymentTrigger().triggerReadyJobs();
assertEquals(1, tester.deploymentQueue().jobs().size());
BuildService.BuildJob productionJob = tester.deploymentQueue().takeJobsToRun().get(0);
assertEquals("production-us-west-1", productionJob.jobName());
}
use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class ClusterUtilizationMaintainerTest method maintain.
@Test
public void maintain() {
ControllerTester tester = new ControllerTester();
ApplicationId app = tester.createAndDeploy("tenant1", "domain1", "app1", Environment.dev, 123).id();
// Precondition: no cluster info attached to the deployments
Deployment deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get();
Assert.assertEquals(0, deployment.clusterUtils().size());
ClusterUtilizationMaintainer mainainer = new ClusterUtilizationMaintainer(tester.controller(), Duration.ofHours(1), new JobControl(new MockCuratorDb()));
mainainer.maintain();
deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get();
Assert.assertEquals(1, deployment.clusterUtils().size());
Assert.assertEquals(0.5554, deployment.clusterUtils().get(ClusterSpec.Id.from("default")).getCpu(), Double.MIN_VALUE);
}
use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class UpgraderTest method testBlockVersionChange.
@Test
public void testBlockVersionChange() {
// Tuesday, 18:00
ManualClock clock = new ManualClock(Instant.parse("2017-09-26T18:00:00.00Z"));
DeploymentTester tester = new DeploymentTester(new ControllerTester(clock));
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").blockChange(false, true, "tue", "18-19", "UTC").region("us-west-1").build();
Application app = tester.createAndDeploy("app1", 1, applicationPackage);
// New version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
// Application is not upgraded at this time
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertTrue("No jobs scheduled", tester.deploymentQueue().jobs().isEmpty());
// One hour passes, time is 19:00, still no upgrade
tester.clock().advance(Duration.ofHours(1));
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertTrue("No jobs scheduled", tester.deploymentQueue().jobs().isEmpty());
// Two hours pass in total, time is 20:00 and application upgrades
tester.clock().advance(Duration.ofHours(1));
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertFalse("Job is scheduled", tester.deploymentQueue().jobs().isEmpty());
tester.completeUpgrade(app, version, applicationPackage);
assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
}
use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class UpgraderTest method testBlockVersionChangeHalfwayThough.
@Test
public void testBlockVersionChangeHalfwayThough() {
// Tuesday, 17:00
ManualClock clock = new ManualClock(Instant.parse("2017-09-26T17:00:00.00Z"));
DeploymentTester tester = new DeploymentTester(new ControllerTester(clock));
ReadyJobsTrigger readyJobsTrigger = new ReadyJobsTrigger(tester.controller(), Duration.ofHours(1), new JobControl(tester.controllerTester().curator()));
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").blockChange(false, true, "tue", "18-19", "UTC").region("us-west-1").region("us-central-1").region("us-east-3").build();
Application app = tester.createAndDeploy("app1", 1, applicationPackage);
// New version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
// Application upgrade starts
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
tester.deployAndNotify(app, applicationPackage, true, systemTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
// Entering block window after prod job is triggered
clock.advance(Duration.ofHours(1));
tester.deployAndNotify(app, applicationPackage, true, productionUsWest1);
// Next job not triggered due to being in the block window
assertTrue(tester.deploymentQueue().jobs().isEmpty());
// One hour passes, time is 19:00, still no upgrade
tester.clock().advance(Duration.ofHours(1));
readyJobsTrigger.maintain();
assertTrue("No jobs scheduled", tester.deploymentQueue().jobs().isEmpty());
// Another hour pass, time is 20:00 and application upgrades
tester.clock().advance(Duration.ofHours(1));
readyJobsTrigger.maintain();
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsCentral1);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
}
Aggregations