Search in sources :

Example 46 with Chain

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());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query)

Example 47 with Chain

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));
}
Also used : Chain(com.yahoo.component.chain.Chain) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 48 with Chain

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();
    }
}
Also used : Response(com.yahoo.jdisc.Response) Chain(com.yahoo.component.chain.Chain) Processor(com.yahoo.processing.Processor) ErrorMessage(com.yahoo.processing.request.ErrorMessage) Test(org.junit.Test)

Example 49 with Chain

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));
}
Also used : Chain(com.yahoo.component.chain.Chain) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) Renderer(com.yahoo.processing.rendering.Renderer) ProcessingRenderer(com.yahoo.processing.rendering.ProcessingRenderer) ProcessingRenderer(com.yahoo.processing.rendering.ProcessingRenderer) Test(org.junit.Test)

Example 50 with Chain

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();
    }
}
Also used : Response(com.yahoo.jdisc.Response) Chain(com.yahoo.component.chain.Chain) Processor(com.yahoo.processing.Processor) Test(org.junit.Test)

Aggregations

Chain (com.yahoo.component.chain.Chain)92 Execution (com.yahoo.search.searchchain.Execution)59 Searcher (com.yahoo.search.Searcher)57 Test (org.junit.Test)56 Result (com.yahoo.search.Result)48 Query (com.yahoo.search.Query)47 FeedContext (com.yahoo.feedapi.FeedContext)21 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)21 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)21 ClusterList (com.yahoo.vespaclient.ClusterList)21 Processor (com.yahoo.processing.Processor)17 Request (com.yahoo.processing.Request)10 Response (com.yahoo.processing.Response)10 ComponentId (com.yahoo.component.ComponentId)8 FederationSearcher (com.yahoo.search.federation.FederationSearcher)8 ArrayList (java.util.ArrayList)8 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)7 Message (com.yahoo.messagebus.Message)7 Hit (com.yahoo.search.result.Hit)7 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)6