Search in sources :

Example 56 with Clock

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));
}
Also used : RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) HttpResponse(com.yahoo.container.jdisc.HttpResponse) 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 57 with Clock

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);
}
Also used : 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 58 with 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));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) Clock(java.time.Clock) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 59 with Clock

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));
}
Also used : Clock(java.time.Clock) Test(org.junit.Test)

Example 60 with Clock

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());
}
Also used : MapContext(com.yahoo.vespa.hosted.controller.MetricsMock.MapContext) Clock(java.time.Clock) Map(java.util.Map) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Aggregations

Clock (java.time.Clock)209 Test (org.junit.Test)62 Instant (java.time.Instant)51 Test (org.testng.annotations.Test)43 LocalTime (java.time.LocalTime)15 ZonedDateTime (java.time.ZonedDateTime)12 LocalDateTime (java.time.LocalDateTime)11 ZoneId (java.time.ZoneId)11 LocalDate (java.time.LocalDate)10 OffsetDateTime (java.time.OffsetDateTime)8 Test (org.junit.jupiter.api.Test)7 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)6 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)6 IOException (java.io.IOException)6 SessionTest (com.yahoo.vespa.config.server.session.SessionTest)5 OffsetTime (java.time.OffsetTime)5 ZoneOffset (java.time.ZoneOffset)5 Chronology (java.time.chrono.Chronology)5 IsoChronology (java.time.chrono.IsoChronology)5 Date (java.util.Date)4