use of java.time.Clock in project vespa by vespa-engine.
the class SessionActiveHandlerTest method testActivationOfUnpreparedSession.
@Test
public void testActivationOfUnpreparedSession() throws Exception {
Clock clock = Clock.systemUTC();
// Needed so we can test that previous active session is still active after a failed activation
RemoteSession firstSession = activateAndAssertOK(90l, 0l, clock);
long sessionId = 91L;
ActivateRequest activateRequest = new ActivateRequest(sessionId, 0l, Session.Status.NEW, "", clock).invoke();
HttpResponse actResponse = activateRequest.getActResponse();
RemoteSession session = activateRequest.getSession();
assertThat(actResponse.getStatus(), is(Response.Status.BAD_REQUEST));
assertThat(getRenderedString(actResponse), is("{\"error-code\":\"BAD_REQUEST\",\"message\":\"tenant:" + tenant + " app:default:default Session " + sessionId + " is not prepared\"}"));
assertThat(session.getStatus(), is(not(Session.Status.ACTIVATE)));
assertThat(firstSession.getStatus(), is(Session.Status.ACTIVATE));
}
use of java.time.Clock in project vespa by vespa-engine.
the class SessionActiveHandlerTest method testForceActivationWithActivationInBetween.
@Test
public void testForceActivationWithActivationInBetween() throws Exception {
Clock clock = Clock.systemUTC();
activateAndAssertOK(90l, 0l, clock);
activateAndAssertOK(92l, 89l, "?force=true", clock);
}
use of java.time.Clock in project vespa by vespa-engine.
the class TenantRequestHandlerTest method testReloadConfig.
@Test
public void testReloadConfig() throws IOException, SAXException {
Clock clock = Clock.systemUTC();
ApplicationId applicationId = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build();
server.reloadConfig(reloadConfig(1, clock));
assertThat(listener.reloaded.get(), is(1));
// Using only payload list for this simple test
SimpletypesConfig config = resolve(SimpletypesConfig.class, server, "");
assertThat(config.intval(), is(1337));
assertThat(server.getApplicationGeneration(applicationId, Optional.of(vespaVersion)), is(1l));
server.reloadConfig(reloadConfig(1l, clock));
config = resolve(SimpletypesConfig.class, server, "");
assertThat(config.intval(), is(1337));
assertThat(listener.reloaded.get(), is(2));
assertThat(server.getApplicationGeneration(applicationId, Optional.of(vespaVersion)), is(1l));
assertThat(listener.tenantHosts.size(), is(1));
assertThat(server.resolveApplicationId("mytesthost"), is(applicationId));
listener.reloaded.set(0);
feedApp(app2, 2);
server.reloadConfig(reloadConfig(2l, clock));
config = resolve(SimpletypesConfig.class, server, "");
assertThat(config.intval(), is(1330));
assertThat(listener.reloaded.get(), is(1));
assertThat(server.getApplicationGeneration(applicationId, Optional.of(vespaVersion)), is(2l));
}
use of java.time.Clock in project vespa by vespa-engine.
the class RemoteSessionTest method require_that_session_is_initialized.
@Test
public void require_that_session_is_initialized() {
Clock clock = Clock.systemUTC();
Session session = createSession(2, clock);
assertThat(session.getSessionId(), is(2l));
session = createSession(Long.MAX_VALUE, clock);
assertThat(session.getSessionId(), is(Long.MAX_VALUE));
}
use of java.time.Clock in project vespa by vespa-engine.
the class MetricsReporterTest method test_chef_metrics.
@Test
public void test_chef_metrics() {
Clock clock = Clock.fixed(Instant.ofEpochSecond(1475497913), ZoneId.systemDefault());
;
ControllerTester tester = new ControllerTester();
MetricsReporter metricsReporter = createReporter(clock, tester.controller(), metrics, SystemName.cd);
metricsReporter.maintain();
assertEquals(2, metrics.getMetrics().size());
Map<MapContext, Map<String, Number>> hostMetrics = getMetricsByHost("fake-node.test");
assertEquals(1, hostMetrics.size());
Map.Entry<MapContext, Map<String, Number>> metricEntry = hostMetrics.entrySet().iterator().next();
MapContext metricContext = metricEntry.getKey();
assertDimension(metricContext, "tenantName", "ciintegrationtests");
assertDimension(metricContext, "app", "restart.default");
assertDimension(metricContext, "zone", "prod.cd-us-east-1");
assertEquals(727, metricEntry.getValue().get(MetricsReporter.convergeMetric).longValue());
}
Aggregations