Search in sources :

Example 6 with VersionStatus

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

the class ControllerTest method testCleanupOfStaleDeploymentData.

@Test
public void testCleanupOfStaleDeploymentData() throws IOException {
    DeploymentTester tester = new DeploymentTester();
    tester.controllerTester().zoneRegistry().setSystem(SystemName.cd);
    tester.controllerTester().zoneRegistry().setZones(ZoneId.from("prod", "cd-us-central-1"));
    Supplier<Map<JobType, JobStatus>> statuses = () -> tester.application(ApplicationId.from("vespa", "canary", "default")).deploymentJobs().jobStatus();
    // Current system version, matches version in test data
    Version version = Version.fromString("6.141.117");
    tester.configServer().setDefaultVersion(version);
    tester.updateVersionStatus(version);
    assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
    // Load test data data
    byte[] json = Files.readAllBytes(Paths.get("src/test/java/com/yahoo/vespa/hosted/controller/maintenance/testdata/canary-with-stale-data.json"));
    Application application = tester.controllerTester().createApplication(SlimeUtils.jsonToSlime(json));
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").region("cd-us-central-1").build();
    tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit();
    long cdJobsCount = statuses.get().keySet().stream().filter(type -> type.zone(SystemName.cd).isPresent()).count();
    long mainJobsCount = statuses.get().keySet().stream().filter(type -> type.zone(SystemName.main).isPresent() && !type.zone(SystemName.cd).isPresent()).count();
    assertEquals("Irrelevant (main) data is present.", 8, mainJobsCount);
    // New version is released
    version = Version.fromString("6.142.1");
    tester.configServer().setDefaultVersion(version);
    tester.updateVersionStatus(version);
    assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    // Test environments pass
    tester.deploy(DeploymentJobs.JobType.systemTest, application, applicationPackage);
    tester.deploymentQueue().takeJobsToRun();
    tester.clock().advance(Duration.ofMinutes(10));
    tester.jobCompletion(systemTest).application(application).submit();
    long newCdJobsCount = statuses.get().keySet().stream().filter(type -> type.zone(SystemName.cd).isPresent()).count();
    long newMainJobsCount = statuses.get().keySet().stream().filter(type -> type.zone(SystemName.main).isPresent() && !type.zone(SystemName.cd).isPresent()).count();
    assertEquals("Irrelevant (main) job data is removed.", 0, newMainJobsCount);
    assertEquals("Relevant (cd) data is not removed.", cdJobsCount, newCdJobsCount);
}
Also used : InstanceName(com.yahoo.config.provision.InstanceName) EndpointStatus(com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus) JobType.productionCorpUsEast1(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionCorpUsEast1) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) ValidationId(com.yahoo.config.application.api.ValidationId) RegionName(com.yahoo.config.provision.RegionName) TenantName(com.yahoo.config.provision.TenantName) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) Duration(java.time.Duration) Map(java.util.Map) JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) ApplicationSerializer(com.yahoo.vespa.hosted.controller.persistence.ApplicationSerializer) Assert.fail(org.junit.Assert.fail) DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) ScrewdriverBuildJob(com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) Instant(java.time.Instant) JobError(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) JobType(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType) List(java.util.List) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest) Assert.assertFalse(org.junit.Assert.assertFalse) SystemName(com.yahoo.config.provision.SystemName) Optional(java.util.Optional) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) DeploymentStatistics(com.yahoo.vespa.hosted.controller.versions.DeploymentStatistics) ApplicationName(com.yahoo.config.provision.ApplicationName) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) Supplier(java.util.function.Supplier) NToken(com.yahoo.vespa.athenz.api.NToken) ArrayList(java.util.ArrayList) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) SlimeUtils(com.yahoo.vespa.config.SlimeUtils) Change(com.yahoo.vespa.hosted.controller.application.Change) DeploymentQueue(com.yahoo.vespa.hosted.controller.deployment.DeploymentQueue) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) BuildJob(com.yahoo.vespa.hosted.controller.deployment.BuildJob) Files(java.nio.file.Files) Environment(com.yahoo.config.provision.Environment) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) Test(org.junit.Test) IOException(java.io.IOException) RotationId(com.yahoo.vespa.hosted.controller.rotation.RotationId) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) JobType.productionUsWest1(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsWest1) Assert.assertNull(org.junit.Assert.assertNull) Paths(java.nio.file.Paths) RecordName(com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName) BuildService(com.yahoo.vespa.hosted.controller.api.integration.BuildService) JobType.productionUsEast3(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) VersionStatus(com.yahoo.vespa.hosted.controller.versions.VersionStatus) Collections(java.util.Collections) JobType.component(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component) Record(com.yahoo.vespa.hosted.controller.api.integration.dns.Record) RotationLock(com.yahoo.vespa.hosted.controller.rotation.RotationLock) Assert.assertEquals(org.junit.Assert.assertEquals) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) Version(com.yahoo.component.Version) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) Map(java.util.Map) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test)

Aggregations

VersionStatus (com.yahoo.vespa.hosted.controller.versions.VersionStatus)5 Version (com.yahoo.component.Version)3 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)3 SystemName (com.yahoo.config.provision.SystemName)2 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)2 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Inject (com.google.inject.Inject)1 AbstractComponent (com.yahoo.component.AbstractComponent)1 Vtag (com.yahoo.component.Vtag)1 ValidationId (com.yahoo.config.application.api.ValidationId)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 ApplicationName (com.yahoo.config.provision.ApplicationName)1 Environment (com.yahoo.config.provision.Environment)1 InstanceName (com.yahoo.config.provision.InstanceName)1 RegionName (com.yahoo.config.provision.RegionName)1 TenantName (com.yahoo.config.provision.TenantName)1 AthenzDomain (com.yahoo.vespa.athenz.api.AthenzDomain)1