Search in sources :

Example 11 with ContainerControllerTester

use of com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester in project vespa by vespa-engine.

the class ApplicationApiTest method deployment_fails_on_illegal_domain_in_deployment_spec.

@Test
public void deployment_fails_on_illegal_domain_in_deployment_spec() throws IOException {
    ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles);
    ContainerTester tester = controllerTester.containerTester();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("default").athenzIdentity(com.yahoo.config.provision.AthenzDomain.from("invalid.domain"), com.yahoo.config.provision.AthenzService.from("service")).environment(Environment.prod).region("us-west-1").build();
    long screwdriverProjectId = 123;
    createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
    Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1");
    ScrewdriverId screwdriverId = new ScrewdriverId(Long.toString(screwdriverProjectId));
    controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application);
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/test/region/us-east-1/instance/default/", POST).data(createApplicationDeployData(applicationPackage, Optional.of(screwdriverProjectId))).screwdriverIdentity(screwdriverId), "{\"error-code\":\"FORBIDDEN\",\"message\":\"Athenz domain in deployment.xml: [invalid.domain] must match tenant domain: [domain1]\"}", 403);
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ContainerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerTester) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 12 with ContainerControllerTester

use of com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester in project vespa by vespa-engine.

the class ApplicationApiTest method testDeployDirectly.

@Test
public void testDeployDirectly() throws Exception {
    // Setup
    ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles);
    ContainerTester tester = controllerTester.containerTester();
    tester.updateSystemVersion();
    createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
    // Create tenant
    tester.assertResponse(request("/application/v4/tenant/tenant1", POST).userIdentity(USER_ID).data("{\"athensDomain\":\"domain1\", \"property\":\"property1\"}").nToken(N_TOKEN), new File("tenant-without-applications.json"));
    // Create application
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1", POST).userIdentity(USER_ID).nToken(N_TOKEN), new File("application-reference.json"));
    // Grant deploy access
    addScrewdriverUserToDeployRole(SCREWDRIVER_ID, ATHENZ_TENANT_DOMAIN, new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId("application1"));
    // POST (deploy) an application to a prod zone - allowed when project ID is not specified
    HttpEntity entity = createApplicationDeployData(applicationPackage, Optional.empty());
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/corp-us-east-1/instance/default/deploy", POST).data(entity).screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json"));
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) HttpEntity(org.apache.http.HttpEntity) ContainerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerTester) File(java.io.File) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 13 with ContainerControllerTester

use of com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester in project vespa by vespa-engine.

the class ControllerApiTest method testControllerApi.

@Test
public void testControllerApi() throws Exception {
    ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
    tester.assertResponse(authenticatedRequest("http://localhost:8080/controller/v1/", new byte[0], Request.Method.GET), new File("root.json"));
    // POST deactivation of a maintenance job
    assertResponse(authenticatedRequest("http://localhost:8080/controller/v1/maintenance/inactive/DeploymentExpirer", new byte[0], Request.Method.POST), 200, "{\"message\":\"Deactivated job 'DeploymentExpirer'\"}");
    // GET a list of all maintenance jobs
    tester.assertResponse(authenticatedRequest("http://localhost:8080/controller/v1/maintenance/", new byte[0], Request.Method.GET), new File("maintenance.json"));
    // DELETE deactivation of a maintenance job
    assertResponse(authenticatedRequest("http://localhost:8080/controller/v1/maintenance/inactive/DeploymentExpirer", new byte[0], Request.Method.DELETE), 200, "{\"message\":\"Re-activated job 'DeploymentExpirer'\"}");
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) File(java.io.File) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 14 with ContainerControllerTester

use of com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester in project vespa by vespa-engine.

the class ZoneApiTest method before.

@Before
public void before() {
    ZoneRegistryMock zoneRegistry = (ZoneRegistryMock) container.components().getComponent(ZoneRegistryMock.class.getName());
    zoneRegistry.setDefaultRegionForEnvironment(Environment.dev, RegionName.from("us-north-2")).setZones(zones);
    this.tester = new ContainerControllerTester(container, responseFiles);
    this.proxy = (ConfigServerProxyMock) container.components().getComponent(ConfigServerProxyMock.class.getName());
    addUserToHostedOperatorRole(HOSTED_VESPA_OPERATOR);
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) ConfigServerProxyMock(com.yahoo.vespa.hosted.controller.ConfigServerProxyMock) ZoneRegistryMock(com.yahoo.vespa.hosted.controller.ZoneRegistryMock) Before(org.junit.Before)

Aggregations

ContainerControllerTester (com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester)14 ControllerContainerTest (com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest)12 Test (org.junit.Test)12 File (java.io.File)8 Application (com.yahoo.vespa.hosted.controller.Application)6 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)6 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)6 ContainerTester (com.yahoo.vespa.hosted.controller.restapi.ContainerTester)5 HttpEntity (org.apache.http.HttpEntity)3 Request (com.yahoo.application.container.handler.Request)2 Version (com.yahoo.component.Version)2 ApplicationId (com.yahoo.config.provision.ApplicationId)2 ZoneRegistryMock (com.yahoo.vespa.hosted.controller.ZoneRegistryMock)2 ScrewdriverId (com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId)2 JobStatus (com.yahoo.vespa.hosted.controller.application.JobStatus)2 BuildJob (com.yahoo.vespa.hosted.controller.deployment.BuildJob)2 Before (org.junit.Before)2 Response (com.yahoo.application.container.handler.Response)1 AthenzDomain (com.yahoo.vespa.athenz.api.AthenzDomain)1 ConfigServerProxyMock (com.yahoo.vespa.hosted.controller.ConfigServerProxyMock)1