Search in sources :

Example 6 with SimpletypesConfig

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

the class RpcServerTest method testGetConfig.

public void testGetConfig() {
    ((MockRequestHandler) tenantProvider.getRequestHandler()).throwException = false;
    ConfigKey<?> key = new ConfigKey<>(SimpletypesConfig.class, "brim");
    ((MockRequestHandler) tenantProvider.getRequestHandler()).responses.put(ApplicationId.defaultId(), createResponse());
    JRTClientConfigRequest req = JRTClientConfigRequestV3.createFromRaw(new RawConfig(key, SimpletypesConfig.CONFIG_DEF_MD5), 120_000, Trace.createDummy(), CompressionType.UNCOMPRESSED, Optional.empty());
    assertTrue(req.validateParameters());
    performRequest(req.getRequest());
    assertThat(req.errorCode(), is(0));
    assertTrue(req.validateResponse());
    ConfigPayload payload = ConfigPayload.fromUtf8Array(req.getNewPayload().getData());
    assertNotNull(payload);
    SimpletypesConfig.Builder builder = new SimpletypesConfig.Builder();
    new ConfigPayloadApplier<>(builder).applyPayload(payload);
    SimpletypesConfig config = new SimpletypesConfig(builder);
    assertThat(config.intval(), is(123));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig)

Example 7 with SimpletypesConfig

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

the class RpcServerTest method createResponse.

public ConfigResponse createResponse() {
    SimpletypesConfig.Builder builder = new SimpletypesConfig.Builder();
    builder.intval(123);
    SimpletypesConfig responseConfig = new SimpletypesConfig(builder);
    ConfigPayload responsePayload = ConfigPayload.fromInstance(responseConfig);
    InnerCNode targetDef = new DefParser(SimpletypesConfig.CONFIG_DEF_NAME, new StringReader(Joiner.on("\n").join(SimpletypesConfig.CONFIG_DEF_SCHEMA))).getTree();
    return SlimeConfigResponse.fromConfigPayload(responsePayload, targetDef, 3l, ConfigUtils.getMd5(responsePayload));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) StringReader(java.io.StringReader) DefParser(com.yahoo.config.codegen.DefParser)

Example 8 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(new ApplicationId.Builder().tenant(tenant).applicationName("myapplication").build(), 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(EXPECTED_RENDERED_STRING));
}
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) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) Test(org.junit.Test) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest)

Example 9 with SimpletypesConfig

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

the class HttpGetConfigHandlerTest method require_that_handler_can_handle_long_appid_request_with_configid.

@Test
public void require_that_handler_can_handle_long_appid_request_with_configid() throws IOException {
    String uriLongAppId = "http://yahoo.com:8080/config/v2/tenant/" + tenant.value() + "/application/myapplication/environment/staging/region/myregion/instance/myinstance/foo.bar/myid";
    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").instanceName("myinstance").build(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
    HttpResponse response = handler.handle(HttpRequest.createTestRequest(uriLongAppId, 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) ApplicationId(com.yahoo.config.provision.ApplicationId) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) Test(org.junit.Test) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest)

Example 10 with SimpletypesConfig

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

the class HttpConfigResponseTest method require_that_response_is_created_from_config.

@Test
public void require_that_response_is_created_from_config() throws IOException {
    final long generation = 1L;
    ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
    // TODO: Hope to be able to remove this mess soon.
    DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
    InnerCNode targetDef = dParser.getTree();
    ConfigResponse configResponse = SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5");
    HttpConfigResponse response = HttpConfigResponse.createFromConfig(configResponse);
    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) StringReader(java.io.StringReader) SlimeConfigResponse(com.yahoo.vespa.config.protocol.SlimeConfigResponse) ConfigResponse(com.yahoo.vespa.config.protocol.ConfigResponse) DefParser(com.yahoo.config.codegen.DefParser) 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