summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authortoby <smorgrav@yahoo-inc.com>2019-02-01 16:21:01 +0100
committertoby <smorgrav@yahoo-inc.com>2019-02-01 16:21:01 +0100
commitb22d9c6123ecc4c8f12236f735dab5f743db7c17 (patch)
treef350726f5a061d565df59ff438ad249ef263b249 /controller-server
parentc30bb0c6513d3f8ef741226cb2027de1c29cbbbf (diff)
Add unit tests
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java13
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deploy-no-deployment.json1
3 files changed, 17 insertions, 1 deletions
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 c99114e3ce2..580d12ea010 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
@@ -875,7 +875,9 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
boolean isZoneApplication = SystemApplication.zone.id().equals(applicationId);
if (isZoneApplication) {
// Make it explicit that version is not yet supported here
- if (deployOptions.field("vespaVersion").valid()) {
+ String versionStr = deployOptions.field("vespaVersion").asString();
+ boolean versionPresent = !versionStr.isEmpty() && !versionStr.equals("null");
+ if (versionPresent) {
throw new RuntimeException("Version not supported for system applications");
}
Version version = wantedSystemVersion(zone, SystemApplication.zone);
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 cd804e2ebfb..7697cf00b86 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
@@ -668,6 +668,19 @@ public class ApplicationApiTest extends ControllerContainerTest {
.data(entity)
.screwdriverIdentity(SCREWDRIVER_ID),
new File("deploy-result.json"));
+
+ // POST (deploy) a system application with an application package
+ HttpEntity noAppEntity = createApplicationDeployData(Optional.empty(), true);
+ tester.assertResponse(request("/application/v4/tenant/hosted-vespa/application/routing/environment/prod/region/us-central-1/instance/default/deploy", POST)
+ .data(noAppEntity)
+ .userIdentity(USER_ID),
+ new File("deploy-result.json"));
+
+ // POST (deploy) a system application without an application package
+ tester.assertResponse(request("/application/v4/tenant/hosted-vespa/application/proxy-host/environment/prod/region/us-central-1/instance/default/deploy", POST)
+ .data(noAppEntity)
+ .userIdentity(USER_ID),
+ new File("deploy-no-deployment.json"), 400);
}
// Tests deployment to config server when using just on API call
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deploy-no-deployment.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deploy-no-deployment.json
new file mode 100644
index 00000000000..f90420f28d7
--- /dev/null
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deploy-no-deployment.json
@@ -0,0 +1 @@
+{"error-code":"BAD_REQUEST","message":"Can't redeploy application, no deployment currently exist"} \ No newline at end of file