Search in sources :

Example 6 with TimingValues

use of com.yahoo.vespa.config.TimingValues 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 TimingValues

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

the class JRTConfigRequesterTest method testFatalError.

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

Example 8 with TimingValues

use of com.yahoo.vespa.config.TimingValues 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 9 with TimingValues

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

the class JRTConfigRequesterTest method testTransientError.

@Test
public void testTransientError() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    final TimingValues timingValues = getTestTimingValues();
    final MockConnection connection = new MockConnection(new ErrorResponseHandler(com.yahoo.jrt.ErrorCode.TIMEOUT));
    JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
    requester.request(createSubscription(subscriber, timingValues));
    waitUntilResponse(connection);
    assertThat(requester.getFatalFailures(), is(0));
    assertThat(requester.getTransientFailures(), is(1));
}
Also used : ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Example 10 with TimingValues

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

the class JRTConfigRequestFactoryTest method testCreateFromSub.

@Test
public void testCreateFromSub() {
    ConfigSubscriber subscriber = new ConfigSubscriber();
    Class<FunctionTestConfig> clazz = FunctionTestConfig.class;
    final String configId = "foo";
    JRTConfigSubscription<FunctionTestConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(clazz, configId), subscriber, new ConfigSet(), new TimingValues());
    // Default vespa version
    JRTClientConfigRequest request = JRTConfigRequestFactory.createFromSub(sub);
    assertThat(request.getProtocolVersion(), is(3L));
    assertThat(request.getVespaVersion().get(), is(defaultVespaVersion));
    // Create with vespa version set
    String version = "5.37.38";
    System.setProperty(JRTConfigRequestFactory.VESPA_VERSION, version);
    request = JRTConfigRequestFactory.createFromSub(sub);
    assertThat(request.getProtocolVersion(), is(3L));
    assertThat(request.getVespaVersion().get(), is(VespaVersion.fromString(version)));
    System.clearProperty(JRTConfigRequestFactory.VESPA_VERSION);
}
Also used : FunctionTestConfig(com.yahoo.foo.FunctionTestConfig) 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)

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