use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.
the class ApplicationApiTest method setDeploymentMaintainedInfo.
/**
* Cluster info, utilization and application and deployment metrics are maintained async by maintainers.
*
* This sets these values as if the maintainers has been ran.
*
* @param controllerTester
*/
private void setDeploymentMaintainedInfo(ContainerControllerTester controllerTester) {
for (Application application : controllerTester.controller().applications().asList()) {
controllerTester.controller().applications().lockOrThrow(application.id(), lockedApplication -> {
lockedApplication = lockedApplication.with(new ApplicationMetrics(0.5, 0.7));
for (Deployment deployment : application.deployments().values()) {
Map<ClusterSpec.Id, ClusterInfo> clusterInfo = new HashMap<>();
List<String> hostnames = new ArrayList<>();
hostnames.add("host1");
hostnames.add("host2");
clusterInfo.put(ClusterSpec.Id.from("cluster1"), new ClusterInfo("flavor1", 37, 2, 4, 50, ClusterSpec.Type.content, hostnames));
Map<ClusterSpec.Id, ClusterUtilization> clusterUtils = new HashMap<>();
clusterUtils.put(ClusterSpec.Id.from("cluster1"), new ClusterUtilization(0.3, 0.6, 0.4, 0.3));
DeploymentMetrics metrics = new DeploymentMetrics(1, 2, 3, 4, 5);
lockedApplication = lockedApplication.withClusterInfo(deployment.zone(), clusterInfo).withClusterUtilization(deployment.zone(), clusterUtils).with(deployment.zone(), metrics);
}
controllerTester.controller().applications().store(lockedApplication);
});
}
}
use of com.yahoo.vespa.hosted.controller.Application 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);
}
use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.
the class FailureRedeployerTest method testRetriesJobsFailingForCurrentChange.
@Test
public void testRetriesJobsFailingForCurrentChange() {
DeploymentTester tester = new DeploymentTester();
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").environment(Environment.prod).region("us-east-3").build();
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
Application app = tester.createApplication("app1", "tenant1", 1, 11L);
tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit();
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
// New version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
// system-test fails and is left with a retry
tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.systemTest);
// Another version is released
version = Version.fromString("5.2");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
// Job is left "running", so needs to time out before it can be retried.
tester.clock().advance(Duration.ofHours(13));
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
// Cancellation of outdated version and triggering on a new version is done by the upgrader.
assertEquals(version, tester.application(app.id()).deploymentJobs().jobStatus().get(systemTest).lastTriggered().get().version());
}
use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.
the class FailureRedeployerTest method testRetryingFailedJobsDuringDeployment.
@Test
public void testRetryingFailedJobsDuringDeployment() {
DeploymentTester tester = new DeploymentTester();
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").environment(Environment.prod).region("us-east-3").build();
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
Application app = tester.createApplication("app1", "tenant1", 1, 11L);
tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit();
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
// New version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
// Test environments pass
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
// Production job fails and is retried
// Advance time so that we can detect jobs in progress
tester.clock().advance(Duration.ofSeconds(1));
tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.productionUsEast3);
assertEquals("Production job is retried", 1, tester.deploymentQueue().jobs().size());
assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
// Another version is released, which cancels any pending upgrades to lower versions
version = Version.fromString("5.2");
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Application starts upgrading to new version", 1, tester.deploymentQueue().jobs().size());
assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
// Failure re-deployer does not retry failing job for prod.us-east-3, since it no longer has an available change
tester.clock().advance(Duration.ofMinutes(1));
tester.jobCompletion(DeploymentJobs.JobType.productionUsEast3).application(app).unsuccessful().submit();
assertFalse("Job is not retried", tester.deploymentQueue().jobs().stream().anyMatch(j -> j.jobName().equals(DeploymentJobs.JobType.productionUsEast3.jobName())));
// Test environments pass
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
// Production job fails again, and is retried
tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.productionUsEast3);
tester.readyJobTrigger().maintain();
assertEquals("Job is retried", Collections.singletonList(new BuildService.BuildJob(app.deploymentJobs().projectId().get(), productionUsEast3.jobName())), tester.deploymentQueue().jobs());
// Production job finally succeeds
tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
assertFalse("No failures", tester.application(app.id()).deploymentJobs().hasFailures());
}
use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.
the class RotationTest method application_with_only_one_non_corp_region.
@Test
public void application_with_only_one_non_corp_region() {
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().globalServiceId("foo").region("us-east-3").region("corp-us-east-1").build();
Application application = tester.createApplication("app2", "tenant2", 22L, 2L);
thrown.expect(RuntimeException.class);
thrown.expectMessage("less than 2 prod zones are defined");
tester.deployCompletely(application, applicationPackage);
}
Aggregations