use of com.yahoo.vespa.hosted.controller.maintenance.JobControl in project vespa by vespa-engine.
the class DeploymentTriggerTest method testUpgradingButNoJobStarted.
@Test
public void testUpgradingButNoJobStarted() {
DeploymentTester tester = new DeploymentTester();
ReadyJobsTrigger readyJobsTrigger = new ReadyJobsTrigger(tester.controller(), Duration.ofHours(1), new JobControl(tester.controllerTester().curator()));
LockedApplication app = (LockedApplication) tester.createAndDeploy("default0", 3, "default");
// Store that we are upgrading but don't start the system-tests job
tester.controller().applications().store(app.withChange(Change.of(Version.fromString("6.2"))));
assertEquals(0, tester.deploymentQueue().jobs().size());
readyJobsTrigger.run();
assertEquals(1, tester.deploymentQueue().jobs().size());
assertEquals("system-test", tester.deploymentQueue().jobs().get(0).jobName());
}
use of com.yahoo.vespa.hosted.controller.maintenance.JobControl in project vespa by vespa-engine.
the class DeploymentJobExecutorTest method testMaintenance.
@Test
public void testMaintenance() {
DeploymentTester tester = new DeploymentTester();
JobControl jobControl = new JobControl(tester.controller().curator());
int project1 = 1;
int project2 = 2;
int project3 = 3;
ApplicationId app1 = tester.createApplication("app1", "tenant", project1, null).id();
ApplicationId app2 = tester.createApplication("app2", "tenant", project2, null).id();
ApplicationId app3 = tester.createApplication("app3", "tenant", project3, null).id();
// Create a BuildService which always rejects jobs from project2, but accepts and runs all others.
ArrayList<BuildJob> buildJobs = new ArrayList<>();
BuildService buildService = buildJob -> buildJob.projectId() == project2 ? false : buildJobs.add(buildJob);
DeploymentJobExecutor triggerer = new DeploymentJobExecutor(tester.controller(), Duration.ofDays(1), jobControl, buildService, Runnable::run);
triggerer.maintain();
assertEquals("No jobs are triggered initially.", Collections.emptyList(), buildJobs);
// Trigger jobs in capacity constrained environment
tester.deploymentQueue().addJob(app1, DeploymentJobs.JobType.systemTest, false);
tester.deploymentQueue().addJob(app2, DeploymentJobs.JobType.systemTest, false);
tester.deploymentQueue().addJob(app3, DeploymentJobs.JobType.systemTest, false);
// Trigger jobs in non-capacity constrained environment
tester.deploymentQueue().addJob(app1, DeploymentJobs.JobType.productionUsWest1, false);
tester.deploymentQueue().addJob(app2, DeploymentJobs.JobType.productionUsWest1, false);
tester.deploymentQueue().addJob(app3, DeploymentJobs.JobType.productionUsWest1, false);
triggerer.maintain();
assertEquals("One system test job and all production jobs not for app2 are triggered after one maintenance run.", Arrays.asList(new BuildJob(project1, DeploymentJobs.JobType.systemTest.jobName()), new BuildJob(project1, DeploymentJobs.JobType.productionUsWest1.jobName()), new BuildJob(project3, DeploymentJobs.JobType.productionUsWest1.jobName())), buildJobs);
buildJobs.clear();
triggerer.maintain();
assertEquals("Next job in line fails to trigger in the build service.", Collections.emptyList(), buildJobs);
buildJobs.clear();
triggerer.maintain();
assertEquals("Next job which was waiting for capacity is triggered on next run.", Collections.singletonList(new BuildJob(project3, DeploymentJobs.JobType.systemTest.jobName())), buildJobs);
buildJobs.clear();
triggerer.maintain();
assertEquals("No jobs are left.", Collections.emptyList(), tester.deploymentQueue().takeJobsToRun());
}
use of com.yahoo.vespa.hosted.controller.maintenance.JobControl 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());
}
Aggregations