Search in sources :

Example 11 with MockCuratorDb

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

the class DnsMaintainerTest method removes_record_for_unassigned_rotation.

@Test
public void removes_record_for_unassigned_rotation() {
    DeploymentTester tester = new DeploymentTester();
    Application application = tester.createApplication("app1", "tenant1", 1, 1L);
    DnsMaintainer dnsMaintainer = new DnsMaintainer(tester.controller(), Duration.ofHours(12), new JobControl(new MockCuratorDb()), tester.controllerTester().nameService());
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).globalServiceId("foo").region("us-west-1").region("us-central-1").build();
    // Deploy application
    tester.deployCompletely(application, applicationPackage);
    assertEquals(2, tester.controllerTester().nameService().records().size());
    Optional<Record> record = tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1--tenant1.global.vespa.yahooapis.com"));
    assertTrue(record.isPresent());
    assertEquals("app1--tenant1.global.vespa.yahooapis.com", record.get().name().asString());
    assertEquals("rotation-fqdn-01.", record.get().data().asString());
    record = tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1.tenant1.global.vespa.yahooapis.com"));
    assertTrue(record.isPresent());
    assertEquals("app1.tenant1.global.vespa.yahooapis.com", record.get().name().asString());
    assertEquals("rotation-fqdn-01.", record.get().data().asString());
    // DnsMaintainer does nothing
    dnsMaintainer.maintain();
    assertTrue("DNS record is not removed", tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1--tenant1.global.vespa.yahooapis.com")).isPresent());
    assertTrue("DNS record is not removed", tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1.tenant1.global.vespa.yahooapis.com")).isPresent());
    // Remove application
    applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).allow(ValidationId.deploymentRemoval).build();
    tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(application, applicationPackage, true, systemTest);
    tester.applications().deactivate(application, ZoneId.from(Environment.test, RegionName.from("us-east-1")));
    tester.applications().deactivate(application, ZoneId.from(Environment.staging, RegionName.from("us-east-3")));
    tester.applications().deleteApplication(application.id(), Optional.of(new NToken("ntoken")));
    // DnsMaintainer removes records
    dnsMaintainer.maintain();
    assertFalse("DNS record removed", tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1--tenant1.global.vespa.yahooapis.com")).isPresent());
    dnsMaintainer.maintain();
    assertFalse("DNS record removed", tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1.tenant1.global.vespa.yahooapis.com")).isPresent());
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) NToken(com.yahoo.vespa.athenz.api.NToken) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) Record(com.yahoo.vespa.hosted.controller.api.integration.dns.Record) Application(com.yahoo.vespa.hosted.controller.Application) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Test(org.junit.Test) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)

Example 12 with MockCuratorDb

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

the class DeploymentMetricsMaintainerTest method maintain.

@Test
public void maintain() {
    ControllerTester tester = new ControllerTester();
    ApplicationId app = tester.createAndDeploy("tenant1", "domain1", "app1", Environment.dev, 123).id();
    // Pre condition: no metric info on neither application nor deployment
    assertEquals(0, tester.controller().applications().require(app).metrics().queryServiceQuality(), 0);
    Deployment deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get();
    assertEquals(0, deployment.metrics().documentCount(), 0);
    DeploymentMetricsMaintainer maintainer = new DeploymentMetricsMaintainer(tester.controller(), Duration.ofMinutes(10), new JobControl(new MockCuratorDb()));
    maintainer.maintain();
    // Post condition:
    Application application = tester.controller().applications().require(app);
    assertEquals(0.5, application.metrics().queryServiceQuality(), Double.MIN_VALUE);
    assertEquals(0.7, application.metrics().writeServiceQuality(), Double.MIN_VALUE);
    deployment = application.deployments().values().stream().findAny().get();
    assertEquals(1, deployment.metrics().queriesPerSecond(), Double.MIN_VALUE);
    assertEquals(2, deployment.metrics().writesPerSecond(), Double.MIN_VALUE);
    assertEquals(3, deployment.metrics().documentCount(), Double.MIN_VALUE);
    assertEquals(4, deployment.metrics().queryLatencyMillis(), Double.MIN_VALUE);
    assertEquals(5, deployment.metrics().writeLatencyMillis(), 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) Application(com.yahoo.vespa.hosted.controller.Application) 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