Search in sources :

Example 6 with SimpletypesConfig

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

the class JRTConfigRequesterTest method testUnknownConfigDefinitionError.

@Test
public void testUnknownConfigDefinitionError() {
    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(ErrorCode.UNKNOWN_DEFINITION));
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    assertThat(requester.getConnectionPool(), is(connection));
    requester.request(sub);
    waitUntilResponse(connection);
    assertThat(requester.getFatalFailures(), is(1));
    assertThat(requester.getTransientFailures(), is(0));
// TODO Check that no further request was sent?
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Example 7 with SimpletypesConfig

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

the class JRTConfigRequesterTest method testTimeout.

@Test
public void testTimeout() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    final TimingValues timingValues = getTestTimingValues();
    JRTConfigSubscription<SimpletypesConfig> sub = createSubscription(subscriber, timingValues);
    sub.close();
    final MockConnection connection = new MockConnection(new DelayedResponseHandler(timingValues.getSubscribeTimeout()), // fake that we have more than one source
    2);
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    requester.request(createSubscription(subscriber, timingValues));
    // Check that no further request was sent?
    try {
        Thread.sleep(timingValues.getFixedDelay() * 2);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    assertTrue(connection.getNumberOfFailovers() >= 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 8 with SimpletypesConfig

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

the class FileConfigSubscriptionTest method require_that_bad_file_throws_exception.

@Test(expected = IllegalArgumentException.class)
public void require_that_bad_file_throws_exception() throws IOException {
    // A little trick to ensure that we can create the subscriber, but that we get an error when reading.
    writeConfig("intval", "23");
    ConfigSubscriber subscriber = new ConfigSubscriber(new FileSource(TEST_TYPES_FILE));
    ConfigSubscription<SimpletypesConfig> sub = new FileConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, ""), subscriber, TEST_TYPES_FILE);
    sub.reload(1);
    // delete file so the below statement throws exception
    Files.delete(TEST_TYPES_FILE.toPath());
    sub.nextConfig(0);
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) FileSource(com.yahoo.config.subscription.FileSource) Test(org.junit.Test)

Example 9 with SimpletypesConfig

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

the class FileConfigSubscriptionTest method require_that_new_config_is_detected_on_reload.

@Test
public void require_that_new_config_is_detected_on_reload() throws IOException {
    writeConfig("intval", "23");
    ConfigSubscriber subscriber = new ConfigSubscriber(new FileSource(TEST_TYPES_FILE));
    ConfigSubscription<SimpletypesConfig> sub = new FileConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, ""), subscriber, TEST_TYPES_FILE);
    assertTrue(sub.nextConfig(1000));
    assertThat(sub.getConfigState().getConfig().intval(), is(23));
    writeConfig("intval", "33");
    sub.reload(1);
    assertTrue(sub.nextConfig(1000));
    ConfigSubscription.ConfigState<SimpletypesConfig> configState = sub.getConfigState();
    assertThat(configState.getConfig().intval(), is(33));
    assertTrue(configState.isConfigChanged());
    assertTrue(configState.isGenerationChanged());
    assertTrue(sub.isConfigChangedAndReset(7L));
    assertSame(configState, sub.getConfigState());
    assertTrue(configState.isConfigChanged());
    assertTrue(configState.isGenerationChanged());
    assertTrue(sub.isConfigChangedAndReset(1L));
    assertNotSame(configState, sub.getConfigState());
    configState = sub.getConfigState();
    assertFalse(configState.isConfigChanged());
    assertFalse(configState.isGenerationChanged());
    sub.reload(2);
    assertTrue(sub.nextConfig(1000));
    configState = sub.getConfigState();
    assertThat(configState.getConfig().intval(), is(33));
    assertFalse(configState.isConfigChanged());
    assertTrue(configState.isGenerationChanged());
    assertFalse(sub.isConfigChangedAndReset(2L));
    assertNotSame(configState, sub.getConfigState());
    configState = sub.getConfigState();
    assertFalse(configState.isConfigChanged());
    assertFalse(configState.isGenerationChanged());
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) FileSource(com.yahoo.config.subscription.FileSource) Test(org.junit.Test)

Example 10 with SimpletypesConfig

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

the class FileConfigSubscriptionTest method require_that_new_config_is_detected_in_time.

@Test
public void require_that_new_config_is_detected_in_time() throws IOException, InterruptedException {
    writeConfig("intval", "23");
    ConfigSubscriber subscriber = new ConfigSubscriber(new FileSource(TEST_TYPES_FILE));
    ConfigSubscription<SimpletypesConfig> sub = new FileConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, ""), subscriber, TEST_TYPES_FILE);
    assertTrue(sub.nextConfig(1000));
    assertThat(sub.getConfigState().getConfig().intval(), is(23));
    Thread.sleep(1000);
    writeConfig("intval", "33");
    assertTrue(sub.nextConfig(1000));
    assertThat(sub.getConfigState().getConfig().intval(), is(33));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) FileSource(com.yahoo.config.subscription.FileSource) 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