Search in sources :

Example 11 with TimingValues

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

the class FileConfigSubscriptionTest method require_that_dir_config_id_reference_is_not_changed.

@Test
public void require_that_dir_config_id_reference_is_not_changed() {
    final String cfgDir = "src/test/resources/configs/foo";
    final String cfgId = "dir:" + cfgDir;
    final ConfigKey<TestReferenceConfig> key = new ConfigKey<>(TestReferenceConfig.class, cfgId);
    ConfigSubscriber subscriber = new ConfigSubscriber();
    ConfigSubscription<TestReferenceConfig> sub = ConfigSubscription.get(key, subscriber, new DirSource(new File(cfgDir)), new TimingValues());
    assertTrue(sub.nextConfig(1000));
    assertThat(sub.getConfigState().getConfig().configId(), is(cfgId));
}
Also used : TestReferenceConfig(com.yahoo.foo.TestReferenceConfig) ConfigKey(com.yahoo.vespa.config.ConfigKey) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) DirSource(com.yahoo.config.subscription.DirSource) File(java.io.File) Test(org.junit.Test)

Example 12 with TimingValues

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

the class ConfigSetSubscriptionTest method testUnknownKey.

@Test(expected = IllegalArgumentException.class)
public void testUnknownKey() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    ConfigSet configSet = new ConfigSet();
    AppConfig.Builder a0builder = new AppConfig.Builder().message("A message, 0").times(88);
    configSet.addBuilder("app/0", a0builder);
    ConfigSubscription.get(new ConfigKey<>(SimpletypesConfig.class, "simpletypes/1"), subscriber, configSet, new TimingValues());
}
Also used : AppConfig(com.yahoo.foo.AppConfig) SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Example 13 with TimingValues

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

the class ConfigSubscriptionTest method testEquals.

@Test
public void testEquals() {
    ConfigSubscriber sub = new ConfigSubscriber();
    final String payload = "boolval true";
    ConfigSubscription<SimpletypesConfig> a = ConfigSubscription.get(new ConfigKey<>(SimpletypesConfig.class, "test"), sub, new RawSource(payload), new TimingValues());
    ConfigSubscription<SimpletypesConfig> b = ConfigSubscription.get(new ConfigKey<>(SimpletypesConfig.class, "test"), sub, new RawSource(payload), new TimingValues());
    ConfigSubscription<SimpletypesConfig> c = ConfigSubscription.get(new ConfigKey<>(SimpletypesConfig.class, "test2"), sub, new RawSource(payload), new TimingValues());
    assertEquals(b, a);
    assertEquals(a, a);
    assertEquals(b, b);
    assertEquals(c, c);
    assertNotEquals(c, a);
    assertNotEquals(c, b);
    ConfigSubscriber subscriber = new ConfigSubscriber();
    ConfigSet configSet = new ConfigSet();
    AppConfig.Builder a0builder = new AppConfig.Builder().message("A message, 0").times(88);
    configSet.addBuilder("app/0", a0builder);
    AppConfig.Builder a1builder = new AppConfig.Builder().message("A message, 1").times(89);
    configSet.addBuilder("app/1", a1builder);
    ConfigSubscription<AppConfig> c1 = ConfigSubscription.get(new ConfigKey<>(AppConfig.class, "app/0"), subscriber, configSet, new TimingValues());
    ConfigSubscription<AppConfig> c2 = ConfigSubscription.get(new ConfigKey<>(AppConfig.class, "app/1"), subscriber, configSet, new TimingValues());
    assertTrue(c1.equals(c1));
    assertFalse(c1.equals(c2));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) AppConfig(com.yahoo.foo.AppConfig) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Example 14 with TimingValues

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

the class JRTConfigRequesterTest method testTransientErrorSubscribed.

@Test
public void testTransientErrorSubscribed() {
    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(com.yahoo.jrt.ErrorCode.TIMEOUT));
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    requester.request(sub);
    waitUntilResponse(connection);
    assertThat(requester.getFatalFailures(), is(0));
    assertThat(requester.getTransientFailures(), 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 15 with TimingValues

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

the class JRTConfigRequesterTest method testDelay.

@Test
public void testDelay() {
    TimingValues timingValues = new TimingValues();
    // transientFailures and fatalFailures are not set until after delay has been calculated,
    // so 0 is the case for the first failure
    int transientFailures = 0;
    int fatalFailures = 0;
    // First time failure, configured
    long delay = JRTConfigRequester.calculateFailedRequestDelay(ErrorType.TRANSIENT, transientFailures, fatalFailures, timingValues, true);
    assertThat(delay, is(timingValues.getConfiguredErrorDelay()));
    assertThat(delay, is((transientFailures + 1) * timingValues.getConfiguredErrorDelay()));
}
Also used : TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Aggregations

TimingValues (com.yahoo.vespa.config.TimingValues)17 Test (org.junit.Test)17 ConfigSubscriber (com.yahoo.config.subscription.ConfigSubscriber)12 SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)10 JRTConfigSubscription (com.yahoo.config.subscription.impl.JRTConfigSubscription)3 AppConfig (com.yahoo.foo.AppConfig)3 ConfigSet (com.yahoo.config.subscription.ConfigSet)2 GenericConfigSubscriber (com.yahoo.config.subscription.impl.GenericConfigSubscriber)2 ConfigSourceSet (com.yahoo.config.subscription.ConfigSourceSet)1 DirSource (com.yahoo.config.subscription.DirSource)1 MockConnection (com.yahoo.config.subscription.impl.MockConnection)1 FunctionTestConfig (com.yahoo.foo.FunctionTestConfig)1 TestReferenceConfig (com.yahoo.foo.TestReferenceConfig)1 Request (com.yahoo.jrt.Request)1 ConfigKey (com.yahoo.vespa.config.ConfigKey)1 JRTServerConfigRequestV3 (com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3)1 File (java.io.File)1 Random (java.util.Random)1