use of com.yahoo.config.subscription.ConfigSubscriber 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());
}
use of com.yahoo.config.subscription.ConfigSubscriber 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", "");
}
use of com.yahoo.config.subscription.ConfigSubscriber 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));
}
use of com.yahoo.config.subscription.ConfigSubscriber 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?
}
use of com.yahoo.config.subscription.ConfigSubscriber 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));
}
Aggregations