Search in sources :

Example 11 with ControllerTester

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);
    }
}
Also used : DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) Application(com.yahoo.vespa.hosted.controller.Application) ApplicationRotation(com.yahoo.vespa.hosted.controller.application.ApplicationRotation) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) Test(org.junit.Test)

Example 12 with ControllerTester

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());
}
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 13 with ControllerTester

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);
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ApplicationId(com.yahoo.config.provision.ApplicationId) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) Test(org.junit.Test)

Example 14 with ControllerTester

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());
}
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 ControllerTester

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());
}
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

ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)20 Test (org.junit.Test)19 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)8 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)8 Application (com.yahoo.vespa.hosted.controller.Application)7 Version (com.yahoo.component.Version)6 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)5 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)5 MockCuratorDb (com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb)5 ManualClock (com.yahoo.test.ManualClock)4 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)4 ApplicationId (com.yahoo.config.provision.ApplicationId)3 AthenzIdentity (com.yahoo.vespa.athenz.api.AthenzIdentity)3 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)3 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)3 MapContext (com.yahoo.vespa.hosted.controller.MetricsMock.MapContext)2 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)2 SourceRevision (com.yahoo.vespa.hosted.controller.application.SourceRevision)2 DeploymentSpec (com.yahoo.config.application.api.DeploymentSpec)1 ValidationOverrides (com.yahoo.config.application.api.ValidationOverrides)1