Search in sources :

Example 1 with SimpletypesConfig

use of com.yahoo.config.SimpletypesConfig in project vespa by vespa-engine.

the class HttpGetConfigHandlerTest method require_that_handler_can_be_created.

@Test
public void require_that_handler_can_be_created() throws IOException {
    // Define config response for mock handler
    final long generation = 1L;
    ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
    InnerCNode targetDef = getInnerCNode();
    mockRequestHandler.responses.put(new ApplicationId.Builder().tenant(tenant).applicationName("myapplication").build(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
    HttpResponse response = handler.handle(HttpRequest.createTestRequest(configUri, GET));
    assertThat(SessionHandlerTest.getRenderedString(response), is(EXPECTED_RENDERED_STRING));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) HttpResponse(com.yahoo.container.jdisc.HttpResponse) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) Test(org.junit.Test) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest)

Example 2 with SimpletypesConfig

use of com.yahoo.config.SimpletypesConfig in project vespa by vespa-engine.

the class HttpGetConfigHandlerTest method require_that_handler_can_be_created.

@Test
public void require_that_handler_can_be_created() throws IOException {
    // Define config response for mock handler
    final long generation = 1L;
    ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
    InnerCNode targetDef = getInnerCNode();
    mockRequestHandler.responses.put(ApplicationId.defaultId(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
    HttpResponse response = handler.handle(HttpRequest.createTestRequest(configUri, GET));
    assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) HttpResponse(com.yahoo.container.jdisc.HttpResponse) Test(org.junit.Test)

Example 3 with SimpletypesConfig

use of com.yahoo.config.SimpletypesConfig in project vespa by vespa-engine.

the class HttpGetConfigHandlerTest method require_that_nocache_property_works.

@Test
public void require_that_nocache_property_works() throws IOException {
    long generation = 1L;
    ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
    InnerCNode targetDef = getInnerCNode();
    mockRequestHandler.responses.put(ApplicationId.defaultId(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
    final HttpRequest request = HttpRequest.createTestRequest(configUri, GET, null, Collections.singletonMap("nocache", "true"));
    HttpResponse response = handler.handle(request);
    assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
Also used : HttpRequest(com.yahoo.container.jdisc.HttpRequest) SimpletypesConfig(com.yahoo.config.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) HttpResponse(com.yahoo.container.jdisc.HttpResponse) Test(org.junit.Test)

Example 4 with SimpletypesConfig

use of com.yahoo.config.SimpletypesConfig 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 5 with SimpletypesConfig

use of com.yahoo.config.SimpletypesConfig in project vespa by vespa-engine.

the class TenantRequestHandlerTest method testResolveMultipleVersions.

@Test
public void testResolveMultipleVersions() throws IOException {
    ApplicationId appId = new ApplicationId.Builder().tenant(tenant).applicationName("myapp1").instanceName("myinst1").build();
    feedAndReloadApp(app1, 1, appId);
    SimpletypesConfig config = resolve(SimpletypesConfig.class, server, appId, vespaVersion, "");
    assertThat(config.intval(), is(1337));
    config = resolve(SimpletypesConfig.class, server, appId, Version.fromIntValues(3, 2, 1), "");
    assertThat(config.intval(), is(1337));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Aggregations

SimpletypesConfig (com.yahoo.config.SimpletypesConfig)12 Test (org.junit.Test)10 InnerCNode (com.yahoo.config.codegen.InnerCNode)7 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)6 ApplicationId (com.yahoo.config.provision.ApplicationId)5 HttpResponse (com.yahoo.container.jdisc.HttpResponse)5 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)3 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)3 DefParser (com.yahoo.config.codegen.DefParser)2 HttpRequest (com.yahoo.container.jdisc.HttpRequest)2 StringReader (java.io.StringReader)2 ConfigResponse (com.yahoo.vespa.config.protocol.ConfigResponse)1 SlimeConfigResponse (com.yahoo.vespa.config.protocol.SlimeConfigResponse)1 TestConfigDefinitionRepo (com.yahoo.vespa.config.server.TestConfigDefinitionRepo)1 RemoteSession (com.yahoo.vespa.config.server.session.RemoteSession)1 SessionZooKeeperClient (com.yahoo.vespa.config.server.session.SessionZooKeeperClient)1 Clock (java.time.Clock)1