Search in sources :

Example 16 with SimpletypesConfig

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

the class JRTConfigRequesterTest method testClosedSubscription.

@Test
public void testClosedSubscription() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    final TimingValues timingValues = getTestTimingValues();
    JRTConfigSubscription<SimpletypesConfig> sub = createSubscription(subscriber, timingValues);
    sub.close();
    final MockConnection connection = new MockConnection(new MockConnection.OKResponseHandler());
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    requester.request(sub);
    assertThat(connection.getNumberOfRequests(), is(1));
    // Check that no further request was sent?
    try {
        Thread.sleep(timingValues.getFixedDelay() * 2);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    assertThat(connection.getNumberOfRequests(), is(1));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Example 17 with SimpletypesConfig

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

the class JRTConfigRequesterTest method testFatalErrorSubscribed.

@Test
public void testFatalErrorSubscribed() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    final TimingValues timingValues = getTestTimingValues();
    JRTConfigSubscription<SimpletypesConfig> sub = createSubscription(subscriber, timingValues);
    sub.setConfig(1L, config());
    final MockConnection connection = new MockConnection(new ErrorResponseHandler());
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    requester.request(sub);
    waitUntilResponse(connection);
    assertThat(requester.getFatalFailures(), is(1));
    assertThat(requester.getTransientFailures(), is(0));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Example 18 with SimpletypesConfig

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

the class ConfigResponseTest method require_that_slime_response_is_initialized.

@Test
public void require_that_slime_response_is_initialized() throws IOException {
    ConfigPayload configPayload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
    DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
    InnerCNode targetDef = dParser.getTree();
    ConfigResponse response = SlimeConfigResponse.fromConfigPayload(configPayload, targetDef, 3, "mymd5");
    List<String> payload = response.getLegacyPayload();
    assertNotNull(payload);
    assertThat(payload.size(), is(6));
    assertThat(payload.get(0), is("boolval false"));
    assertThat(response.getGeneration(), is(3L));
    assertThat(response.getConfigMd5(), is("mymd5"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    response.serialize(baos, CompressionType.UNCOMPRESSED);
    assertThat(baos.toString(), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) StringReader(java.io.StringReader) DefParser(com.yahoo.config.codegen.DefParser) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 19 with SimpletypesConfig

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

the class ConfigResponseTest method require_that_slime_response_decompresses_on_serialize.

@Test
public void require_that_slime_response_decompresses_on_serialize() throws IOException {
    ConfigPayload configPayload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
    DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
    InnerCNode targetDef = dParser.getTree();
    Utf8Array data = configPayload.toUtf8Array(true);
    Utf8Array bytes = new Utf8Array(new LZ4PayloadCompressor().compress(data.getBytes()));
    ConfigResponse response = new SlimeConfigResponse(bytes, targetDef, 3, "mymd5", CompressionInfo.create(CompressionType.LZ4, data.getByteLength()));
    List<String> payload = response.getLegacyPayload();
    assertNotNull(payload);
    assertThat(payload.size(), is(6));
    assertThat(payload.get(0), is("boolval false"));
    assertThat(response.getGeneration(), is(3L));
    assertThat(response.getConfigMd5(), is("mymd5"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    response.serialize(baos, CompressionType.UNCOMPRESSED);
    assertThat(baos.toString(), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) DefParser(com.yahoo.config.codegen.DefParser) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) StringReader(java.io.StringReader) LZ4PayloadCompressor(com.yahoo.vespa.config.LZ4PayloadCompressor) Utf8Array(com.yahoo.text.Utf8Array) Test(org.junit.Test)

Aggregations

SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)19 Test (org.junit.Test)19 ConfigSubscriber (com.yahoo.config.subscription.ConfigSubscriber)11 TimingValues (com.yahoo.vespa.config.TimingValues)9 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)4 FileSource (com.yahoo.config.subscription.FileSource)3 DefParser (com.yahoo.config.codegen.DefParser)2 InnerCNode (com.yahoo.config.codegen.InnerCNode)2 GenericConfigSubscriber (com.yahoo.config.subscription.impl.GenericConfigSubscriber)2 JRTConfigSubscription (com.yahoo.config.subscription.impl.JRTConfigSubscription)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 StringReader (java.io.StringReader)2 ConfigSet (com.yahoo.config.subscription.ConfigSet)1 ConfigSourceSet (com.yahoo.config.subscription.ConfigSourceSet)1 MockConnection (com.yahoo.config.subscription.impl.MockConnection)1 AppConfig (com.yahoo.foo.AppConfig)1 Request (com.yahoo.jrt.Request)1 Utf8Array (com.yahoo.text.Utf8Array)1 LZ4PayloadCompressor (com.yahoo.vespa.config.LZ4PayloadCompressor)1 JRTServerConfigRequestV3 (com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3)1