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));
}
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());
}
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));
}
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));
}
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()));
}
Aggregations