Search in sources :

Example 1 with SimpletypesConfig

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

the class JRTConfigRequestBase method created_from_subscription.

@Test
public void created_from_subscription() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    JRTConfigSubscription<SimpletypesConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, configId), subscriber, new ConfigSet(), new TimingValues());
    JRTClientConfigRequest request = createReq(sub, Trace.createNew(9));
    assertThat(request.getConfigKey().getName(), is(SimpletypesConfig.CONFIG_DEF_NAME));
    JRTServerConfigRequest serverRequest = createReq(request.getRequest());
    assertTrue(serverRequest.validateParameters());
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) JRTConfigSubscription(com.yahoo.config.subscription.impl.JRTConfigSubscription) ConfigSet(com.yahoo.config.subscription.ConfigSet) Test(org.junit.Test)

Example 2 with SimpletypesConfig

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

the class JRTConfigRequestBase method created_from_existing_subscription.

@Test
public void created_from_existing_subscription() {
    System.setProperty("VESPA_CONFIG_PROTOCOL_VERSION", getProtocolVersion());
    MockConnection connection = new MockConnection(new MockConnection.AbstractResponseHandler() {

        @Override
        protected void createResponse() {
            JRTServerConfigRequest serverRequest = createReq(request);
            serverRequest.addOkResponse(createPayload(), currentGeneration, configMd5);
        }
    });
    ConfigSourceSet src = new ConfigSourceSet();
    ConfigSubscriber subscriber = new GenericConfigSubscriber(Collections.singletonMap(src, JRTConfigRequester.get(connection, new TimingValues())));
    JRTConfigSubscription<SimpletypesConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, configId), subscriber, src, new TimingValues());
    sub.subscribe(120_0000);
    assertTrue(sub.nextConfig(120_0000));
    sub.close();
    JRTClientConfigRequest nextReq = createReq(sub, Trace.createNew());
    SimpletypesConfig config = sub.getConfigState().getConfig();
    assertThat(nextReq.getRequestConfigMd5(), is(config.getConfigMd5()));
    assertThat(nextReq.getRequestGeneration(), is(currentGeneration));
    System.setProperty("VESPA_CONFIG_PROTOCOL_VERSION", "");
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) GenericConfigSubscriber(com.yahoo.config.subscription.impl.GenericConfigSubscriber) MockConnection(com.yahoo.config.subscription.impl.MockConnection) TimingValues(com.yahoo.vespa.config.TimingValues) ConfigSourceSet(com.yahoo.config.subscription.ConfigSourceSet) JRTConfigSubscription(com.yahoo.config.subscription.impl.JRTConfigSubscription) Test(org.junit.Test)

Example 3 with SimpletypesConfig

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

the class ConfigBuilderMergeTest method require_that_simple_fields_are_overwritten_on_merge.

@Test
public void require_that_simple_fields_are_overwritten_on_merge() {
    SimpletypesConfig.Builder b1 = createSimpleBuilder("foo", 2, 5, 4.3, false);
    SimpletypesConfig.Builder b2 = createSimpleBuilder("bar", 3, 6, 3.3, true);
    ConfigInstanceUtil.setValues(b1, b2);
    SimpletypesConfig c1 = new SimpletypesConfig(b1);
    SimpletypesConfig c2 = new SimpletypesConfig(b2);
    assertThat(c1, is(c2));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) Test(org.junit.Test)

Example 4 with SimpletypesConfig

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

the class ConfigUtilsTest method testGetMd5OfPayload.

@Test
public void testGetMd5OfPayload() {
    String expectedMd5 = "c9246ed8c8ab55b1c463c501c84075e6";
    String expectedChangedMd5 = "f6f81062ef5f024f1912798490ba7dfc";
    ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
    System.out.println(payload);
    assertThat(ConfigUtils.getMd5(payload), is(expectedMd5));
    payload.getSlime().get().setString("fabio", "bar");
    System.out.println(payload);
    assertThat(ConfigUtils.getMd5(payload), is(expectedChangedMd5));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) Test(org.junit.Test)

Example 5 with SimpletypesConfig

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

the class JRTConfigRequesterTest method testFirstRequestAfterSubscribing.

@Test
public void testFirstRequestAfterSubscribing() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    final TimingValues timingValues = getTestTimingValues();
    JRTConfigSubscription<SimpletypesConfig> sub = createSubscription(subscriber, timingValues);
    final MockConnection connection = new MockConnection();
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    assertThat(requester.getConnectionPool(), is(connection));
    requester.request(sub);
    final Request request = connection.getRequest();
    assertNotNull(request);
    assertThat(connection.getNumberOfRequests(), is(1));
    JRTServerConfigRequestV3 receivedRequest = JRTServerConfigRequestV3.createFromRequest(request);
    assertTrue(receivedRequest.validateParameters());
    assertThat(receivedRequest.getTimeout(), is(timingValues.getSubscribeTimeout()));
    assertThat(requester.getFatalFailures(), is(0));
    assertThat(requester.getTransientFailures(), is(0));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) Request(com.yahoo.jrt.Request) JRTServerConfigRequestV3(com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3) 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