Search in sources :

Example 6 with RemoteSession

use of com.yahoo.vespa.config.server.session.RemoteSession in project vespa by vespa-engine.

the class SessionActiveHandlerTest method activateAndAssertOKPut.

private ActivateRequest activateAndAssertOKPut(long sessionId, long previousSessionId, String subPath, Clock clock) throws Exception {
    ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, subPath, clock);
    activateRequest.invoke();
    HttpResponse actResponse = activateRequest.getActResponse();
    String message = getRenderedString(actResponse);
    assertThat(message, actResponse.getStatus(), Is.is(OK));
    assertActivationMessageOK(activateRequest, message);
    RemoteSession session = activateRequest.getSession();
    assertThat(session.getStatus(), Is.is(Session.Status.ACTIVATE));
    return activateRequest;
}
Also used : RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) HttpResponse(com.yahoo.container.jdisc.HttpResponse) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 7 with RemoteSession

use of com.yahoo.vespa.config.server.session.RemoteSession in project vespa by vespa-engine.

the class TenantRequestHandlerTest method reloadConfig.

private ApplicationSet reloadConfig(long id, String application, Clock clock) {
    SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, configCurator, Tenants.getSessionsPath(tenant).append(String.valueOf(id)), new TestConfigDefinitionRepo(), "", Optional.empty());
    zkc.writeApplicationId(new ApplicationId.Builder().tenant(tenant).applicationName(application).build());
    RemoteSession session = new RemoteSession(tenant, id, componentRegistry, zkc, clock);
    return session.ensureApplicationLoaded();
}
Also used : TestConfigDefinitionRepo(com.yahoo.vespa.config.server.TestConfigDefinitionRepo) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) SessionZooKeeperClient(com.yahoo.vespa.config.server.session.SessionZooKeeperClient)

Example 8 with RemoteSession

use of com.yahoo.vespa.config.server.session.RemoteSession in project vespa by vespa-engine.

the class SessionActiveHandlerTest method testThatPreviousSessionIsDeactivated.

@Test
public void testThatPreviousSessionIsDeactivated() throws Exception {
    Clock clock = Clock.systemUTC();
    RemoteSession firstSession = activateAndAssertOK(90l, 0l, clock);
    activateAndAssertOK(91l, 90l, clock);
    assertThat(firstSession.getStatus(), Is.is(Session.Status.DEACTIVATE));
}
Also used : RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) Clock(java.time.Clock) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) SessionTest(com.yahoo.vespa.config.server.session.SessionTest) Test(org.junit.Test)

Example 9 with RemoteSession

use of com.yahoo.vespa.config.server.session.RemoteSession in project vespa by vespa-engine.

the class SessionActiveHandlerTest method activateAndAssertErrorPut.

private void activateAndAssertErrorPut(long sessionId, long previousSessionId, Clock clock, int statusCode, HttpErrorResponse.errorCodes errorCode, String expectedError) throws Exception {
    ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, "", clock);
    activateRequest.invoke();
    HttpResponse actResponse = activateRequest.getActResponse();
    RemoteSession session = activateRequest.getSession();
    assertThat(actResponse.getStatus(), Is.is(statusCode));
    String message = getRenderedString(actResponse);
    assertThat(message, Is.is("{\"error-code\":\"" + errorCode.name() + "\",\"message\":\"" + expectedError + "\"}"));
    assertThat(session.getStatus(), Is.is(Session.Status.PREPARE));
}
Also used : RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) HttpResponse(com.yahoo.container.jdisc.HttpResponse) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 10 with RemoteSession

use of com.yahoo.vespa.config.server.session.RemoteSession in project vespa by vespa-engine.

the class SessionActiveHandlerTest method createRemoteSession.

private RemoteSession createRemoteSession(long sessionId, Session.Status status, SessionZooKeeperClient zkClient, Clock clock) throws IOException {
    zkClient.writeStatus(status);
    ZooKeeperClient zkC = new ZooKeeperClient(configCurator, new BaseDeployLogger(), false, Tenants.getSessionsPath(tenant).append(String.valueOf(sessionId)));
    zkC.write(Collections.singletonMap(modelFactory.getVersion(), new MockFileRegistry()));
    zkC.write(AllocatedHosts.withHosts(Collections.emptySet()));
    RemoteSession session = new RemoteSession(TenantName.from("default"), sessionId, componentRegistry, zkClient, clock);
    remoteSessionRepo.addSession(session);
    return session;
}
Also used : ZooKeeperClient(com.yahoo.vespa.config.server.deploy.ZooKeeperClient) SessionZooKeeperClient(com.yahoo.vespa.config.server.session.SessionZooKeeperClient) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry)

Aggregations

RemoteSession (com.yahoo.vespa.config.server.session.RemoteSession)12 SessionZooKeeperClient (com.yahoo.vespa.config.server.session.SessionZooKeeperClient)5 HttpResponse (com.yahoo.container.jdisc.HttpResponse)3 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)3 Test (org.junit.Test)3 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)2 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)2 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)2 TestComponentRegistry (com.yahoo.vespa.config.server.TestComponentRegistry)2 TestConfigDefinitionRepo (com.yahoo.vespa.config.server.TestConfigDefinitionRepo)2 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)2 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)2 SessionTest (com.yahoo.vespa.config.server.session.SessionTest)2 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)2 Clock (java.time.Clock)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 SimpletypesConfig (com.yahoo.config.SimpletypesConfig)1 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 MockFileRegistry (com.yahoo.config.model.application.provider.MockFileRegistry)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1