Search in sources :

Example 11 with ManualClock

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());
}
Also used : SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) BuildService(com.yahoo.vespa.hosted.controller.api.integration.BuildService) JobControl(com.yahoo.vespa.hosted.controller.maintenance.JobControl) ReadyJobsTrigger(com.yahoo.vespa.hosted.controller.maintenance.ReadyJobsTrigger) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) ManualClock(com.yahoo.test.ManualClock) Version(com.yahoo.component.Version) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 12 with ManualClock

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());
}
Also used : MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Node(com.yahoo.vespa.hosted.provision.Node) FlavorConfigBuilder(com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder) NodeRepositoryProvisioner(com.yahoo.vespa.hosted.provision.provisioning.NodeRepositoryProvisioner) ArrayList(java.util.ArrayList) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ManualClock(com.yahoo.test.ManualClock) NodeFlavors(com.yahoo.config.provision.NodeFlavors) NodeRepository(com.yahoo.vespa.hosted.provision.NodeRepository) DockerImage(com.yahoo.config.provision.DockerImage) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 13 with ManualClock

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);
}
Also used : ManualClock(com.yahoo.test.ManualClock) MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Zone(com.yahoo.config.provision.Zone) NodeRepository(com.yahoo.vespa.hosted.provision.NodeRepository) Curator(com.yahoo.vespa.curator.Curator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) DockerImage(com.yahoo.config.provision.DockerImage) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 14 with ManualClock

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());
}
Also used : ManualClock(com.yahoo.test.ManualClock) Version(com.yahoo.component.Version) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 15 with ManualClock

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());
}
Also used : ManualClock(com.yahoo.test.ManualClock) Version(com.yahoo.component.Version) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Aggregations

ManualClock (com.yahoo.test.ManualClock)18 Test (org.junit.Test)16 Version (com.yahoo.component.Version)4 Application (com.yahoo.vespa.hosted.controller.Application)4 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)4 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)4 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)4 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)4 DockerImage (com.yahoo.config.provision.DockerImage)3 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)3 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)3 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)3 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)3 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)3 ArrayList (java.util.ArrayList)3 ModelFactory (com.yahoo.config.model.api.ModelFactory)2 ApplicationId (com.yahoo.config.provision.ApplicationId)2 Zone (com.yahoo.config.provision.Zone)2 Metric (com.yahoo.jdisc.Metric)2 Curator (com.yahoo.vespa.curator.Curator)2