Search in sources :

Example 1 with SourceRevision

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

the class ControllerTest method testDeploymentApplicationVersion.

@Test
public void testDeploymentApplicationVersion() {
    DeploymentTester tester = new DeploymentTester();
    Application app = tester.createApplication("app1", "tenant1", 1, 11L);
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").region("us-east-3").build();
    SourceRevision source = new SourceRevision("repo", "master", "commit1");
    ApplicationVersion applicationVersion = ApplicationVersion.from(source, 101);
    runDeployment(tester, app.id(), applicationVersion, applicationPackage, source, 101);
    assertEquals("Artifact is downloaded twice in staging and once for other zones", 5, tester.artifactRepository().hits(app.id(), applicationVersion.id()));
    // Application is upgraded. This makes deployment orchestration pick the last successful application version in
    // zones which do not have permanent deployments, e.g. test and staging
    runUpgrade(tester, app.id(), applicationVersion);
}
Also used : SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) 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)

Example 2 with SourceRevision

use of com.yahoo.vespa.hosted.controller.application.SourceRevision 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 3 with SourceRevision

use of com.yahoo.vespa.hosted.controller.application.SourceRevision 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 4 with SourceRevision

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

the class ApplicationSerializerTest method testSerialization.

@Test
public void testSerialization() {
    ControllerTester tester = new ControllerTester();
    DeploymentSpec deploymentSpec = DeploymentSpec.fromXml("<deployment version='1.0'>" + "   <staging/>" + "</deployment>");
    ValidationOverrides validationOverrides = ValidationOverrides.fromXml("<validation-overrides version='1.0'>" + "  <allow until='2017-06-15'>deployment-removal</allow>" + "</validation-overrides>");
    List<Deployment> deployments = new ArrayList<>();
    ApplicationVersion applicationVersion1 = ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 31);
    ApplicationVersion applicationVersion2 = ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 32);
    // One deployment without cluster info and utils
    deployments.add(new Deployment(zone1, applicationVersion1, Version.fromString("1.2.3"), Instant.ofEpochMilli(3)));
    deployments.add(new Deployment(zone2, applicationVersion2, Version.fromString("1.2.3"), Instant.ofEpochMilli(5), createClusterUtils(3, 0.2), createClusterInfo(3, 4), new DeploymentMetrics(2, 3, 4, 5, 6)));
    Optional<Long> projectId = Optional.of(123L);
    List<JobStatus> statusList = new ArrayList<>();
    statusList.add(JobStatus.initial(DeploymentJobs.JobType.systemTest).withTriggering(Version.fromString("5.6.7"), ApplicationVersion.unknown, "Test", Instant.ofEpochMilli(7)).withCompletion(30, Optional.empty(), Instant.ofEpochMilli(8), tester.controller()));
    statusList.add(JobStatus.initial(DeploymentJobs.JobType.stagingTest).withTriggering(Version.fromString("5.6.6"), ApplicationVersion.unknown, "Test 2", Instant.ofEpochMilli(5)).withCompletion(11, Optional.of(JobError.unknown), Instant.ofEpochMilli(6), tester.controller()));
    DeploymentJobs deploymentJobs = new DeploymentJobs(projectId, statusList, Optional.empty());
    Application original = new Application(ApplicationId.from("t1", "a1", "i1"), deploymentSpec, validationOverrides, deployments, deploymentJobs, Change.of(Version.fromString("6.7")), Change.of(ApplicationVersion.from(new SourceRevision("repo", "master", "deadcafe"), 42)), Optional.of(IssueId.from("1234")), new MetricsService.ApplicationMetrics(0.5, 0.9), Optional.of(new RotationId("my-rotation")));
    Application serialized = applicationSerializer.fromSlime(applicationSerializer.toSlime(original));
    assertEquals(original.id(), serialized.id());
    assertEquals(original.deploymentSpec().xmlForm(), serialized.deploymentSpec().xmlForm());
    assertEquals(original.validationOverrides().xmlForm(), serialized.validationOverrides().xmlForm());
    assertEquals(2, serialized.deployments().size());
    assertEquals(original.deployments().get(zone1).applicationVersion(), serialized.deployments().get(zone1).applicationVersion());
    assertEquals(original.deployments().get(zone2).applicationVersion(), serialized.deployments().get(zone2).applicationVersion());
    assertEquals(original.deployments().get(zone1).version(), serialized.deployments().get(zone1).version());
    assertEquals(original.deployments().get(zone2).version(), serialized.deployments().get(zone2).version());
    assertEquals(original.deployments().get(zone1).at(), serialized.deployments().get(zone1).at());
    assertEquals(original.deployments().get(zone2).at(), serialized.deployments().get(zone2).at());
    assertEquals(original.deploymentJobs().projectId(), serialized.deploymentJobs().projectId());
    assertEquals(original.deploymentJobs().jobStatus().size(), serialized.deploymentJobs().jobStatus().size());
    assertEquals(original.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.systemTest), serialized.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.systemTest));
    assertEquals(original.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.stagingTest), serialized.deploymentJobs().jobStatus().get(DeploymentJobs.JobType.stagingTest));
    assertEquals(original.outstandingChange(), serialized.outstandingChange());
    assertEquals(original.ownershipIssueId(), serialized.ownershipIssueId());
    assertEquals(original.change(), serialized.change());
    assertEquals(original.rotation().get().id(), serialized.rotation().get().id());
    // Test cluster utilization
    assertEquals(0, serialized.deployments().get(zone1).clusterUtils().size());
    assertEquals(3, serialized.deployments().get(zone2).clusterUtils().size());
    assertEquals(0.4, serialized.deployments().get(zone2).clusterUtils().get(ClusterSpec.Id.from("id2")).getCpu(), 0.01);
    assertEquals(0.2, serialized.deployments().get(zone2).clusterUtils().get(ClusterSpec.Id.from("id1")).getCpu(), 0.01);
    assertEquals(0.2, serialized.deployments().get(zone2).clusterUtils().get(ClusterSpec.Id.from("id1")).getMemory(), 0.01);
    // Test cluster info
    assertEquals(3, serialized.deployments().get(zone2).clusterInfo().size());
    assertEquals(10, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavorCost());
    assertEquals(ClusterSpec.Type.content, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getClusterType());
    assertEquals("flavor2", serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavor());
    assertEquals(4, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getHostnames().size());
    assertEquals(2, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavorCPU(), Double.MIN_VALUE);
    assertEquals(4, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavorMem(), Double.MIN_VALUE);
    assertEquals(50, serialized.deployments().get(zone2).clusterInfo().get(ClusterSpec.Id.from("id2")).getFlavorDisk(), Double.MIN_VALUE);
    // Test metrics
    assertEquals(original.metrics().queryServiceQuality(), serialized.metrics().queryServiceQuality(), Double.MIN_VALUE);
    assertEquals(original.metrics().writeServiceQuality(), serialized.metrics().writeServiceQuality(), Double.MIN_VALUE);
    assertEquals(2, serialized.deployments().get(zone2).metrics().queriesPerSecond(), Double.MIN_VALUE);
    assertEquals(3, serialized.deployments().get(zone2).metrics().writesPerSecond(), Double.MIN_VALUE);
    assertEquals(4, serialized.deployments().get(zone2).metrics().documentCount(), Double.MIN_VALUE);
    assertEquals(5, serialized.deployments().get(zone2).metrics().queryLatencyMillis(), Double.MIN_VALUE);
    assertEquals(6, serialized.deployments().get(zone2).metrics().writeLatencyMillis(), Double.MIN_VALUE);
    {
        // test more deployment serialization cases
        Application original2 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("repo1", "branch1", "commit1"), 42)));
        Application serialized2 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original2));
        assertEquals(original2.change(), serialized2.change());
        assertEquals(serialized2.change().application().get().source(), original2.change().application().get().source());
        Application original3 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42)));
        Application serialized3 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original3));
        assertEquals(original3.change(), serialized3.change());
        assertEquals(serialized3.change().application().get().source(), original3.change().application().get().source());
        Application original4 = writable(original).withChange(Change.empty());
        Application serialized4 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original4));
        assertEquals(original4.change(), serialized4.change());
        Application original5 = writable(original).withChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42)));
        Application serialized5 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original5));
        assertEquals(original5.change(), serialized5.change());
        Application original6 = writable(original).withOutstandingChange(Change.of(ApplicationVersion.from(new SourceRevision("a", "b", "c"), 42)));
        Application serialized6 = applicationSerializer.fromSlime(applicationSerializer.toSlime(original6));
        assertEquals(original6.outstandingChange(), serialized6.outstandingChange());
    }
}
Also used : SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) DeploymentMetrics(com.yahoo.vespa.hosted.controller.application.DeploymentMetrics) MetricsService(com.yahoo.vespa.hosted.controller.api.integration.MetricsService) ArrayList(java.util.ArrayList) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) ValidationOverrides(com.yahoo.config.application.api.ValidationOverrides) RotationId(com.yahoo.vespa.hosted.controller.rotation.RotationId) Application(com.yahoo.vespa.hosted.controller.Application) Test(org.junit.Test)

Aggregations

SourceRevision (com.yahoo.vespa.hosted.controller.application.SourceRevision)4 Test (org.junit.Test)4 Application (com.yahoo.vespa.hosted.controller.Application)3 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)3 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)3 Version (com.yahoo.component.Version)2 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)2 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)2 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)2 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)2 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)2 DeploymentSpec (com.yahoo.config.application.api.DeploymentSpec)1 ValidationOverrides (com.yahoo.config.application.api.ValidationOverrides)1 ManualClock (com.yahoo.test.ManualClock)1 LockedApplication (com.yahoo.vespa.hosted.controller.LockedApplication)1 BuildService (com.yahoo.vespa.hosted.controller.api.integration.BuildService)1 MetricsService (com.yahoo.vespa.hosted.controller.api.integration.MetricsService)1 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)1 DeploymentJobs (com.yahoo.vespa.hosted.controller.application.DeploymentJobs)1 DeploymentMetrics (com.yahoo.vespa.hosted.controller.application.DeploymentMetrics)1