diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-10-24 09:53:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-24 09:53:34 +0200 |
commit | c9edf2aab9cf43a3dbe161442d9c98415f7c6628 (patch) | |
tree | 87f4e808792d808bb64ea4dfe8815f30f264d30a | |
parent | 0de9e3aa1150edcad532a6237d7cc6d2c69d1f51 (diff) | |
parent | 89c5a8c80bda8cf8520d54be9997cf1373ea6b08 (diff) |
Merge pull request #7432 from vespa-engine/bratseth/add-new-url-to-bindingmatch-too
Bind the suspended url
5 files changed, 25 insertions, 7 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java index f05ea5eee8d..be99212c176 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java @@ -146,6 +146,7 @@ public class ApplicationHandler extends HttpHandler { "http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/content/*", "http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/filedistributionstatus", "http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/restart", + "http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/suspended", "http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/serviceconverge", "http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/serviceconverge/*", "http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/clustercontroller/*/status/*", @@ -155,7 +156,7 @@ public class ApplicationHandler extends HttpHandler { } private static boolean isIsSuspendedRequest(HttpRequest request) { - return getBindingMatch(request).groupCount() == 4 && + return getBindingMatch(request).groupCount() == 7 && request.getUri().getPath().endsWith("/suspended"); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java index 15faf267cce..94137f58a39 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java @@ -18,17 +18,16 @@ import com.yahoo.vespa.config.server.http.Utils; * in the session's application package * * @author Ulf Lilleengen - * @since 5.1 */ public class SessionContentHandler extends SessionHandler { + private final TenantRepository tenantRepository; private final ContentHandler contentHandler = new ContentHandler(); @Inject public SessionContentHandler(SessionHandler.Context ctx, ApplicationRepository applicationRepository, - TenantRepository tenantRepository) - { + TenantRepository tenantRepository) { super(ctx, applicationRepository); this.tenantRepository = tenantRepository; } @@ -53,7 +52,7 @@ public class SessionContentHandler extends SessionHandler { } private SessionContentRequestV2 getContentRequest(HttpRequest request) { - final TenantName tenantName = Utils.getTenantNameFromSessionRequest(request); + TenantName tenantName = Utils.getTenantNameFromSessionRequest(request); validateRequest(tenantName); long sessionId = getSessionIdV2(request); String contentPath = SessionContentRequestV2.getContentPath(request); diff --git a/configserver/src/main/resources/configserver-app/services.xml b/configserver/src/main/resources/configserver-app/services.xml index 511cde23e89..8521ca8b31f 100644 --- a/configserver/src/main/resources/configserver-app/services.xml +++ b/configserver/src/main/resources/configserver-app/services.xml @@ -133,6 +133,7 @@ <binding>https://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/content/*</binding> <binding>http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/filedistributionstatus</binding> <binding>https://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/filedistributionstatus</binding> + <binding>http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/suspended</binding> <binding>http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/restart</binding> <binding>https://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/restart</binding> <binding>http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*/converge</binding> diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java index 5097ed1d67c..0e2cee24b60 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java @@ -13,7 +13,6 @@ import static org.junit.Assert.*; * Base class for handler tests * * @author hmusum - * @since 5.1.14 */ public class HandlerTest { @@ -49,4 +48,5 @@ public class HandlerTest { public static void assertHttpStatusCodeAndMessage(HttpResponse response, int statusCode, String contentType, String message) throws IOException { assertHttpStatusCodeErrorCodeAndMessage(response, statusCode, null, contentType, message); } + } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java index 149b2e17bd9..2c84e2d8ad4 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java @@ -60,10 +60,12 @@ public class ApplicationHandlerTest { private final static TenantName mytenantName = TenantName.from("mytenant"); private final static TenantName foobar = TenantName.from("foobar"); private final static ApplicationId applicationId = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build(); + private TenantRepository tenantRepository; private ApplicationRepository applicationRepository; private SessionHandlerTest.MockProvisioner provisioner; private MockStateApiFactory stateApiFactory = new MockStateApiFactory(); + private OrchestratorMock orchestrator; @Before public void setup() { @@ -72,9 +74,10 @@ public class ApplicationHandlerTest { tenantRepository.addTenant(TenantBuilder.create(componentRegistry, mytenantName)); tenantRepository.addTenant(TenantBuilder.create(componentRegistry, foobar)); provisioner = new SessionHandlerTest.MockProvisioner(); + orchestrator = new OrchestratorMock(); applicationRepository = new ApplicationRepository(tenantRepository, provisioner, - new OrchestratorMock(), + orchestrator, Clock.systemUTC()); listApplicationsHandler = new ListApplicationsHandler(ListApplicationsHandler.testOnlyContext(), tenantRepository, @@ -138,6 +141,14 @@ public class ApplicationHandlerTest { } @Test + public void testSuspended() throws Exception { + applicationRepository.deploy(testApp, prepareParams(applicationId)); + assertSuspended(false, applicationId, Zone.defaultZone()); + orchestrator.suspend(applicationId); + assertSuspended(true, applicationId, Zone.defaultZone()); + } + + @Test public void testConverge() throws Exception { applicationRepository.deploy(testApp, prepareParams(applicationId)); converge(applicationId, Zone.defaultZone()); @@ -241,6 +252,12 @@ public class ApplicationHandlerTest { assertApplicationGeneration(toUrlPath(applicationId, zone, fullAppIdInUrl), expectedGeneration); } + private void assertSuspended(boolean expectedValue, ApplicationId application, Zone zone) throws IOException { + String restartUrl = toUrlPath(application, zone, true) + "/suspended"; + HttpResponse response = createApplicationHandler().handle(HttpRequest.createTestRequest(restartUrl, com.yahoo.jdisc.http.HttpRequest.Method.GET)); + HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "{\"suspended\":" + expectedValue + "}"); + } + private String toUrlPath(ApplicationId application, Zone zone, boolean fullAppIdInUrl) { String url = "http://myhost:14000/application/v2/tenant/" + application.tenant().value() + "/application/" + application.application().value(); if (fullAppIdInUrl) |