Search in sources :

Example 6 with MockCuratorDb

use of com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb 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 7 with MockCuratorDb

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

the class OutstandingChangeDeployerTest method testChangeDeployer.

@Test
public void testChangeDeployer() {
    DeploymentTester tester = new DeploymentTester();
    tester.configServer().setDefaultVersion(new Version(6, 1));
    OutstandingChangeDeployer deployer = new OutstandingChangeDeployer(tester.controller(), Duration.ofMinutes(10), new JobControl(new MockCuratorDb()));
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").build();
    tester.createAndDeploy("app1", 11, applicationPackage);
    tester.createAndDeploy("app2", 22, applicationPackage);
    Version version = new Version(6, 2);
    tester.deploymentTrigger().triggerChange(tester.application("app1").id(), Change.of(version));
    tester.deploymentTrigger().triggerReadyJobs();
    assertEquals(Change.of(version), tester.application("app1").change());
    assertFalse(tester.application("app1").outstandingChange().isPresent());
    tester.jobCompletion(DeploymentJobs.JobType.component).application(tester.application("app1")).sourceRevision(new SourceRevision("repository1", "master", "cafed00d")).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    Application app = tester.application("app1");
    assertTrue(app.outstandingChange().isPresent());
    assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id());
    assertEquals(1, tester.deploymentQueue().jobs().size());
    deployer.maintain();
    tester.deploymentTrigger().triggerReadyJobs();
    assertEquals("No effect as job is in progress", 1, tester.deploymentQueue().jobs().size());
    assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id());
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsWest1);
    assertEquals("Upgrade done", 0, tester.deploymentQueue().jobs().size());
    deployer.maintain();
    tester.deploymentTrigger().triggerReadyJobs();
    app = tester.application("app1");
    assertEquals("1.0.43-cafed00d", app.change().application().get().id());
    List<BuildService.BuildJob> jobs = tester.deploymentQueue().jobs();
    assertEquals(1, jobs.size());
    assertEquals(11, jobs.get(0).projectId());
    assertEquals(DeploymentJobs.JobType.systemTest.jobName(), jobs.get(0).jobName());
    assertFalse(tester.application("app1").outstandingChange().isPresent());
}
Also used : SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) Version(com.yahoo.component.Version) 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) Test(org.junit.Test)

Example 8 with MockCuratorDb

use of com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb 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 9 with MockCuratorDb

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

the class ApplicationOwnershipConfirmerTest method setup.

@Before
public void setup() {
    tester = new DeploymentTester();
    issues = new MockOwnershipIssues();
    confirmer = new ApplicationOwnershipConfirmer(tester.controller(), Duration.ofDays(1), new JobControl(new MockCuratorDb()), issues);
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) Before(org.junit.Before)

Example 10 with MockCuratorDb

use of com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb 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)

Aggregations

MockCuratorDb (com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb)12 Test (org.junit.Test)9 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)5 Application (com.yahoo.vespa.hosted.controller.Application)4 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)4 ApplicationId (com.yahoo.config.provision.ApplicationId)3 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)3 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)3 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)3 Before (org.junit.Before)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Version (com.yahoo.component.Version)1 NToken (com.yahoo.vespa.athenz.api.NToken)1 AttributeMapping (com.yahoo.vespa.hosted.controller.api.integration.chef.AttributeMapping)1 Chef (com.yahoo.vespa.hosted.controller.api.integration.chef.Chef)1 PartialNodeResult (com.yahoo.vespa.hosted.controller.api.integration.chef.rest.PartialNodeResult)1 Record (com.yahoo.vespa.hosted.controller.api.integration.dns.Record)1 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)1 SourceRevision (com.yahoo.vespa.hosted.controller.application.SourceRevision)1 VersionStatus (com.yahoo.vespa.hosted.controller.versions.VersionStatus)1