use of com.yahoo.test.ManualClock 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.test.ManualClock in project vespa by vespa-engine.
the class ReservationExpirerTest method ensure_reservation_times_out.
@Test
public void ensure_reservation_times_out() {
ManualClock clock = new ManualClock();
NodeFlavors flavors = FlavorConfigBuilder.createDummies("default");
NodeRepository nodeRepository = new NodeRepository(flavors, curator, clock, Zone.defaultZone(), new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
NodeRepositoryProvisioner provisioner = new NodeRepositoryProvisioner(nodeRepository, flavors, Zone.defaultZone());
List<Node> nodes = new ArrayList<>(2);
nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.host));
nodes = nodeRepository.addNodes(nodes);
nodes = nodeRepository.setDirty(nodes, Agent.system, getClass().getSimpleName());
// Reserve 2 nodes
assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.dirty).size());
nodeRepository.setReady(nodes, Agent.system, getClass().getSimpleName());
ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("bar").instanceName("fuz").build();
ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
provisioner.prepare(applicationId, cluster, Capacity.fromNodeCount(2), 1, null);
assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
// Reservation times out
// Reserved but not used time out
clock.advance(Duration.ofMinutes(14));
new ReservationExpirer(nodeRepository, clock, Duration.ofMinutes(10), new JobControl(nodeRepository.database())).run();
// Assert nothing is reserved
assertEquals(0, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
List<Node> dirty = nodeRepository.getNodes(NodeType.tenant, Node.State.dirty);
assertEquals(2, dirty.size());
assertFalse(dirty.get(0).allocation().isPresent());
assertFalse(dirty.get(1).allocation().isPresent());
}
use of com.yahoo.test.ManualClock in project vespa by vespa-engine.
the class PeriodicApplicationMaintainerTest method before.
@Before
public void before() {
Curator curator = new MockCurator();
Zone zone = new Zone(Environment.prod, RegionName.from("us-east"));
this.nodeRepository = new NodeRepository(nodeFlavors, curator, new ManualClock(), zone, new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
this.fixture = new Fixture(zone, nodeRepository, nodeFlavors, curator);
}
use of com.yahoo.test.ManualClock 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.test.ManualClock 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