diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-06-01 11:43:13 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2020-06-01 11:43:13 +0200 |
commit | f9d72e54b506f2ab81e9c8805a6461964bf04b86 (patch) | |
tree | 5b571330c745270e19e068b3f361b6c27ce78db3 /configserver | |
parent | 79f45ceceb9d861a5d8f070c5dabc1fa1bd93af5 (diff) |
Move and collapse two tests into one
Diffstat (limited to 'configserver')
2 files changed, 22 insertions, 26 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index c4de563e068..900e0e8d8a5 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -4,6 +4,7 @@ package com.yahoo.vespa.config.server; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.model.api.ApplicationRoles; +import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; @@ -483,6 +484,27 @@ public class ApplicationRepositoryTest { assertEquals(Session.Status.ACTIVATE, activeSession.getStatus()); } + @Test + public void testActivationofSessionCreatedFromNoLongerActiveSessionFails() { + TimeoutBudget timeoutBudget = new TimeoutBudget(clock, Duration.ofSeconds(10)); + + PrepareResult result1 = deployApp(testAppJdiscOnly); + result1.sessionId(); + + long sessionId2 = applicationRepository.createSessionFromExisting(applicationId(), + new BaseDeployLogger(), + false, + timeoutBudget); + // Deploy and activate another session + PrepareResult result2 = deployApp(testAppJdiscOnly); + result2.sessionId(); + + applicationRepository.prepare(tenantRepository.getTenant(tenant1), sessionId2, prepareParams(), clock.instant()); + exceptionRule.expect(ActivationConflictException.class); + exceptionRule.expectMessage(containsString("tenant:test1 app:testapp:default Cannot activate session 3 because the currently active session (4) has changed since session 3 was created (was 2 at creation time)")); + applicationRepository.activate(tenantRepository.getTenant(tenant1), sessionId2, timeoutBudget, false); + } + private ApplicationRepository createApplicationRepository() { return new ApplicationRepository(tenantRepository, provisioner, diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java index 3495786321e..175f0337d41 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java @@ -14,7 +14,6 @@ import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.jdisc.Response; import com.yahoo.jdisc.http.HttpRequest; import com.yahoo.slime.JsonFormat; import com.yahoo.vespa.config.server.ApplicationRepository; @@ -57,7 +56,6 @@ import java.util.Optional; import java.util.Set; import static com.yahoo.jdisc.Response.Status.BAD_REQUEST; -import static com.yahoo.jdisc.Response.Status.CONFLICT; import static com.yahoo.jdisc.Response.Status.METHOD_NOT_ALLOWED; import static com.yahoo.jdisc.Response.Status.NOT_FOUND; import static com.yahoo.jdisc.Response.Status.OK; @@ -131,22 +129,6 @@ public class SessionActiveHandlerTest { } @Test - public void require_that_session_created_from_active_that_is_no_longer_active_cannot_be_activated() throws Exception { - long sessionId = 1; - activateAndAssertOK(1, 0); - sessionId++; - activateAndAssertOK(sessionId, 1); - - sessionId++; - ActivateRequest activateRequest = new ActivateRequest(sessionId, 1, "").invoke(); - HttpResponse actResponse = activateRequest.getActResponse(); - String message = getRenderedString(actResponse); - assertThat(message, actResponse.getStatus(), Is.is(CONFLICT)); - assertThat(message, - containsString("Cannot activate session 3 because the currently active session (2) has changed since session 3 was created (was 1 at creation time)")); - } - - @Test public void testAlreadyActivatedSession() throws Exception { activateAndAssertOK(1, 0); HttpResponse response = handler.handle(createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.ACTIVE, 1L)); @@ -161,14 +143,6 @@ public class SessionActiveHandlerTest { } @Test - public void testActivationWithActivationInBetween() throws Exception { - activateAndAssertOK(90, 0); - activateAndAssertError(92, 89, - Response.Status.CONFLICT, HttpErrorResponse.errorCodes.ACTIVATION_CONFLICT, - "tenant:" + tenantName + " app:default:default Cannot activate session 92 because the currently active session (90) has changed since session 92 was created (was 89 at creation time)"); - } - - @Test public void require_that_handler_gives_error_for_unsupported_methods() throws Exception { testUnsupportedMethod(createTestRequest(pathPrefix, HttpRequest.Method.POST, Cmd.PREPARED, 1L)); testUnsupportedMethod(createTestRequest(pathPrefix, HttpRequest.Method.DELETE, Cmd.PREPARED, 1L)); |