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;
}
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();
}
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));
}
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));
}
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;
}
Aggregations