use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ElapsedTimeTestCase method testTimingWithShortChain.
public void testTimingWithShortChain() {
Chain<? extends Searcher> chain = new Chain<>(new ShortChainTestingSearcher(), new NoForwardSearcher());
Execution exec = new Execution(chain, Execution.Context.createContextStub());
exec.search(new Query());
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class PeakQpsTestCase method checkSearch.
@Test
public void checkSearch() {
MeasureQpsConfig config = new MeasureQpsConfig(new MeasureQpsConfig.Builder().outputmethod(MeasureQpsConfig.Outputmethod.METAHIT).queryproperty("qpsprobe"));
Searcher s = new PeakQpsSearcher(config, Statistics.nullImplementation);
Chain<Searcher> c = new Chain<>(s);
Execution e = new Execution(c, Execution.Context.createContextStub());
e.search(new Query("/?query=a"));
new Execution(c, Execution.Context.createContextStub());
Result r = e.search(new Query("/?query=a&qpsprobe=true"));
final Hit hit = r.hits().get(0);
assertTrue(hit instanceof PeakQpsSearcher.QpsHit);
assertNotNull(hit.fields().get(PeakQpsSearcher.QpsHit.MEAN_QPS));
assertNotNull(hit.fields().get(PeakQpsSearcher.QpsHit.PEAK_QPS));
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ProcessingHandlerTestCase method testResponseDataStatusOverridesErrors.
/**
* Tests that the ResponseStatus takes precedence over errors
*/
@Test
public void testResponseDataStatusOverridesErrors() throws InterruptedException {
ProcessingTestDriver.MockResponseHandler responseHandler = null;
try {
List<Chain<Processor>> chains = new ArrayList<>();
chains.add(new Chain<Processor>("default", new ResponseStatusSetter(200), new ProcessorLibrary.StringDataAdder("Hello"), new ProcessorLibrary.ErrorAdder(new ErrorMessage(Error.FORBIDDEN.code, "Message"))));
driver = new ProcessingTestDriver(chains);
responseHandler = driver.sendRequest("http://localhost/?chain=default").awaitResponse();
Response response = responseHandler.getResponse();
assertEquals(200, response.getStatus());
} finally {
if (responseHandler != null)
responseHandler.readAll();
}
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ProcessingHandlerTestCase method testUserSpecifiedDefaultRendererIsNotReplacedInRegistry.
@Test
public void testUserSpecifiedDefaultRendererIsNotReplacedInRegistry() throws Exception {
String defaultId = AbstractProcessingHandler.DEFAULT_RENDERER_ID;
Renderer myDefaultRenderer = new ProcessingRenderer();
ComponentRegistry<Renderer> renderers = new ComponentRegistry<>();
renderers.register(ComponentId.fromString(defaultId), myDefaultRenderer);
driver = new ProcessingTestDriver(Collections.<Chain<Processor>>emptyList(), renderers);
Renderer defaultRenderer = driver.processingHandler().getRenderers().getComponent(defaultId);
assertThat(defaultRenderer, sameInstance(myDefaultRenderer));
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ProcessingHandlerTestCase method testResponseDataStatus.
@Test
public void testResponseDataStatus() throws InterruptedException {
ProcessingTestDriver.MockResponseHandler responseHandler = null;
try {
List<Chain<Processor>> chains = new ArrayList<>();
chains.add(new Chain<Processor>("default", new ResponseStatusSetter(429)));
driver = new ProcessingTestDriver(chains);
responseHandler = driver.sendRequest("http://localhost/?chain=default").awaitResponse();
Response response = responseHandler.getResponse();
assertEquals(429, response.getStatus());
assertEquals("ResponseHeaders are not rendered", "{\"datalist\":[]}", responseHandler.read());
} finally {
if (responseHandler != null)
responseHandler.readAll();
}
}
Aggregations