Search in sources :

Example 6 with ControllerTester

use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.

the class UpgraderTest method testBlockVersionChangeHalfwayThoughThenNewVersion.

/**
 * Tests the scenario where a release is deployed to 2 of 3 production zones, then blocked,
 * followed by timeout of the upgrade and a new release.
 * In this case, the blocked production zone should not progress with upgrading to the previous version,
 * and should not upgrade to the new version until the other production zones have it
 * (expected behavior; both requirements are debatable).
 */
@Test
public void testBlockVersionChangeHalfwayThoughThenNewVersion() {
    // Friday, 16:00
    ManualClock clock = new ManualClock(Instant.parse("2017-09-29T16: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, "mon-fri", "00-09,17-23", "UTC").blockChange(false, true, "sat-sun", "00-23", "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);
    tester.deployAndNotify(app, applicationPackage, true, productionUsWest1);
    // Entering block window after prod job is triggered
    clock.advance(Duration.ofHours(1));
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsCentral1);
    // Next job not triggered due to being in the block window
    assertTrue(tester.deploymentQueue().jobs().isEmpty());
    // A day passes and we get a new version
    tester.clock().advance(Duration.ofDays(1));
    version = Version.fromString("5.2");
    tester.updateVersionStatus(version);
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    assertTrue("Nothing is scheduled", tester.deploymentQueue().jobs().isEmpty());
    // Monday morning: We are not blocked
    // Sunday, 17:00
    tester.clock().advance(Duration.ofDays(1));
    // Monday, 10:00
    tester.clock().advance(Duration.ofHours(17));
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    // We proceed with the new version in the expected order, not starting with the previously blocked version:
    // Test jobs are run with the new version, but not production as we are in the block window
    tester.deployAndNotify(app, applicationPackage, true, systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, productionUsWest1);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsCentral1);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
    // App is completely upgraded to the latest version
    for (Deployment deployment : tester.applications().require(app.id()).deployments().values()) assertEquals(version, deployment.version());
}
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) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) 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 7 with ControllerTester

use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.

the class ClusterInfoMaintainerTest 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.clusterInfo().size());
    ClusterInfoMaintainer mainainer = new ClusterInfoMaintainer(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(2, deployment.clusterInfo().size());
    Assert.assertEquals(10, deployment.clusterInfo().get(ClusterSpec.Id.from("clusterA")).getFlavorCost());
}
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 8 with ControllerTester

use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.

the class JobControlTest method testJobControlMayDeactivateJobs.

@Test
public void testJobControlMayDeactivateJobs() {
    JobControl jobControl = new JobControl(new MockCuratorDb());
    ControllerTester tester = new ControllerTester();
    MockMaintainer mockMaintainer = new MockMaintainer(tester.controller(), jobControl);
    assertTrue(jobControl.jobs().contains("MockMaintainer"));
    assertEquals(0, mockMaintainer.maintenanceInvocations);
    mockMaintainer.run();
    assertEquals(1, mockMaintainer.maintenanceInvocations);
    jobControl.setActive("MockMaintainer", false);
    mockMaintainer.run();
    assertEquals(1, mockMaintainer.maintenanceInvocations);
    jobControl.setActive("MockMaintainer", true);
    mockMaintainer.run();
    assertEquals(2, mockMaintainer.maintenanceInvocations);
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) Test(org.junit.Test)

Example 9 with ControllerTester

use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.

the class VersionStatusUpdaterTest method testVersionUpdating.

/**
 * Test that this job updates the status. Test of the content of the update is in VersionStatusTest
 */
@Test
public void testVersionUpdating() {
    ControllerTester tester = new ControllerTester();
    tester.controller().updateVersionStatus(new VersionStatus(Collections.emptyList()));
    assertFalse(tester.controller().versionStatus().systemVersion().isPresent());
    VersionStatusUpdater updater = new VersionStatusUpdater(tester.controller(), Duration.ofMinutes(3), new JobControl(new MockCuratorDb()));
    updater.maintain();
    assertTrue(tester.controller().versionStatus().systemVersion().isPresent());
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) VersionStatus(com.yahoo.vespa.hosted.controller.versions.VersionStatus) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) Test(org.junit.Test)

Example 10 with ControllerTester

use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.

the class RotationTest method before.

@Before
public void before() {
    tester = new DeploymentTester(new ControllerTester(rotationsConfig));
    repository = tester.controller().applications().rotationRepository();
    application = tester.createApplication("app1", "tenant1", 11L, 1L);
}
Also used : DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) Before(org.junit.Before)

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