summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2019-11-04 14:42:33 +0100
committerJon Marius Venstad <venstad@gmail.com>2019-11-04 14:47:22 +0100
commitd6ec79f8acc3e37cd752785017a6b767daad38f4 (patch)
tree1555e14cd4816afdf5486e894490a67f29bcc8c2 /controller-server
parent62daf7b1734f817da94668dc6a526e7fe6d9c5bb (diff)
Remove ContainerControllerTester and BuildJob
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java128
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java153
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java20
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java26
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance-with-routing-policy.json12
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/athenz/AthenzApiTest.java3
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/ControllerApiTest.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiTest.java17
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java26
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java45
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json43
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/flags/AuditedFlagsApiTest.java6
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiTest.java13
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v1/ZoneApiTest.java14
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v2/ZoneApiTest.java22
15 files changed, 98 insertions, 438 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java
deleted file mode 100644
index 63d84926144..00000000000
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/BuildJob.java
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.deployment;
-
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.vespa.hosted.controller.Application;
-import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion;
-import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
-import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision;
-import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
-import com.yahoo.vespa.hosted.controller.application.DeploymentJobs;
-import com.yahoo.vespa.hosted.controller.integration.ArtifactRepositoryMock;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
-
-import java.util.Objects;
-import java.util.Optional;
-import java.util.function.Consumer;
-
-import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component;
-
-public class BuildJob {
-
- public static final long defaultBuildNumber = 42;
-
- private JobType job;
- private ApplicationId applicationId;
- private Optional<DeploymentJobs.JobError> jobError = Optional.empty();
- private Optional<SourceRevision> sourceRevision = Optional.of(DeploymentContext.defaultSourceRevision);
- private long projectId;
- private long buildNumber = defaultBuildNumber;
-
- private final Consumer<DeploymentJobs.JobReport> reportConsumer;
- private final ArtifactRepositoryMock artifactRepository;
-
- public BuildJob(Consumer<DeploymentJobs.JobReport> reportConsumer, ArtifactRepositoryMock artifactRepository) {
- Objects.requireNonNull(reportConsumer, "reportConsumer cannot be null");
- Objects.requireNonNull(artifactRepository, "artifactRepository cannot be null");
- this.reportConsumer = reportConsumer;
- this.artifactRepository = artifactRepository;
- }
-
- public BuildJob type(JobType job) {
- this.job = job;
- return this;
- }
-
- public BuildJob application(Application application) {
- if (application.projectId().isPresent())
- this.projectId = application.projectId().getAsLong();
-
- return application(application.id().defaultInstance());
- }
-
- public BuildJob application(ApplicationId applicationId) {
- this.applicationId = applicationId;
- return this;
- }
-
- public BuildJob error(DeploymentJobs.JobError jobError) {
- this.jobError = Optional.of(jobError);
- return this;
- }
-
- public BuildJob sourceRevision(SourceRevision sourceRevision) {
- this.sourceRevision = Optional.of(sourceRevision);
- return this;
- }
-
- public BuildJob buildNumber(long buildNumber) {
- this.buildNumber = requireBuildNumber(buildNumber);
- return this;
- }
-
- public BuildJob nextBuildNumber(int increment) {
- return buildNumber(buildNumber + requireBuildNumber(increment));
- }
-
- public BuildJob nextBuildNumber() {
- return nextBuildNumber(1);
- }
-
- public BuildJob projectId(long projectId) {
- this.projectId = projectId;
- return this;
- }
-
- public BuildJob success(boolean success) {
- this.jobError = success ? Optional.empty() : Optional.of(DeploymentJobs.JobError.unknown);
- return this;
- }
-
- public BuildJob unsuccessful() {
- return success(false);
- }
-
- /** Create a job report for this build job */
- public DeploymentJobs.JobReport report() {
- return job == component ? DeploymentJobs.JobReport.ofComponent(applicationId, projectId, buildNumber, jobError, sourceRevision.get())
- : DeploymentJobs.JobReport.ofJob(applicationId, job, buildNumber, jobError);
- }
-
- /** Upload given application package to artifact repository as part of this job */
- public BuildJob uploadArtifact(ApplicationPackage applicationPackage) {
- Objects.requireNonNull(job, "job cannot be null");
- Objects.requireNonNull(applicationId, "applicationId cannot be null");
- if (job != component) {
- throw new IllegalStateException(job + " cannot upload artifact");
- }
- artifactRepository.put(applicationId, applicationPackage, ApplicationVersion.from(sourceRevision.get(), buildNumber).id());
- return this;
- }
-
- /** Send report for this build job to the controller */
- public void submit() {
- if (job == component &&
- !artifactRepository.contains(applicationId, ApplicationVersion.from(sourceRevision.get(), buildNumber).id())) {
- throw new IllegalStateException(job + " must upload artifact before reporting completion");
- }
- reportConsumer.accept(report());
- }
-
- private static long requireBuildNumber(long n) {
- if (n <= 0) {
- throw new IllegalArgumentException("Build number must be positive");
- }
- return n;
- }
-
-}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java
deleted file mode 100644
index d7d3a2c97b1..00000000000
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerControllerTester.java
+++ /dev/null
@@ -1,153 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.restapi;
-
-import com.yahoo.application.container.JDisc;
-import com.yahoo.application.container.handler.Request;
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.Environment;
-import com.yahoo.config.provision.TenantName;
-import com.yahoo.config.provision.zone.ZoneId;
-import com.yahoo.vespa.athenz.api.AthenzDomain;
-import com.yahoo.vespa.athenz.api.AthenzPrincipal;
-import com.yahoo.vespa.athenz.api.AthenzUser;
-import com.yahoo.vespa.athenz.api.OktaAccessToken;
-import com.yahoo.vespa.athenz.api.OktaIdentityToken;
-import com.yahoo.vespa.hosted.controller.Application;
-import com.yahoo.vespa.hosted.controller.Controller;
-import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions;
-import com.yahoo.vespa.hosted.controller.api.identifiers.Property;
-import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId;
-import com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId;
-import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
-import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockBuildService;
-import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
-import com.yahoo.vespa.hosted.controller.application.DeploymentJobs;
-import com.yahoo.vespa.hosted.controller.api.integration.athenz.ApplicationAction;
-import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId;
-import com.yahoo.vespa.hosted.controller.athenz.HostedAthenzIdentities;
-import com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactoryMock;
-import com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzDbMock;
-import com.yahoo.vespa.hosted.controller.deployment.BuildJob;
-import com.yahoo.vespa.hosted.controller.deployment.DeploymentSteps;
-import com.yahoo.vespa.hosted.controller.maintenance.JobControl;
-import com.yahoo.vespa.hosted.controller.maintenance.Upgrader;
-import com.yahoo.vespa.hosted.controller.persistence.CuratorDb;
-import com.yahoo.vespa.hosted.controller.security.AthenzCredentials;
-import com.yahoo.vespa.hosted.controller.security.AthenzTenantSpec;
-
-import java.io.File;
-import java.time.Duration;
-import java.util.Optional;
-
-import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.component;
-import static org.junit.Assert.assertFalse;
-
-/**
- * Provides testing of controller functionality accessed through the container
- *
- * @author bratseth
- */
-public class ContainerControllerTester {
-
- private final ContainerTester containerTester;
- private final Upgrader upgrader;
-
- public ContainerControllerTester(JDisc container, String responseFilePath) {
- containerTester = new ContainerTester(container, responseFilePath);
- CuratorDb curatorDb = controller().curator();
- upgrader = new Upgrader(controller(), Duration.ofDays(1), new JobControl(curatorDb), curatorDb);
- upgrader.setUpgradesPerMinute(100); // Anything to make it more than one per maintenance interval.
- }
-
- public Controller controller() { return containerTester.controller(); }
-
- public Upgrader upgrader() { return upgrader; }
-
- /** Returns the wrapped generic container tester */
- public ContainerTester containerTester() { return containerTester; }
-
- public Application createApplication() {
- return createApplication("domain1","tenant1", "application1", "default");
- }
-
- public Application createApplication(String athensDomain, String tenant, String application, String instance) {
- AthenzDomain domain1 = addTenantAthenzDomain(athensDomain, "user");
- AthenzPrincipal user = new AthenzPrincipal(new AthenzUser("user"));
- AthenzCredentials credentials = new AthenzCredentials(
- user, domain1, new OktaIdentityToken("okta-identity-token"), new OktaAccessToken("okta-access-token"));
- AthenzTenantSpec tenantSpec = new AthenzTenantSpec(TenantName.from(tenant),
- domain1,
- new Property("property1"),
- Optional.of(new PropertyId("1234")));
- controller().tenants().create(tenantSpec, credentials);
-
- TenantAndApplicationId id = TenantAndApplicationId.from(tenant, application);
- controller().applications().createApplication(id, Optional.of(credentials));
- controller().applications().createInstance(id.instance(instance));
- return controller().applications().requireApplication(id);
- }
-
- public void deploy(ApplicationId id, ApplicationPackage applicationPackage, ZoneId zone) {
- controller().applications().deploy(id, zone, Optional.of(applicationPackage),
- new DeployOptions(false, Optional.empty(), false, false));
- }
-
- public void deployCompletely(Application application, ApplicationPackage applicationPackage, long projectId,
- boolean failStaging) {
- jobCompletion(JobType.component).application(application)
- .projectId(projectId)
- .uploadArtifact(applicationPackage)
- .submit();
- DeploymentSteps steps = controller().applications().deploymentTrigger().steps(applicationPackage.deploymentSpec());
- // TODO jonmv: Connect instances from deployment spec to deployments below.
- boolean succeeding = true;
- for (var job : steps.jobs()) {
- if (!succeeding) return;
- var zone = job.zone(controller().system());
- deploy(application.id().defaultInstance(), applicationPackage, zone);
- if (failStaging && zone.environment() == Environment.staging) {
- succeeding = false;
- }
- if (zone.environment().isTest()) {
- controller().applications().deactivate(application.id().defaultInstance(), zone);
- }
- jobCompletion(job).application(application).success(succeeding).projectId(projectId).submit();
- }
- }
-
- /** Notify the controller about a job completing */
- public BuildJob jobCompletion(JobType job) {
- return new BuildJob(this::notifyJobCompletion, containerTester.serviceRegistry().artifactRepositoryMock()).type(job);
- }
-
- // ---- Delegators:
-
- public void assertResponse(Request request, File expectedResponse) {
- containerTester.assertResponse(request, expectedResponse);
- }
-
- public void assertResponse(Request request, String expectedResponse, int expectedStatusCode) {
- containerTester.assertResponse(() -> request, expectedResponse, expectedStatusCode);
- }
-
- private void notifyJobCompletion(DeploymentJobs.JobReport report) {
- MockBuildService buildService = containerTester.serviceRegistry().buildServiceMock();
- if (report.jobType() != component && ! buildService.remove(report.buildJob()))
- throw new IllegalArgumentException(report.jobType() + " is not running for " + report.applicationId());
- assertFalse("Unexpected entry '" + report.jobType() + "@" + report.projectId() + " in: " + buildService.jobs(),
- buildService.remove(report.buildJob()));
- controller().applications().deploymentTrigger().notifyOfCompletion(report);
- controller().applications().deploymentTrigger().triggerReadyJobs();
- }
-
- private AthenzDomain addTenantAthenzDomain(String domainName, String userName) {
- AthenzClientFactoryMock mock = (AthenzClientFactoryMock) containerTester.container().components()
- .getComponent(AthenzClientFactoryMock.class.getName());
- AthenzDomain athensDomain = new AthenzDomain(domainName);
- AthenzDbMock.Domain domain = mock.getSetup().getOrCreateDomain(athensDomain);
- domain.markAsVespaTenant();
- domain.admin(new AthenzUser(userName));
- return athensDomain;
- }
-
-}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java
index cd0a3a6f112..df8787a2a4b 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java
@@ -73,22 +73,6 @@ public class ContainerTester {
return (ServiceRegistryMock) container.components().getComponent(ServiceRegistryMock.class.getName());
}
- public void computeVersionStatus() {
- controller().updateVersionStatus(VersionStatus.compute(controller()));
- }
-
- public void upgradeSystem(Version version) {
- var controllerVersion = new ControllerVersion(version, "badc0ffee", Instant.EPOCH);
- controller().curator().writeControllerVersion(controller().hostname(), controllerVersion);
- for (ZoneApi zone : controller().zoneRegistry().zones().all().zones()) {
- for (SystemApplication application : SystemApplication.all()) {
- configServer().setVersion(application.id(), zone.getId(), controllerVersion.version());
- configServer().convergeServices(application.id(), zone.getId());
- }
- }
- computeVersionStatus();
- }
-
public void authorize(AthenzDomain tenantDomain, AthenzIdentity identity, ApplicationAction action, ApplicationName application) {
athenzClientFactory().getSetup()
.domains.get(tenantDomain)
@@ -146,6 +130,10 @@ public class ContainerTester {
assertResponse(() -> request, expectedResponse, 200);
}
+ public void assertResponse(Request request, String expectedResponse, int expectedStatusCode) {
+ assertResponse(() -> request, expectedResponse, expectedStatusCode);
+ }
+
public void assertResponse(Supplier<Request> request, String expectedResponse, int expectedStatusCode) {
assertResponse(request,
(response) -> assertEquals(expectedResponse, new String(response.getBody(), StandardCharsets.UTF_8)),
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
index 1b95e9eeab5..a1c9aa872fd 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
@@ -64,7 +64,6 @@ import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock;
import com.yahoo.vespa.hosted.controller.maintenance.JobControl;
import com.yahoo.vespa.hosted.controller.maintenance.RotationStatusUpdater;
import com.yahoo.vespa.hosted.controller.metric.ApplicationMetrics;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import com.yahoo.vespa.hosted.controller.tenant.AthenzTenant;
@@ -98,9 +97,7 @@ import static com.yahoo.application.container.handler.Request.Method.POST;
import static com.yahoo.application.container.handler.Request.Method.PUT;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
@@ -146,24 +143,20 @@ public class ApplicationApiTest extends ControllerContainerTest {
private static final UserId HOSTED_VESPA_OPERATOR = new UserId("johnoperator");
private static final OktaIdentityToken OKTA_IT = new OktaIdentityToken("okta-it");
private static final OktaAccessToken OKTA_AT = new OktaAccessToken("okta-at");
- private static final ZoneId TEST_ZONE = ZoneId.from(Environment.test, RegionName.from("us-east-1"));
- private static final ZoneId STAGING_ZONE = ZoneId.from(Environment.staging, RegionName.from("us-east-3"));
- private ContainerControllerTester controllerTester;
private ContainerTester tester;
private DeploymentTester deploymentTester;
@Before
public void before() {
- controllerTester = new ContainerControllerTester(container, responseFiles);
- tester = controllerTester.containerTester();
+ tester = new ContainerTester(container, responseFiles);
deploymentTester = new DeploymentTester(new ControllerTester(tester));
+ deploymentTester.controllerTester().computeVersionStatus();
}
@Test
public void testApplicationApi() {
- tester.computeVersionStatus();
createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID); // (Necessary but not provided in this API)
// GET API root
@@ -754,7 +747,6 @@ public class ApplicationApiTest extends ControllerContainerTest {
@Test
public void testRotationOverride() {
// Setup
- tester.computeVersionStatus();
createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
ApplicationPackage applicationPackage = new ApplicationPackageBuilder()
.instances("instance1")
@@ -813,7 +805,6 @@ public class ApplicationApiTest extends ControllerContainerTest {
@Test
public void multiple_endpoints() {
// Setup
- tester.computeVersionStatus();
createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
ApplicationPackage applicationPackage = new ApplicationPackageBuilder()
.instances("instance1")
@@ -860,7 +851,6 @@ public class ApplicationApiTest extends ControllerContainerTest {
@Test
public void testDeployDirectly() {
// Setup
- tester.computeVersionStatus();
createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
addUserToHostedOperatorRole(HostedAthenzIdentities.from(HOSTED_VESPA_OPERATOR));
@@ -895,7 +885,7 @@ public class ApplicationApiTest extends ControllerContainerTest {
.userIdentity(HOSTED_VESPA_OPERATOR),
"{\"error-code\":\"BAD_REQUEST\",\"message\":\"Deployment of system applications during a system upgrade is not allowed\"}",
400);
- tester.upgradeSystem(tester.controller().versionStatus().controllerVersion().get().versionNumber());
+ deploymentTester.controllerTester().upgradeSystem(deploymentTester.controller().versionStatus().controllerVersion().get().versionNumber());
tester.assertResponse(request("/application/v4/tenant/hosted-vespa/application/routing/environment/prod/region/us-central-1/instance/default/deploy", POST)
.data(noAppEntity)
.userIdentity(HOSTED_VESPA_OPERATOR),
@@ -910,8 +900,6 @@ public class ApplicationApiTest extends ControllerContainerTest {
@Test
public void testSortsDeploymentsAndJobs() {
- tester.computeVersionStatus();
-
// Deploy
ApplicationPackage applicationPackage = new ApplicationPackageBuilder()
.instances("instance1")
@@ -1003,7 +991,6 @@ public class ApplicationApiTest extends ControllerContainerTest {
@Test
public void testErrorResponses() throws Exception {
- deploymentTester.controllerTester().computeVersionStatus();
createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
// PUT (update) non-existing tenant returns 403 as tenant access cannot be determined when the tenant does not exist
@@ -1408,7 +1395,6 @@ public class ApplicationApiTest extends ControllerContainerTest {
@Test
public void testJobStatusReporting() {
addUserToHostedOperatorRole(HostedAthenzIdentities.from(HOSTED_VESPA_OPERATOR));
- tester.computeVersionStatus();
var app = deploymentTester.newDeploymentContext(createTenantAndApplication());
Version vespaVersion = tester.configServer().initialVersion(); // system version from mock config server client
@@ -1557,8 +1543,8 @@ public class ApplicationApiTest extends ControllerContainerTest {
* This sets these values as if the maintainers has been ran.
*/
private void setDeploymentMaintainedInfo() {
- for (Application application : controllerTester.controller().applications().asList()) {
- controllerTester.controller().applications().lockApplicationOrThrow(application.id(), lockedApplication -> {
+ for (Application application : deploymentTester.applications().asList()) {
+ deploymentTester.applications().lockApplicationOrThrow(application.id(), lockedApplication -> {
lockedApplication = lockedApplication.with(new ApplicationMetrics(0.5, 0.7));
for (Instance instance : application.instances().values()) {
@@ -1578,7 +1564,7 @@ public class ApplicationApiTest extends ControllerContainerTest {
.with(deployment.zone(), metrics)
.recordActivityAt(Instant.parse("2018-06-01T10:15:30.00Z"), deployment.zone()));
}
- controllerTester.controller().applications().store(lockedApplication);
+ deploymentTester.applications().store(lockedApplication);
}
});
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance-with-routing-policy.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance-with-routing-policy.json
index 844f60ede19..d0abe24fa58 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance-with-routing-policy.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance-with-routing-policy.json
@@ -26,7 +26,7 @@
"gitCommit": "commit1"
}
},
- "reason": "Testing deployment for production-us-west-1 (platform 7, application 1.0.1-commit1)",
+ "reason": "Testing deployment for production-us-west-1 (platform 6.1, application 1.0.1-commit1)",
"at": "(ignore)"
},
"lastCompleted": {
@@ -41,7 +41,7 @@
"gitCommit": "commit1"
}
},
- "reason": "Testing deployment for production-us-west-1 (platform 7, application 1.0.1-commit1)",
+ "reason": "Testing deployment for production-us-west-1 (platform 6.1, application 1.0.1-commit1)",
"at": "(ignore)"
},
"lastSuccess": {
@@ -56,7 +56,7 @@
"gitCommit": "commit1"
}
},
- "reason": "Testing deployment for production-us-west-1 (platform 7, application 1.0.1-commit1)",
+ "reason": "Testing deployment for production-us-west-1 (platform 6.1, application 1.0.1-commit1)",
"at": "(ignore)"
}
},
@@ -75,7 +75,7 @@
"gitCommit": "commit1"
}
},
- "reason": "Testing deployment for production-us-west-1 (platform 7, application 1.0.1-commit1)",
+ "reason": "Testing deployment for production-us-west-1 (platform 6.1, application 1.0.1-commit1)",
"at": "(ignore)"
},
"lastCompleted": {
@@ -90,7 +90,7 @@
"gitCommit": "commit1"
}
},
- "reason": "Testing deployment for production-us-west-1 (platform 7, application 1.0.1-commit1)",
+ "reason": "Testing deployment for production-us-west-1 (platform 6.1, application 1.0.1-commit1)",
"at": "(ignore)"
},
"lastSuccess": {
@@ -105,7 +105,7 @@
"gitCommit": "commit1"
}
},
- "reason": "Testing deployment for production-us-west-1 (platform 7, application 1.0.1-commit1)",
+ "reason": "Testing deployment for production-us-west-1 (platform 6.1, application 1.0.1-commit1)",
"at": "(ignore)"
}
},
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/athenz/AthenzApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/athenz/AthenzApiTest.java
index e0fc403da8e..e3216a0038b 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/athenz/AthenzApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/athenz/AthenzApiTest.java
@@ -3,7 +3,6 @@ package com.yahoo.vespa.hosted.controller.restapi.athenz;
import com.yahoo.vespa.athenz.api.AthenzDomain;
import com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactoryMock;
import com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzDbMock;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import org.junit.Test;
@@ -19,7 +18,7 @@ public class AthenzApiTest extends ControllerContainerTest {
@Test
public void testAthenzApi() {
- ContainerTester tester = new ContainerControllerTester(container, responseFiles).containerTester();
+ ContainerTester tester = new ContainerTester(container, responseFiles);
((AthenzClientFactoryMock) tester.container().components().getComponent(AthenzClientFactoryMock.class.getName()))
.getSetup().addDomain(new AthenzDbMock.Domain(new AthenzDomain("domain1")));
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/ControllerApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/ControllerApiTest.java
index 13e82e5132e..b21c588235e 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/ControllerApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/ControllerApiTest.java
@@ -5,7 +5,7 @@ import com.yahoo.application.container.handler.Request;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.test.ManualClock;
import com.yahoo.vespa.hosted.controller.auditlog.AuditLogger;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import org.junit.Before;
import org.junit.Test;
@@ -26,11 +26,11 @@ public class ControllerApiTest extends ControllerContainerTest {
private static final String responseFiles = "src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/";
- private ContainerControllerTester tester;
+ private ContainerTester tester;
@Before
public void before() {
- tester = new ContainerControllerTester(container, responseFiles);
+ tester = new ContainerTester(container, responseFiles);
}
@Test
@@ -76,7 +76,7 @@ public class ControllerApiTest extends ControllerContainerTest {
public void testUpgraderApi() {
// Get current configuration
tester.assertResponse(authenticatedRequest("http://localhost:8080/controller/v1/jobs/upgrader", "", Request.Method.GET),
- "{\"upgradesPerMinute\":100.0,\"confidenceOverrides\":[]}",
+ "{\"upgradesPerMinute\":0.125,\"confidenceOverrides\":[]}",
200);
// Set invalid configuration
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiTest.java
index b085a87672e..f992a54a114 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiTest.java
@@ -8,8 +8,7 @@ import com.yahoo.config.provision.zone.ZoneApi;
import com.yahoo.vespa.athenz.api.AthenzIdentity;
import com.yahoo.vespa.athenz.api.AthenzUser;
import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock;
-import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import org.junit.Before;
import org.junit.Test;
@@ -27,13 +26,13 @@ public class CostApiTest extends ControllerContainerTest {
private static final ZoneApi zone2 = ZoneApiMock.newBuilder().withId("prod.us-west-1").with(cloud1).build();
private static final ZoneApi zone3 = ZoneApiMock.newBuilder().withId("prod.eu-west-1").with(cloud2).build();
- private ContainerControllerTester tester;
+ private ContainerTester tester;
@Before
public void before() {
- tester = new ContainerControllerTester(container, responses);
- zoneRegistryMock().setSystemName(SystemName.cd)
- .setZones(zone1, zone2, zone3);
+ tester = new ContainerTester(container, responses);
+ tester.serviceRegistry().zoneRegistry().setSystemName(SystemName.cd)
+ .setZones(zone1, zone2, zone3);
}
@Test
@@ -42,13 +41,9 @@ public class CostApiTest extends ControllerContainerTest {
"Date,Property,Reserved Cpu Cores,Reserved Memory GB,Reserved Disk Space GB,Usage Fraction\n", 200);
}
- private ZoneRegistryMock zoneRegistryMock() {
- return (ZoneRegistryMock) tester.containerTester().container().components()
- .getComponent(ZoneRegistryMock.class.getName());
- }
-
private void assertResponse(Request request, String body, int statusCode) {
addIdentityToRequest(request, operator);
tester.assertResponse(request, body, statusCode);
}
+
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java
index 35ec5b0e37e..37cf5511c0b 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiTest.java
@@ -1,12 +1,8 @@
package com.yahoo.vespa.hosted.controller.restapi.deployment;
-import com.yahoo.config.provision.AthenzService;
-import com.yahoo.config.provision.Environment;
-import com.yahoo.vespa.hosted.controller.Application;
-import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision;
-import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
-import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
+import com.yahoo.vespa.hosted.controller.ControllerTester;
+import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import org.junit.Test;
@@ -19,19 +15,9 @@ public class BadgeApiTest extends ControllerContainerTest {
@Test
public void testBadgeApi() {
- ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
- Application application = tester.createApplication("domain", "tenant", "application", "default");
- ApplicationPackage packageWithService = new ApplicationPackageBuilder()
- .environment(Environment.prod)
- .athenzIdentity(com.yahoo.config.provision.AthenzDomain.from("domain"), AthenzService.from("service"))
- .region("us-west-1")
- .build();
- tester.controller().jobController().submit(application.id(),
- new SourceRevision("repository", "branch", "commit"),
- "foo@bar",
- 123,
- packageWithService,
- new byte[0]);
+ ContainerTester tester = new ContainerTester(container, responseFiles);
+ var application = new DeploymentTester(new ControllerTester(tester)).newDeploymentContext("tenant", "application", "default");
+ application.submit();
tester.assertResponse(authenticatedRequest("http://localhost:8080/badge/v1/tenant/application/default"),
"", 302);
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java
index bb1e6b6256a..3c23053eac0 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java
@@ -5,11 +5,12 @@ import com.yahoo.component.Version;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.zone.ZoneId;
-import com.yahoo.vespa.hosted.controller.Application;
-import com.yahoo.vespa.hosted.controller.Controller;
+import com.yahoo.vespa.hosted.controller.ControllerTester;
+import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
+import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import com.yahoo.vespa.hosted.controller.versions.NodeVersion;
import com.yahoo.vespa.hosted.controller.versions.NodeVersions;
@@ -31,42 +32,42 @@ public class DeploymentApiTest extends ControllerContainerTest {
@Test
public void testDeploymentApi() {
- ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
+ ContainerTester tester = new ContainerTester(container, responseFiles);
+ DeploymentTester deploymentTester = new DeploymentTester(new ControllerTester(tester));
Version version = Version.fromString("5.0");
- tester.containerTester().upgradeSystem(version);
+ deploymentTester.controllerTester().upgradeSystem(version);
ApplicationPackage applicationPackage = new ApplicationPackageBuilder()
.environment(Environment.prod)
.region("us-west-1")
.build();
// 3 applications deploy on current system version
- Application failingInstance = tester.createApplication("domain1", "tenant1", "application1", "default");
- Application productionInstance = tester.createApplication("domain2", "tenant2", "application2", "default");
- Application instanceWithoutDeployment = tester.createApplication("domain3", "tenant3", "application3", "default");
- tester.deployCompletely(failingInstance, applicationPackage, 1L, false);
- tester.deployCompletely(productionInstance, applicationPackage, 2L, false);
+ var failingApp = deploymentTester.newDeploymentContext("tenant1", "application1", "default");
+ var productionApp = deploymentTester.newDeploymentContext("tenant2", "application2", "default");
+ var appWithoutDeployments = deploymentTester.newDeploymentContext("tenant3", "application3", "default");
+ failingApp.submit(applicationPackage).deploy();
+ productionApp.submit(applicationPackage).deploy();
// Deploy once so that job information is stored, then remove the deployment
- tester.deployCompletely(instanceWithoutDeployment, applicationPackage, 3L, false);
- tester.controller().applications().deactivate(instanceWithoutDeployment.id().defaultInstance(), ZoneId.from("prod", "us-west-1"));
+ appWithoutDeployments.submit(applicationPackage).deploy();
+ deploymentTester.applications().deactivate(appWithoutDeployments.instanceId(), ZoneId.from("prod", "us-west-1"));
// New version released
version = Version.fromString("5.1");
- tester.containerTester().upgradeSystem(version);
+ deploymentTester.controllerTester().upgradeSystem(version);
// Applications upgrade, 1/2 succeed
- tester.upgrader().maintain();
- tester.controller().applications().deploymentTrigger().triggerReadyJobs();
- tester.controller().applications().deploymentTrigger().triggerReadyJobs();
- tester.deployCompletely(failingInstance, applicationPackage, 1L, true);
- tester.deployCompletely(productionInstance, applicationPackage, 2L, false);
+ deploymentTester.upgrader().maintain();
+ deploymentTester.triggerJobs();
+ productionApp.deployPlatform(version);
+ failingApp.runJob(JobType.systemTest).failDeployment(JobType.stagingTest);
+ deploymentTester.triggerJobs();
- tester.controller().updateVersionStatus(censorConfigServers(VersionStatus.compute(tester.controller()),
- tester.controller()));
+ tester.controller().updateVersionStatus(censorConfigServers(VersionStatus.compute(tester.controller())));
tester.assertResponse(authenticatedRequest("http://localhost:8080/deployment/v1/"), new File("root.json"));
}
- private VersionStatus censorConfigServers(VersionStatus versionStatus, Controller controller) {
+ private VersionStatus censorConfigServers(VersionStatus versionStatus) {
List<VespaVersion> censored = new ArrayList<>();
for (VespaVersion version : versionStatus.versions()) {
if (version.nodeVersions().size() > 0) {
@@ -78,7 +79,7 @@ public class DeploymentApiTest extends ControllerContainerTest {
version.isReleased(),
NodeVersions.EMPTY.with(List.of(new NodeVersion(HostName.from("config1.test"), ZoneId.defaultId(), version.versionNumber(), version.versionNumber(), Instant.EPOCH),
new NodeVersion(HostName.from("config2.test"), ZoneId.defaultId(), version.versionNumber(), version.versionNumber(), Instant.EPOCH))),
- VespaVersion.confidenceFrom(version.statistics(), controller)
+ version.confidence()
);
}
censored.add(version);
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json
index 845fa4631b6..a3a763e9634 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json
@@ -1,14 +1,14 @@
{
- "versions":[
+ "versions": [
{
"version": "5",
"confidence": "high",
- "commit": "(ignore)",
- "date": "(ignore)",
+ "commit": "badc0ffee",
+ "date": 0,
"controllerVersion": false,
"systemVersion": false,
- "configServers": [ ],
- "failingApplications": [ ],
+ "configServers": [],
+ "failingApplications": [],
"productionApplications": [
{
"tenant": "tenant1",
@@ -20,16 +20,16 @@
"productionSuccesses": 1
}
],
- "deployingApplications": [ ]
+ "deployingApplications": []
},
{
- "version":"5.1",
- "confidence":"normal",
- "commit":"(ignore)",
- "date": "(ignore)",
- "controllerVersion":false,
- "systemVersion":true,
- "configServers":[
+ "version": "5.1",
+ "confidence": "normal",
+ "commit": "badc0ffee",
+ "date": 0,
+ "controllerVersion": true,
+ "systemVersion": true,
+ "configServers": [
{
"hostname":"config1.test"
},
@@ -37,7 +37,7 @@
"hostname":"config2.test"
}
],
- "failingApplications":[
+ "failingApplications": [
{
"tenant": "tenant1",
"application": "application1",
@@ -47,7 +47,7 @@
"failing": "staging-test"
}
],
- "productionApplications":[
+ "productionApplications": [
{
"tenant": "tenant2",
"application": "application2",
@@ -68,18 +68,7 @@
"running": "staging-test"
}
]
- },
- {
- "version": "(ignore)",
- "confidence": "normal",
- "commit": "(ignore)",
- "date": "(ignore)",
- "controllerVersion": true,
- "systemVersion": false,
- "configServers": [ ],
- "failingApplications": [ ],
- "productionApplications": [ ],
- "deployingApplications": [ ]
}
]
}
+
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/flags/AuditedFlagsApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/flags/AuditedFlagsApiTest.java
index b4ef98cc7f6..8fdfbb14c1b 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/flags/AuditedFlagsApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/flags/AuditedFlagsApiTest.java
@@ -5,7 +5,7 @@ import com.yahoo.application.container.handler.Request;
import com.yahoo.vespa.athenz.api.AthenzIdentity;
import com.yahoo.vespa.athenz.api.AthenzUser;
import com.yahoo.vespa.hosted.controller.auditlog.AuditLog;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import org.junit.Before;
import org.junit.Test;
@@ -20,12 +20,12 @@ public class AuditedFlagsApiTest extends ControllerContainerTest {
private static final String responses = "src/test/java/com/yahoo/vespa/hosted/controller/restapi/flags/responses/";
private static final AthenzIdentity operator = AthenzUser.fromUserId("operatorUser");
- private ContainerControllerTester tester;
+ private ContainerTester tester;
@Before
public void before() {
addUserToHostedOperatorRole(operator);
- tester = new ContainerControllerTester(container, responses);
+ tester = new ContainerTester(container, responses);
}
@Test
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiTest.java
index 6bc221184c1..89f11eae5ae 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiTest.java
@@ -17,7 +17,7 @@ import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock;
import com.yahoo.vespa.hosted.controller.maintenance.JobControl;
import com.yahoo.vespa.hosted.controller.maintenance.Maintainer;
import com.yahoo.vespa.hosted.controller.maintenance.OsUpgrader;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import com.yahoo.vespa.hosted.controller.versions.OsVersionStatus;
import org.intellij.lang.annotations.Language;
@@ -43,12 +43,12 @@ public class OsApiTest extends ControllerContainerTest {
private static final ZoneApi zone2 = ZoneApiMock.newBuilder().withId("prod.us-west-1").with(cloud1).build();
private static final ZoneApi zone3 = ZoneApiMock.newBuilder().withId("prod.eu-west-1").with(cloud2).build();
- private ContainerControllerTester tester;
+ private ContainerTester tester;
private List<OsUpgrader> osUpgraders;
@Before
public void before() {
- tester = new ContainerControllerTester(container, responses);
+ tester = new ContainerTester(container, responses);
addUserToHostedOperatorRole(operator);
zoneRegistryMock().setSystemName(SystemName.cd)
.setZones(zone1, zone2, zone3)
@@ -70,8 +70,6 @@ public class OsApiTest extends ControllerContainerTest {
// All nodes are initially on empty version
upgradeAndUpdateStatus();
- assertFile(new Request("http://localhost:8080/os/v1/"), "versions-initial.json");
-
// Upgrade OS to a different version in each cloud
assertResponse(new Request("http://localhost:8080/os/v1/", "{\"version\": \"7.5.2\", \"cloud\": \"cloud1\"}", Request.Method.PATCH),
"{\"message\":\"Set target OS version for cloud 'cloud1' to 7.5.2\"}", 200);
@@ -160,12 +158,11 @@ public class OsApiTest extends ControllerContainerTest {
}
private ZoneRegistryMock zoneRegistryMock() {
- return (ZoneRegistryMock) tester.containerTester().container().components()
- .getComponent(ZoneRegistryMock.class.getName());
+ return tester.serviceRegistry().zoneRegistry();
}
private NodeRepositoryMock nodeRepository() {
- return tester.containerTester().serviceRegistry().configServerMock().nodeRepository();
+ return tester.serviceRegistry().configServerMock().nodeRepository();
}
private void assertResponse(Request request, @Language("JSON") String body, int statusCode) {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v1/ZoneApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v1/ZoneApiTest.java
index 89d90fe6221..73c64b0ee5d 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v1/ZoneApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v1/ZoneApiTest.java
@@ -7,7 +7,7 @@ import com.yahoo.config.provision.zone.ZoneApi;
import com.yahoo.vespa.hosted.controller.api.role.Role;
import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock;
import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerCloudTest;
import org.junit.Before;
import org.junit.Test;
@@ -30,7 +30,7 @@ public class ZoneApiTest extends ControllerContainerCloudTest {
private static final Set<Role> everyone = Set.of(Role.everyone());
- private ContainerControllerTester tester;
+ private ContainerTester tester;
@Before
public void before() {
@@ -38,23 +38,23 @@ public class ZoneApiTest extends ControllerContainerCloudTest {
.getComponent(ZoneRegistryMock.class.getName());
zoneRegistry.setDefaultRegionForEnvironment(Environment.dev, RegionName.from("us-north-2"))
.setZones(zones);
- this.tester = new ContainerControllerTester(container, responseFiles);
+ this.tester = new ContainerTester(container, responseFiles);
}
@Test
public void test_requests() {
// GET /zone/v1
- tester.containerTester().assertResponse(request("/zone/v1")
+ tester.assertResponse(request("/zone/v1")
.roles(everyone),
new File("root.json"));
// GET /zone/v1/environment/prod
- tester.containerTester().assertResponse(request("/zone/v1/environment/prod")
+ tester.assertResponse(request("/zone/v1/environment/prod")
.roles(everyone),
new File("prod.json"));
// GET /zone/v1/environment/dev/default
- tester.containerTester().assertResponse(request("/api/zone/v1/environment/dev/default")
+ tester.assertResponse(request("/api/zone/v1/environment/dev/default")
.roles(everyone),
new File("default-for-region.json"));
}
@@ -62,7 +62,7 @@ public class ZoneApiTest extends ControllerContainerCloudTest {
@Test
public void test_invalid_requests() {
// GET /zone/v1/environment/prod/default: No default region
- tester.containerTester().assertResponse(request("/zone/v1/environment/prod/default")
+ tester.assertResponse(request("/zone/v1/environment/prod/default")
.roles(everyone),
new File("no-default-region.json"),
400);
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v2/ZoneApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v2/ZoneApiTest.java
index 40562ba493e..50b1db50c19 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v2/ZoneApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/zone/v2/ZoneApiTest.java
@@ -10,7 +10,7 @@ import com.yahoo.vespa.hosted.controller.integration.ConfigServerProxyMock;
import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock;
import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock;
import com.yahoo.vespa.hosted.controller.proxy.ProxyRequest;
-import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester;
+import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
import org.junit.Before;
import org.junit.Test;
@@ -34,7 +34,7 @@ public class ZoneApiTest extends ControllerContainerTest {
ZoneApiMock.fromId("test.us-north-3"),
ZoneApiMock.fromId("staging.us-north-4"));
- private ContainerControllerTester tester;
+ private ContainerTester tester;
private ConfigServerProxyMock proxy;
@Before
@@ -43,44 +43,44 @@ public class ZoneApiTest extends ControllerContainerTest {
.getComponent(ZoneRegistryMock.class.getName());
zoneRegistry.setDefaultRegionForEnvironment(Environment.dev, RegionName.from("us-north-2"))
.setZones(zones);
- this.tester = new ContainerControllerTester(container, responseFiles);
+ this.tester = new ContainerTester(container, responseFiles);
this.proxy = (ConfigServerProxyMock) container.components().getComponent(ConfigServerProxyMock.class.getName());
}
@Test
public void test_requests() {
// GET /zone/v2
- tester.containerTester().assertResponse(authenticatedRequest("http://localhost:8080/zone/v2"),
+ tester.assertResponse(authenticatedRequest("http://localhost:8080/zone/v2"),
new File("root.json"));
// GET /zone/v2/prod/us-north-1
- tester.containerTester().assertResponse(authenticatedRequest("http://localhost:8080/zone/v2/prod/us-north-1"),
+ tester.assertResponse(authenticatedRequest("http://localhost:8080/zone/v2/prod/us-north-1"),
"ok");
assertLastRequest(ZoneId.from("prod", "us-north-1"), 2, "GET");
// GET /zone/v2/nodes/v2/node/?recursive=true
- tester.containerTester().assertResponse(authenticatedRequest("http://localhost:8080/zone/v2/prod/us-north-1/nodes/v2/node/?recursive=true"),
+ tester.assertResponse(authenticatedRequest("http://localhost:8080/zone/v2/prod/us-north-1/nodes/v2/node/?recursive=true"),
"ok");
assertLastRequest(ZoneId.from("prod", "us-north-1"), 2, "GET");
// POST /zone/v2/dev/us-north-2/nodes/v2/command/restart?hostname=node1
- tester.containerTester().assertResponse(operatorRequest("http://localhost:8080/zone/v2/dev/aws-us-north-2/nodes/v2/command/restart?hostname=node1",
+ tester.assertResponse(operatorRequest("http://localhost:8080/zone/v2/dev/aws-us-north-2/nodes/v2/command/restart?hostname=node1",
"", Method.POST),
"ok");
// PUT /zone/v2/prod/us-north-1/nodes/v2/state/dirty/node1
- tester.containerTester().assertResponse(operatorRequest("http://localhost:8080/zone/v2/prod/us-north-1/nodes/v2/state/dirty/node1",
+ tester.assertResponse(operatorRequest("http://localhost:8080/zone/v2/prod/us-north-1/nodes/v2/state/dirty/node1",
"", Method.PUT), "ok");
assertLastRequest(ZoneId.from("prod", "us-north-1"), 2, "PUT");
// DELETE /zone/v2/prod/us-north-1/nodes/v2/node/node1
- tester.containerTester().assertResponse(operatorRequest("http://localhost:8080/zone/v2/prod/us-north-1/nodes/v2/node/node1",
+ tester.assertResponse(operatorRequest("http://localhost:8080/zone/v2/prod/us-north-1/nodes/v2/node/node1",
"", Method.DELETE), "ok");
assertLastRequest(ZoneId.from("prod", "us-north-1"), 2, "DELETE");
// PATCH /zone/v2/prod/us-north-1/nodes/v2/node/node1
- tester.containerTester().assertResponse(operatorRequest("http://localhost:8080/zone/v2/dev/aws-us-north-2/nodes/v2/node/node1",
+ tester.assertResponse(operatorRequest("http://localhost:8080/zone/v2/dev/aws-us-north-2/nodes/v2/node/node1",
"{\"currentRestartGeneration\": 1}",
Method.PATCH), "ok");
assertLastRequest(ZoneId.from("dev", "aws-us-north-2"), 1, "PATCH");
@@ -92,7 +92,7 @@ public class ZoneApiTest extends ControllerContainerTest {
@Test
public void test_invalid_requests() {
// POST /zone/v2/prod/us-north-34/nodes/v2
- tester.containerTester().assertResponse(operatorRequest("http://localhost:8080/zone/v2/prod/us-north-42/nodes/v2",
+ tester.assertResponse(operatorRequest("http://localhost:8080/zone/v2/prod/us-north-42/nodes/v2",
"", Method.POST),
new File("unknown-zone.json"), 400);
assertFalse(proxy.lastReceived().isPresent());