diff options
author | Henrik <henrik.hoiness@online.no> | 2018-07-05 13:25:59 +0200 |
---|---|---|
committer | Henrik <henrik.hoiness@online.no> | 2018-07-05 13:25:59 +0200 |
commit | 1c604359c6a432685b6edbb3e721aa9af91a518e (patch) | |
tree | 4306caf78fc7e94283738d5838f37f36e98351fd /controller-server | |
parent | 4253ef45bdb7c6f6084134ab4f0e2174eea6f40a (diff) | |
parent | 9e63438157c0659f9382324b5a83cb6a020018e1 (diff) |
Fixed merge conflict with StatusPageProxyHandler
Diffstat (limited to 'controller-server')
28 files changed, 254 insertions, 161 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/concurrent/TimeoutException.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/concurrent/TimeoutException.java deleted file mode 100644 index 260761fa6ac..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/concurrent/TimeoutException.java +++ /dev/null @@ -1,15 +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.concurrent; - -/** - * Throws on timeout - * - * @author bratseth - */ -public class TimeoutException extends RuntimeException { - - public TimeoutException(String message) { - super(message); - } - -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java index b889179750e..a046ed87a05 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterUtilizationMaintainer.java @@ -22,7 +22,7 @@ import java.util.Map; */ public class ClusterUtilizationMaintainer extends Maintainer { - Controller controller; + private final Controller controller; public ClusterUtilizationMaintainer(Controller controller, Duration duration, JobControl jobControl) { super(controller, duration, jobControl); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java index 2f1345eb49e..feec83d226e 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporter.java @@ -106,9 +106,7 @@ public class MetricsReporter extends Maintainer { node.getValue("tenant").ifPresent(tenant -> dimensions.put("tenantName", tenant)); Optional<String> application = node.getValue("application"); - if (application.isPresent()) { - dimensions.put("app",String.format("%s.%s", application.get(), node.getValue("instance").orElse("default"))); - } + application.ifPresent(app -> dimensions.put("app", String.format("%s.%s", app, node.getValue("instance").orElse("default")))); Metric.Context context = metric.createContext(dimensions); metric.set(convergeMetric, secondsSinceConverge, context); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/SystemUpgrader.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/SystemUpgrader.java index 953e95e25c8..a71ce4299b1 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/SystemUpgrader.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/SystemUpgrader.java @@ -32,12 +32,7 @@ public class SystemUpgrader extends Maintainer { @Override protected void maintain() { - Optional<Version> target = targetVersion(); - if (!target.isPresent()) { - return; - } - - deployAll(target.get(), SystemApplication.all()); + targetVersion().ifPresent(target -> deployAll(target, SystemApplication.all())); } /** Deploy a list of system applications until they converge on the given version */ @@ -69,17 +64,18 @@ public class SystemUpgrader extends Maintainer { if (convergedOn(target, application.dependencies(), zone)) { deploy(target, application, zone); } - converged &= convergedOn(target, application, zone) & application.configConvergedIn(zone, controller()); + converged &= convergedOn(target, application, zone); } return converged; } /** Deploy application on given version idempotently */ private void deploy(Version target, SystemApplication application, ZoneId zone) { - if (!wantedVersion(zone, application, target).equals(target)) { - log.info(String.format("Deploying %s version %s in %s", application.id(), target, zone)); - controller().applications().deploy(application, zone, target); + if (wantedVersion(zone, application, target).equals(target)) { + return; } + log.info(String.format("Deploying %s version %s in %s", application.id(), target, zone)); + controller().applications().deploy(application, zone, target); } private boolean convergedOn(Version target, List<SystemApplication> applications, ZoneId zone) { @@ -87,7 +83,7 @@ public class SystemUpgrader extends Maintainer { } private boolean convergedOn(Version target, SystemApplication application, ZoneId zone) { - return currentVersion(zone, application, target).equals(target); + return currentVersion(zone, application, target).equals(target) && application.configConvergedIn(zone, controller()); } private Version wantedVersion(ZoneId zone, SystemApplication application, Version defaultVersion) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java index 22cbe942932..6286f89cc9d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java @@ -117,15 +117,15 @@ public class Upgrader extends Maintainer { /** Returns the number of applications to upgrade in this run */ private int numberOfApplicationsToUpgrade() { - return Math.max(1, (int)(maintenanceInterval().getSeconds() * (upgradesPerMinute() / 60))); + return Math.max(1, (int) (maintenanceInterval().getSeconds() * (upgradesPerMinute() / 60))); } - /** Returns number upgrades per minute */ + /** Returns number of upgrades per minute */ public double upgradesPerMinute() { return curator.readUpgradesPerMinute(); } - /** Sets the number upgrades per minute */ + /** Sets the number of upgrades per minute */ public void setUpgradesPerMinute(double n) { curator.writeUpgradesPerMinute(n); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/ConfigServerRestExecutorImpl.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/ConfigServerRestExecutorImpl.java index e5e03cf5dfc..ae1102e2cef 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/ConfigServerRestExecutorImpl.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/ConfigServerRestExecutorImpl.java @@ -145,7 +145,7 @@ public class ConfigServerRestExecutorImpl implements ConfigServerRestExecutor { .setSocketTimeout((int) PROXY_REQUEST_TIMEOUT.toMillis()).build(); try ( CloseableHttpClient client = createHttpClient(config, sslContextProvider, zoneRegistry, proxyRequest); - CloseableHttpResponse response = client.execute(requestBase); + CloseableHttpResponse response = client.execute(requestBase) ) { String content = getContent(response); int status = response.getStatusLine().getStatusCode(); @@ -246,7 +246,7 @@ public class ConfigServerRestExecutorImpl implements ConfigServerRestExecutor { .setSocketTimeout(timeout).build(); try ( CloseableHttpClient client = createHttpClient(config, sslContextProvider, zoneRegistry, proxyRequest); - CloseableHttpResponse response = client.execute(httpget); + CloseableHttpResponse response = client.execute(httpget) ) { if (response.getStatusLine().getStatusCode() == 200) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/package-info.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/package-info.java index f6c300268a2..c4472fb79e4 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/package-info.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/package-info.java @@ -1,8 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.vespa.hosted.controller.proxy; - /** * @author Haakon Dybdahl */ +@ExportPackage +package com.yahoo.vespa.hosted.controller.proxy; + import com.yahoo.osgi.annotation.ExportPackage; diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 53720b04225..b8f2ccad879 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -345,13 +345,15 @@ public class ApplicationApiHandler extends LoggingRequestHandler { private void toSlime(Cursor object, Application application, HttpRequest request) { object.setString("application", application.id().application().value()); object.setString("instance", application.id().instance().value()); + // Currently deploying change if (application.change().isPresent()) { - Cursor deployingObject = object.setObject("deploying"); - application.change().platform().ifPresent(v -> deployingObject.setString("version", v.toString())); - application.change().application() - .filter(v -> v != ApplicationVersion.unknown) - .ifPresent(v -> toSlime(v, deployingObject.setObject("revision"))); + toSlime(object.setObject("deploying"), application.change()); + } + + // Outstanding change + if (application.outstandingChange().isPresent()) { + toSlime(object.setObject("outstandingChange"), application.outstandingChange()); } // Jobs sorted according to deployment spec @@ -454,6 +456,13 @@ public class ApplicationApiHandler extends LoggingRequestHandler { return new SlimeJsonResponse(slime); } + private void toSlime(Cursor object, Change change) { + change.platform().ifPresent(version -> object.setString("version", version.toString())); + change.application() + .filter(version -> !version.isUnknown()) + .ifPresent(version -> toSlime(version, object.setObject("revision"))); + } + private void toSlime(Cursor response, DeploymentId deploymentId, Deployment deployment, HttpRequest request) { Cursor serviceUrlArray = response.setArray("serviceUrls"); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/EmptyJsonResponse.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/EmptyJsonResponse.java index 3e8d4182c42..be3222cc1a8 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/EmptyJsonResponse.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/EmptyJsonResponse.java @@ -2,9 +2,7 @@ package com.yahoo.vespa.hosted.controller.restapi.application; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.slime.Slime; -import java.io.IOException; import java.io.OutputStream; /** @@ -17,7 +15,7 @@ public class EmptyJsonResponse extends HttpResponse { } @Override - public void render(OutputStream stream) throws IOException { } + public void render(OutputStream stream) {} @Override public String getContentType() { return "application/json"; } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/BlockingRequestFilter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/BlockingRequestFilter.java index 5d0a66a040e..3bd504b37d8 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/BlockingRequestFilter.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/BlockingRequestFilter.java @@ -11,6 +11,7 @@ import com.yahoo.jdisc.http.filter.SecurityRequestFilter; /** * @author bjorncs */ +@SuppressWarnings("unused") // Injected public class BlockingRequestFilter implements SecurityRequestFilter { @Override diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/statuspage/StatusPageClient.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/statuspage/StatusPageClient.java index ecb2f611171..93213172048 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/statuspage/StatusPageClient.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/statuspage/StatusPageClient.java @@ -1,6 +1,8 @@ // 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.restapi.statuspage; +import com.yahoo.slime.Slime; +import com.yahoo.vespa.config.SlimeUtils; import org.apache.http.HttpStatus; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; @@ -36,8 +38,8 @@ public class StatusPageClient { this.key = Objects.requireNonNull(key, "key cannot be null"); } - /** GET given page and return response body */ - public byte[] get(String page, Optional<String> since) { + /** GET given page and return response body as slime */ + public Slime get(String page, Optional<String> since) { HttpGet get = new HttpGet(pageUrl(page, since)); try (CloseableHttpClient client = client()) { try (CloseableHttpResponse response = client.execute(get)) { @@ -45,7 +47,8 @@ public class StatusPageClient { throw new IllegalArgumentException("Received status " + response.getStatusLine().getStatusCode() + " from StatusPage"); } - return EntityUtils.toByteArray(response.getEntity()); + byte[] body = EntityUtils.toByteArray(response.getEntity()); + return SlimeUtils.jsonToSlime(body); } } catch (IOException e) { throw new UncheckedIOException(e); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/statuspage/StatusPageProxyHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/statuspage/StatusPageProxyHandler.java index 388fe0ef69d..9021de366cb 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/statuspage/StatusPageProxyHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/statuspage/StatusPageProxyHandler.java @@ -6,13 +6,13 @@ import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; import com.yahoo.container.jdisc.secretstore.SecretStore; +import com.yahoo.slime.Slime; import com.yahoo.vespa.hosted.controller.restapi.ErrorResponse; import com.yahoo.restapi.Path; +import com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse; import com.yahoo.vespa.hosted.controller.statuspage.config.StatuspageConfig; import com.yahoo.yolean.Exceptions; -import java.io.IOException; -import java.io.OutputStream; import java.net.URI; import java.util.Optional; import java.util.logging.Level; @@ -60,28 +60,8 @@ public class StatusPageProxyHandler extends LoggingRequestHandler { } StatusPageClient client = StatusPageClient.create(apiUrl, secretStore.getSecret(secretKey)); Optional<String> since = Optional.ofNullable(request.getProperty("since")); - byte[] response = client.get(path.get("page"), since); - return new ByteArrayHttpResponse(response); - } - - private static class ByteArrayHttpResponse extends HttpResponse { - - private final byte[] data; - - public ByteArrayHttpResponse(byte[] data) { - super(200); - this.data = data; - } - - @Override - public void render(OutputStream out) throws IOException { - out.write(data); - } - - @Override - public String getContentType() { - return "application/json"; - } + Slime statusPageResponse = client.get(path.get("page"), since); + return new SlimeJsonResponse(statusPageResponse); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/TestIdentities.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/TestIdentities.java index a2fec7cfdbf..18d3e92620d 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/TestIdentities.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/TestIdentities.java @@ -12,14 +12,14 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.RegionId; */ public class TestIdentities { - public static EnvironmentId environment = new EnvironmentId("dev"); + public static final EnvironmentId environment = new EnvironmentId("dev"); - public static RegionId region = new RegionId("us-east-1"); + public static final RegionId region = new RegionId("us-east-1"); - public static InstanceId instance = new InstanceId("default"); + public static final InstanceId instance = new InstanceId("default"); - public static Property property = new Property("property"); + public static final Property property = new Property("property"); - public static NToken userNToken = new NToken("dummy"); + public static final NToken userNToken = new NToken("dummy"); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/athenz/filter/AthenzPrincipalFilterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/athenz/filter/AthenzPrincipalFilterTest.java index ee9c65013a8..301fc461b6f 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/athenz/filter/AthenzPrincipalFilterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/athenz/filter/AthenzPrincipalFilterTest.java @@ -144,7 +144,7 @@ public class AthenzPrincipalFilterTest { } private static void assertUnauthorized(ResponseHandlerMock responseHandler, String expectedMessageSubstring) { - assertNotNull(responseHandler.response);; + assertNotNull(responseHandler.response); assertEquals(UNAUTHORIZED, responseHandler.response.getStatus()); assertTrue(responseHandler.getResponseContent().contains(expectedMessageSubstring)); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/athenz/filter/NTokenValidatorTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/athenz/filter/NTokenValidatorTest.java index a70c1572c21..510c806383c 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/athenz/filter/NTokenValidatorTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/athenz/filter/NTokenValidatorTest.java @@ -13,7 +13,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import java.security.KeyPair; -import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.time.Instant; import java.util.Optional; @@ -34,7 +33,7 @@ public class NTokenValidatorTest { public ExpectedException exceptionRule = ExpectedException.none(); @Test - public void valid_token_is_accepted() throws NoSuchAlgorithmException, InvalidTokenException { + public void valid_token_is_accepted() throws InvalidTokenException { NTokenValidator validator = new NTokenValidator(createKeystore()); NToken token = createNToken(IDENTITY, Instant.now(), TRUSTED_KEY.getPrivate(), "0"); AthenzPrincipal principal = validator.validate(token); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java index a81c4adcb2e..2f9703b91e1 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java @@ -26,12 +26,13 @@ import java.util.zip.ZipOutputStream; */ public class ApplicationPackageBuilder { - private String upgradePolicy = null; - private Environment environment = Environment.prod; - private String globalServiceId = null; private final StringBuilder environmentBody = new StringBuilder(); private final StringBuilder validationOverridesBody = new StringBuilder(); private final StringBuilder blockChange = new StringBuilder(); + + private String upgradePolicy = null; + private Environment environment = Environment.prod; + private String globalServiceId = null; private String athenzIdentityAttributes = null; private String searchDefinition = "search test { }"; @@ -145,8 +146,7 @@ public class ApplicationPackageBuilder { public ApplicationPackage build() { ByteArrayOutputStream zip = new ByteArrayOutputStream(); - ZipOutputStream out = new ZipOutputStream(zip); - try { + try (ZipOutputStream out = new ZipOutputStream(zip)) { out.putNextEntry(new ZipEntry("deployment.xml")); out.write(deploymentSpec()); out.closeEntry(); @@ -158,10 +158,6 @@ public class ApplicationPackageBuilder { out.closeEntry(); } catch (IOException e) { throw new UncheckedIOException(e); - } finally { - try { - out.close(); - } catch (IOException ignored) {} } return new ApplicationPackage(zip.toByteArray()); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java index 8039f1d5cce..354f736202a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java @@ -46,8 +46,8 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer private final Map<URI, Version> versions = new HashMap<>(); private final NodeRepositoryMock nodeRepository = new NodeRepositoryMock(); private final Map<DeploymentId, ServiceConvergence> serviceStatus = new HashMap<>(); + private final Version initialVersion = new Version(6, 1, 0); - private Version initialVersion = new Version(6, 1, 0); private Version lastPrepareVersion = null; private RuntimeException prepareException = null; @@ -95,14 +95,6 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer this.prepareException = prepareException; } - /** - * Returns the (initially empty) mutable map of config server urls to versions. - * This API will return defaultVersion as response to any version(url) call for versions not added to the map. - */ - public Map<URI, Version> versions() { - return versions; - } - /** Set version for system applications in given zone */ public void setVersion(ApplicationId application, ZoneId zone, Version version) { for (Node node : nodeRepository().list(zone, application)) { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/NodeRepositoryClientMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/NodeRepositoryClientMock.java index 330127b7670..1b12b441272 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/NodeRepositoryClientMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/NodeRepositoryClientMock.java @@ -9,7 +9,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepo import com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeState; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; -import java.io.IOException; import java.util.Arrays; import java.util.Collection; @@ -17,28 +16,29 @@ import java.util.Collection; * @author bjorncs */ public class NodeRepositoryClientMock implements NodeRepositoryClientInterface { + @Override - public void addNodes(ZoneId zone, Collection<NodeRepositoryNode> nodes) throws IOException { + public void addNodes(ZoneId zone, Collection<NodeRepositoryNode> nodes) { throw new UnsupportedOperationException(); } @Override - public NodeRepositoryNode getNode(ZoneId zone, String hostname) throws IOException { + public NodeRepositoryNode getNode(ZoneId zone, String hostname) { throw new UnsupportedOperationException(); } @Override - public void deleteNode(ZoneId zone, String hostname) throws IOException { + public void deleteNode(ZoneId zone, String hostname) { throw new UnsupportedOperationException(); } @Override - public NodeList listNodes(ZoneId zone, boolean recursive) throws IOException { + public NodeList listNodes(ZoneId zone, boolean recursive) { throw new UnsupportedOperationException(); } @Override - public NodeList listNodes(ZoneId zone, String tenant, String applicationId, String instance) throws IOException { + public NodeList listNodes(ZoneId zone, String tenant, String applicationId, String instance) { NodeRepositoryNode nodeA = createNodeA(); NodeRepositoryNode nodeB = createNodeB(); return new NodeList(Arrays.asList(nodeA, nodeB)); @@ -69,57 +69,58 @@ public class NodeRepositoryClientMock implements NodeRepositoryClientInterface { } @Override - public String resetFailureInformation(ZoneId zone, String nodename) throws IOException { + public String resetFailureInformation(ZoneId zone, String nodename) { throw new UnsupportedOperationException(); } @Override - public String restart(ZoneId zone, String nodename) throws IOException { + public String restart(ZoneId zone, String nodename) { throw new UnsupportedOperationException(); } @Override - public String reboot(ZoneId zone, String nodename) throws IOException { + public String reboot(ZoneId zone, String nodename) { throw new UnsupportedOperationException(); } @Override - public String cancelReboot(ZoneId zone, String nodename) throws IOException { + public String cancelReboot(ZoneId zone, String nodename) { throw new UnsupportedOperationException(); } @Override - public String wantTo(ZoneId zone, String nodename, WantTo... actions) throws IOException { + public String wantTo(ZoneId zone, String nodename, WantTo... actions) { throw new UnsupportedOperationException(); } @Override - public String cancelRestart(ZoneId zone, String nodename) throws IOException { + public String cancelRestart(ZoneId zone, String nodename) { throw new UnsupportedOperationException(); } @Override - public String setHardwareFailureDescription(ZoneId zone, String nodename, String hardwareFailureDescription) throws IOException { + public String setHardwareFailureDescription(ZoneId zone, String nodename, String hardwareFailureDescription) { throw new UnsupportedOperationException(); } @Override - public void setState(ZoneId zone, NodeState nodeState, String nodename) throws IOException { + public void setState(ZoneId zone, NodeState nodeState, String nodename) { throw new UnsupportedOperationException(); } @Override - public String enableMaintenanceJob(ZoneId zone, String jobName) throws IOException { + public String enableMaintenanceJob(ZoneId zone, String jobName) { throw new UnsupportedOperationException(); } @Override - public String disableMaintenanceJob(ZoneId zone, String jobName) throws IOException { + public String disableMaintenanceJob(ZoneId zone, String jobName) { throw new UnsupportedOperationException(); } @Override - public MaintenanceJobList listMaintenanceJobs(ZoneId zone) throws IOException { + public MaintenanceJobList listMaintenanceJobs(ZoneId zone) { throw new UnsupportedOperationException(); } + } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java index a1aef28bd63..2b76d386fdd 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporterTest.java @@ -168,8 +168,8 @@ public class DeploymentIssueReporterTest { class MockDeploymentIssues extends LoggingDeploymentIssues { - Map<ApplicationId, IssueId> applicationIssues = new HashMap<>(); - Map<IssueId, Integer> issueLevels = new HashMap<>(); + private final Map<ApplicationId, IssueId> applicationIssues = new HashMap<>(); + private final Map<IssueId, Integer> issueLevels = new HashMap<>(); MockDeploymentIssues() { super(tester.clock()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java index 03e324cd406..fa6edd939c4 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java @@ -52,7 +52,7 @@ public class MetricsReporterTest { @Test public void test_chef_metrics() { - Clock clock = Clock.fixed(Instant.ofEpochSecond(1475497913), ZoneId.systemDefault());; + Clock clock = Clock.fixed(Instant.ofEpochSecond(1475497913), ZoneId.systemDefault()); ControllerTester tester = new ControllerTester(); MetricsReporter metricsReporter = createReporter(clock, tester.controller(), metrics, SystemName.cd); metricsReporter.maintain(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/VersionStatusSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/VersionStatusSerializerTest.java index a0cca52c192..87e145f9f93 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/VersionStatusSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/VersionStatusSerializerTest.java @@ -12,6 +12,7 @@ import org.junit.Test; import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -28,7 +29,7 @@ public class VersionStatusSerializerTest { List<VespaVersion> vespaVersions = new ArrayList<>(); DeploymentStatistics statistics = new DeploymentStatistics( Version.fromString("5.0"), - Arrays.asList(ApplicationId.from("tenant1", "failing1", "default")), + Collections.singletonList(ApplicationId.from("tenant1", "failing1", "default")), Arrays.asList(ApplicationId.from("tenant2", "success1", "default"), ApplicationId.from("tenant2", "success2", "default")), Arrays.asList(ApplicationId.from("tenant1", "failing1", "default"), 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 index 18d13e0be44..60a05e4f938 100644 --- 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 @@ -83,7 +83,7 @@ public class ContainerControllerTester { return controller().applications().createApplication(app, Optional.of(TestIdentities.userNToken)); } - public Application deploy(Application application, ApplicationPackage applicationPackage, ZoneId zone, long projectId) { + public Application deploy(Application application, ApplicationPackage applicationPackage, ZoneId zone) { controller().applications().deploy(application.id(), zone, Optional.of(applicationPackage), new DeployOptions(false, Optional.empty(), false, false)); return application; 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 53f32dbcacd..cc275b0636f 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 @@ -7,18 +7,21 @@ import com.yahoo.application.container.handler.Response; import com.yahoo.component.ComponentSpecification; import com.yahoo.component.Version; import com.yahoo.container.http.filter.FilterChainRepository; -import com.yahoo.io.IOUtils; import com.yahoo.jdisc.http.filter.SecurityRequestFilter; import com.yahoo.jdisc.http.filter.SecurityRequestFilterChain; -import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.SystemApplication; +import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; import com.yahoo.vespa.hosted.controller.versions.VersionStatus; import org.junit.ComparisonFailure; import java.io.File; import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.CharacterCodingException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Optional; import java.util.function.Supplier; import java.util.regex.Pattern; @@ -65,26 +68,31 @@ public class ContainerTester { computeVersionStatus(); } - public void assertResponse(Supplier<Request> request, File responseFile) throws IOException { + public void assertResponse(Supplier<Request> request, File responseFile) { assertResponse(request.get(), responseFile); } - public void assertResponse(Request request, File responseFile) throws IOException { + public void assertResponse(Request request, File responseFile) { assertResponse(request, responseFile, 200); } - public void assertResponse(Supplier<Request> request, File responseFile, int expectedStatusCode) throws IOException { + public void assertResponse(Supplier<Request> request, File responseFile, int expectedStatusCode) { assertResponse(request.get(), responseFile, expectedStatusCode); } - public void assertResponse(Request request, File responseFile, int expectedStatusCode) throws IOException { - String expectedResponse = IOUtils.readFile(new File(responseFilePath + responseFile.toString())); + public void assertResponse(Request request, File responseFile, int expectedStatusCode) { + String expectedResponse = readTestFile(responseFile.toString()); expectedResponse = include(expectedResponse); expectedResponse = expectedResponse.replaceAll("(\"[^\"]*\")|\\s*", "$1"); // Remove whitespace FilterResult filterResult = invokeSecurityFilters(request); request = filterResult.request; Response response = filterResult.response != null ? filterResult.response : container.handleRequest(request); - String responseString = response.getBodyAsString(); + String responseString; + try { + responseString = response.getBodyAsString(); + } catch (CharacterCodingException e) { + throw new UncheckedIOException(e); + } if (expectedResponse.contains("(ignore)")) { // Convert expected response to a literal pattern and replace any ignored field with a pattern that matches // until the first stop character @@ -141,7 +149,7 @@ public class ContainerTester { } /** Replaces @include(localFile) with the content of the file */ - private String include(String response) throws IOException { + private String include(String response) { // Please don't look at this code int includeIndex = response.indexOf("@include("); if (includeIndex < 0) return response; @@ -149,14 +157,22 @@ public class ContainerTester { String rest = response.substring(includeIndex + "@include(".length()); int filenameEnd = rest.indexOf(")"); String includeFileName = rest.substring(0, filenameEnd); - String includedContent = IOUtils.readFile(new File(responseFilePath + includeFileName)); + String includedContent = readTestFile(includeFileName); includedContent = include(includedContent); String postFix = rest.substring(filenameEnd + 1); postFix = include(postFix); return prefix + includedContent + postFix; } - static class FilterResult { + private String readTestFile(String name) { + try { + return new String(Files.readAllBytes(Paths.get(responseFilePath, name))); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + private static class FilterResult { final Request request; final Response response; @@ -165,5 +181,6 @@ public class ContainerTester { this.response = response; } } + } 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 4c37a9c3128..45513c2294f 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 @@ -18,7 +18,6 @@ import com.yahoo.vespa.athenz.api.AthenzUser; import com.yahoo.vespa.athenz.api.NToken; import com.yahoo.vespa.config.SlimeUtils; import com.yahoo.vespa.hosted.controller.Application; -import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; 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; @@ -33,6 +32,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.organization.MockOrgani import com.yahoo.vespa.hosted.controller.api.integration.organization.User; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; +import com.yahoo.vespa.hosted.controller.application.Change; import com.yahoo.vespa.hosted.controller.application.ClusterInfo; import com.yahoo.vespa.hosted.controller.application.ClusterUtilization; import com.yahoo.vespa.hosted.controller.application.Deployment; @@ -43,6 +43,7 @@ import com.yahoo.vespa.hosted.controller.athenz.mock.AthenzClientFactoryMock; import com.yahoo.vespa.hosted.controller.athenz.mock.AthenzDbMock; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.BuildJob; +import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester; import com.yahoo.vespa.hosted.controller.restapi.ContainerTester; import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest; @@ -97,6 +98,7 @@ public class ApplicationApiTest extends ControllerContainerTest { .build(); private static final AthenzDomain ATHENZ_TENANT_DOMAIN = new AthenzDomain("domain1"); + private static final AthenzDomain ATHENZ_TENANT_DOMAIN_2 = new AthenzDomain("domain2"); private static final ScrewdriverId SCREWDRIVER_ID = new ScrewdriverId("12345"); private static final UserId USER_ID = new UserId("myuser"); private static final UserId HOSTED_VESPA_OPERATOR = new UserId("johnoperator"); @@ -145,7 +147,7 @@ public class ApplicationApiTest extends ControllerContainerTest { // Add another Athens domain, so we can try to create more tenants - createAthenzDomainWithAdmin(new AthenzDomain("domain2"), USER_ID); // New domain to test tenant w/property ID + createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN_2, USER_ID); // New domain to test tenant w/property ID // Add property info for that property id, as well, in the mock organization. addPropertyData((MockOrganization) controllerTester.controller().organization(), "1234"); // POST (add) a tenant with property ID @@ -194,7 +196,7 @@ public class ApplicationApiTest extends ControllerContainerTest { ATHENZ_TENANT_DOMAIN, new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(id.application().value())); // (Necessary but not provided in this API) - // Trigger deployment from completion of component job + // Pipeline notifies about completed component job controllerTester.jobCompletion(JobType.component) .application(id) .projectId(screwdriverProjectId) @@ -203,13 +205,13 @@ public class ApplicationApiTest extends ControllerContainerTest { // ... systemtest tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/test/region/us-east-1/instance/default/", POST) - .data(createApplicationDeployData(applicationPackage, false)) + .data(createApplicationDeployData(Optional.empty(), false)) .screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json")); tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/test/region/us-east-1/instance/default", DELETE) .screwdriverIdentity(SCREWDRIVER_ID), "Deactivated tenant/tenant1/application/application1/environment/test/region/us-east-1/instance/default"); - // Called through the separate screwdriver/v1 API + controllerTester.jobCompletion(JobType.systemTest) .application(id) .projectId(screwdriverProjectId) @@ -217,7 +219,7 @@ public class ApplicationApiTest extends ControllerContainerTest { // ... staging tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/staging/region/us-east-3/instance/default/", POST) - .data(createApplicationDeployData(applicationPackage, false)) + .data(createApplicationDeployData(Optional.empty(), false)) .screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json")); tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/staging/region/us-east-3/instance/default", DELETE) @@ -230,7 +232,7 @@ public class ApplicationApiTest extends ControllerContainerTest { // ... prod zone tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/corp-us-east-1/instance/default/", POST) - .data(createApplicationDeployData(applicationPackage, false)) + .data(createApplicationDeployData(Optional.empty(), false)) .screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json")); controllerTester.jobCompletion(JobType.productionCorpUsEast1) @@ -239,6 +241,43 @@ public class ApplicationApiTest extends ControllerContainerTest { .unsuccessful() .submit(); + // POST (create) another application + ApplicationPackage applicationPackage = new ApplicationPackageBuilder() + .environment(Environment.prod) + .region("us-west-1") + .build(); + + tester.assertResponse(request("/application/v4/tenant/tenant2/application/application2", POST) + .userIdentity(USER_ID) + .nToken(N_TOKEN), + new File("application-reference-2.json")); + + ApplicationId app2 = ApplicationId.from("tenant2", "application2", "default"); + long screwdriverProjectId2 = 456; + addScrewdriverUserToDeployRole(SCREWDRIVER_ID, + ATHENZ_TENANT_DOMAIN_2, + new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(app2.application().value())); + + // Trigger upgrade and then application change + controllerTester.controller().applications().deploymentTrigger().triggerChange(app2, Change.of(Version.fromString("7.0"))); + + controllerTester.jobCompletion(JobType.component) + .application(app2) + .projectId(screwdriverProjectId2) + .uploadArtifact(applicationPackage) + .submit(); + + // GET application having both change and outstanding change + tester.assertResponse(request("/application/v4/tenant/tenant2/application/application2", GET) + .userIdentity(USER_ID), + new File("application2.json")); + + // DELETE application + tester.assertResponse(request("/application/v4/tenant/tenant2/application/application2", DELETE) + .userIdentity(USER_ID) + .nToken(N_TOKEN), + ""); + // GET tenant screwdriver projects tester.assertResponse(request("/application/v4/tenant-pipeline/", GET) .userIdentity(USER_ID), @@ -383,8 +422,6 @@ public class ApplicationApiTest extends ControllerContainerTest { tester.assertResponse(request("/application/v4/tenant/tenant1", DELETE).userIdentity(USER_ID) .nToken(N_TOKEN), new File("tenant-without-applications.json")); - - controllerTester.controller().deconstruct(); } private void addIssues(ContainerControllerTester tester, ApplicationId id) { @@ -395,7 +432,7 @@ public class ApplicationApiTest extends ControllerContainerTest { } @Test - public void testDeployDirectly() throws Exception { + public void testDeployDirectly() { // Setup ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles); ContainerTester tester = controllerTester.containerTester(); @@ -427,11 +464,10 @@ public class ApplicationApiTest extends ControllerContainerTest { new File("deploy-result.json")); } - // Tests deployment to config server when using just on API call // For now this depends on a switch in ApplicationController that does this for by- tenants in CD only @Test - public void testDeployDirectlyUsingOneCallForDeploy() throws Exception { + public void testDeployDirectlyUsingOneCallForDeploy() { // Setup ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles); ContainerTester tester = controllerTester.containerTester(); @@ -813,7 +849,7 @@ public class ApplicationApiTest extends ControllerContainerTest { } @Test - public void deployment_succeeds_when_correct_domain_is_used() throws IOException { + public void deployment_succeeds_when_correct_domain_is_used() { ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles); ContainerTester tester = controllerTester.containerTester(); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() @@ -844,7 +880,7 @@ public class ApplicationApiTest extends ControllerContainerTest { } @Test - public void testJobStatusReporting() throws Exception { + public void testJobStatusReporting() { ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles); addUserToHostedOperatorRole(HostedAthenzIdentities.from(HOSTED_VESPA_OPERATOR)); tester.containerTester().computeVersionStatus(); @@ -861,7 +897,7 @@ public class ApplicationApiTest extends ControllerContainerTest { .application(app) .projectId(projectId); job.type(JobType.component).uploadArtifact(applicationPackage).submit(); - tester.deploy(app, applicationPackage, TEST_ZONE, projectId); + tester.deploy(app, applicationPackage, TEST_ZONE); job.type(JobType.systemTest).submit(); // Notifying about unknown job fails @@ -909,9 +945,9 @@ public class ApplicationApiTest extends ControllerContainerTest { .projectId(projectId); job.type(JobType.component).uploadArtifact(applicationPackage).submit(); - tester.deploy(app, applicationPackage, TEST_ZONE, projectId); + tester.deploy(app, applicationPackage, TEST_ZONE); job.type(JobType.systemTest).submit(); - tester.deploy(app, applicationPackage, STAGING_ZONE, projectId); + tester.deploy(app, applicationPackage, STAGING_ZONE); job.type(JobType.stagingTest).error(DeploymentJobs.JobError.outOfCapacity).submit(); // Appropriate error is recorded @@ -1104,8 +1140,6 @@ public class ApplicationApiTest extends ControllerContainerTest { * 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()) { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/PathTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/PathTest.java index 2edafa96b2c..b1a3040521f 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/PathTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/PathTest.java @@ -15,12 +15,12 @@ public class PathTest { @Test public void testPath() { - assertFalse(new Path("").matches("/a/{foo}/bar/{b}"));; - assertFalse(new Path("///").matches("/a/{foo}/bar/{b}"));; - assertFalse(new Path("///foo").matches("/a/{foo}/bar/{b}"));; - assertFalse(new Path("///bar/").matches("/a/{foo}/bar/{b}"));; + assertFalse(new Path("").matches("/a/{foo}/bar/{b}")); + assertFalse(new Path("///").matches("/a/{foo}/bar/{b}")); + assertFalse(new Path("///foo").matches("/a/{foo}/bar/{b}")); + assertFalse(new Path("///bar/").matches("/a/{foo}/bar/{b}")); Path path = new Path("/a/1/bar/fuz"); - assertTrue(path.matches("/a/{foo}/bar/{b}"));; + assertTrue(path.matches("/a/{foo}/bar/{b}")); assertEquals("1", path.get("foo")); assertEquals("fuz", path.get("b")); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-reference-2.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-reference-2.json new file mode 100644 index 00000000000..a4026d6a812 --- /dev/null +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application-reference-2.json @@ -0,0 +1,5 @@ +{ + "application": "application2", + "instance": "default", + "url": "http://localhost:8080/application/v4/tenant/tenant2/application/application2" +} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application2.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application2.json new file mode 100644 index 00000000000..fa51d645cfc --- /dev/null +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/application2.json @@ -0,0 +1,78 @@ +{ + "application": "application2", + "instance": "default", + "deploying": { + "version": "(ignore)" + }, + "outstandingChange": { + "revision": { + "hash": "(ignore)", + "source": { + "gitRepository": "repository1", + "gitBranch": "master", + "gitCommit": "commit1" + } + } + }, + "deploymentJobs": [ + { + "type": "component", + "success": true, + "lastCompleted": { + "id": 42, + "version": "(ignore)", + "revision": { + "hash": "(ignore)", + "source": { + "gitRepository": "repository1", + "gitBranch": "master", + "gitCommit": "commit1" + } + }, + "reason": "Application commit", + "at": "(ignore)" + }, + "lastSuccess": { + "id": 42, + "version": "(ignore)", + "revision": { + "hash": "(ignore)", + "source": { + "gitRepository": "repository1", + "gitBranch": "master", + "gitCommit": "commit1" + } + }, + "reason": "Application commit", + "at": "(ignore)" + } + }, + { + "type": "system-test", + "success": false, + "lastTriggered": { + "id": -1, + "version": "7.0.0", + "revision": { + "hash": "1.0.42-commit1", + "source": { + "gitRepository": "repository1", + "gitBranch": "master", + "gitCommit": "commit1" + } + }, + "reason": "Testing last changes outside prod", + "at": "(ignore)" + } + } + ], + "changeBlockers": [], + "compileVersion": "6.1.0", + "globalRotations": [], + "instances": [], + "metrics": { + "queryServiceQuality": 0.0, + "writeServiceQuality": 0.0 + }, + "activity": {} +} 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 61f915f3c1e..1ed2af1f7b9 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 @@ -107,14 +107,14 @@ public class DeploymentApiTest extends ControllerContainerTest { .projectId(projectId) .uploadArtifact(applicationPackage) .submit(); - tester.deploy(application, applicationPackage, ZoneId.from(Environment.test, RegionName.from("us-east-1")), - projectId); + tester.deploy(application, applicationPackage, ZoneId.from(Environment.test, RegionName.from("us-east-1")) + ); tester.jobCompletion(JobType.systemTest) .application(application) .projectId(projectId) .submit(); - tester.deploy(application, applicationPackage, ZoneId.from(Environment.staging, RegionName.from("us-east-3")), - projectId); + tester.deploy(application, applicationPackage, ZoneId.from(Environment.staging, RegionName.from("us-east-3")) + ); tester.jobCompletion(JobType.stagingTest) .application(application) .projectId(projectId) @@ -122,7 +122,7 @@ public class DeploymentApiTest extends ControllerContainerTest { .submit(); if (success) { tester.deploy(application, applicationPackage, ZoneId.from(Environment.prod, - RegionName.from("corp-us-east-1")), projectId); + RegionName.from("corp-us-east-1"))); tester.jobCompletion(JobType.productionCorpUsEast1) .application(application) .projectId(projectId) |