use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ControllerTester method createApplication.
public Application createApplication(TenantId tenant, String applicationName, String instanceName, long projectId) {
ApplicationId applicationId = ApplicationId.from(tenant.id(), applicationName, instanceName);
controller().applications().createApplication(applicationId, Optional.of(TestIdentities.userNToken));
controller().applications().lockOrThrow(applicationId, lockedApplication -> controller().applications().store(lockedApplication.withProjectId(projectId)));
return controller().applications().require(applicationId);
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ClusterInfoMaintainerTest 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.clusterInfo().size());
ClusterInfoMaintainer mainainer = new ClusterInfoMaintainer(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(2, deployment.clusterInfo().size());
Assert.assertEquals(10, deployment.clusterInfo().get(ClusterSpec.Id.from("clusterA")).getFlavorCost());
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ControllerTest method testGlobalRotations.
@Test
public void testGlobalRotations() throws IOException {
// Setup tester and app def
ControllerTester tester = new ControllerTester();
ZoneId zone = ZoneId.from(Environment.defaultEnvironment(), RegionName.defaultName());
ApplicationId appId = ApplicationId.from("tenant", "app1", "default");
DeploymentId deployId = new DeploymentId(appId, zone);
// Check initial rotation status
Map<String, EndpointStatus> rotationStatus = tester.controller().applications().getGlobalRotationStatus(deployId);
assertEquals(1, rotationStatus.size());
assertTrue(rotationStatus.get("qrs-endpoint").getStatus().equals(EndpointStatus.Status.in));
// Set the global rotations out of service
EndpointStatus status = new EndpointStatus(EndpointStatus.Status.out, "Testing I said", "Test", tester.clock().instant().getEpochSecond());
List<String> overrides = tester.controller().applications().setGlobalRotationStatus(deployId, status);
assertEquals(1, overrides.size());
// Recheck the override rotation status
rotationStatus = tester.controller().applications().getGlobalRotationStatus(deployId);
assertEquals(1, rotationStatus.size());
assertTrue(rotationStatus.get("qrs-endpoint").getStatus().equals(EndpointStatus.Status.out));
assertTrue(rotationStatus.get("qrs-endpoint").getReason().equals("Testing I said"));
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class ControllerTest method testPullRequestDeployment.
@Test
public void testPullRequestDeployment() {
// Setup system
ControllerTester tester = new ControllerTester();
ApplicationController applications = tester.controller().applications();
// staging deployment
long app1ProjectId = 22;
ApplicationId app1 = tester.createAndDeploy("tenant1", "domain1", "application1", Environment.staging, app1ProjectId).id();
// pull-request deployment - uses different instance id
ApplicationId app1pr = tester.createAndDeploy("tenant1", "domain1", "application1", "1", Environment.staging, app1ProjectId, null).id();
assertTrue(applications.get(app1).isPresent());
assertEquals(app1, applications.get(app1).get().id());
assertTrue(applications.get(app1pr).isPresent());
assertEquals(app1pr, applications.get(app1pr).get().id());
// Simulate restart
tester.createNewController();
applications = tester.controller().applications();
assertTrue(applications.get(app1).isPresent());
assertEquals(app1, applications.get(app1).get().id());
assertTrue(applications.get(app1pr).isPresent());
assertEquals(app1pr, applications.get(app1pr).get().id());
// Deleting application also removes PR instance
ApplicationId app2 = tester.createAndDeploy("tenant1", "domain1", "application2", Environment.staging, 33).id();
tester.controller().applications().deleteApplication(app1, Optional.of(new NToken("ntoken")));
assertEquals("All instances deleted", 0, tester.controller().applications().asList(app1.tenant()).stream().filter(app -> app.id().application().equals(app1.application())).count());
assertEquals("Other application survives", 1, tester.controller().applications().asList(app1.tenant()).stream().filter(app -> app.id().application().equals(app2.application())).count());
}
use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.
the class DeploymentJobExecutorTest method testMaintenance.
@Test
public void testMaintenance() {
DeploymentTester tester = new DeploymentTester();
JobControl jobControl = new JobControl(tester.controller().curator());
int project1 = 1;
int project2 = 2;
int project3 = 3;
ApplicationId app1 = tester.createApplication("app1", "tenant", project1, null).id();
ApplicationId app2 = tester.createApplication("app2", "tenant", project2, null).id();
ApplicationId app3 = tester.createApplication("app3", "tenant", project3, null).id();
// Create a BuildService which always rejects jobs from project2, but accepts and runs all others.
ArrayList<BuildJob> buildJobs = new ArrayList<>();
BuildService buildService = buildJob -> buildJob.projectId() == project2 ? false : buildJobs.add(buildJob);
DeploymentJobExecutor triggerer = new DeploymentJobExecutor(tester.controller(), Duration.ofDays(1), jobControl, buildService, Runnable::run);
triggerer.maintain();
assertEquals("No jobs are triggered initially.", Collections.emptyList(), buildJobs);
// Trigger jobs in capacity constrained environment
tester.deploymentQueue().addJob(app1, DeploymentJobs.JobType.systemTest, false);
tester.deploymentQueue().addJob(app2, DeploymentJobs.JobType.systemTest, false);
tester.deploymentQueue().addJob(app3, DeploymentJobs.JobType.systemTest, false);
// Trigger jobs in non-capacity constrained environment
tester.deploymentQueue().addJob(app1, DeploymentJobs.JobType.productionUsWest1, false);
tester.deploymentQueue().addJob(app2, DeploymentJobs.JobType.productionUsWest1, false);
tester.deploymentQueue().addJob(app3, DeploymentJobs.JobType.productionUsWest1, false);
triggerer.maintain();
assertEquals("One system test job and all production jobs not for app2 are triggered after one maintenance run.", Arrays.asList(new BuildJob(project1, DeploymentJobs.JobType.systemTest.jobName()), new BuildJob(project1, DeploymentJobs.JobType.productionUsWest1.jobName()), new BuildJob(project3, DeploymentJobs.JobType.productionUsWest1.jobName())), buildJobs);
buildJobs.clear();
triggerer.maintain();
assertEquals("Next job in line fails to trigger in the build service.", Collections.emptyList(), buildJobs);
buildJobs.clear();
triggerer.maintain();
assertEquals("Next job which was waiting for capacity is triggered on next run.", Collections.singletonList(new BuildJob(project3, DeploymentJobs.JobType.systemTest.jobName())), buildJobs);
buildJobs.clear();
triggerer.maintain();
assertEquals("No jobs are left.", Collections.emptyList(), tester.deploymentQueue().takeJobsToRun());
}
Aggregations