use of com.yahoo.processing.Processor in project vespa by vespa-engine.
the class ProcessingTestCase method testChainedProcessing1.
/**
* Execute three simple processors doing some phony processing
*/
@Test
public void testChainedProcessing1() {
// Create a chain
Chain<Processor> chain = new Chain<>(new CombineData(), new Get6DataItems(), new DataSource());
// Execute it
Request request = new Request();
request.properties().set("appendage", 1);
Response response = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()).process(request);
// Verify the result
assertEquals(6 - 1, response.data().asList().size());
assertEquals("first.2, third.2", response.data().get(0).toString());
assertEquals("second.2", response.data().get(1).toString());
assertEquals("first.3", response.data().get(2).toString());
assertEquals("second.3", response.data().get(3).toString());
assertEquals("third.3", response.data().get(4).toString());
}
use of com.yahoo.processing.Processor in project vespa by vespa-engine.
the class ProcessingTestCase method testChainedProcessing2.
/**
* Execute the same processors in a different order
*/
@Test
public void testChainedProcessing2() {
// Create a chain
Chain<Processor> chain = new Chain<>(new Get6DataItems(), new CombineData(), new DataSource());
// Execute it
Request request = new Request();
request.properties().set("appendage", 1);
Response response = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()).process(request);
// Check the result
assertEquals(6, response.data().asList().size());
assertEquals("first.2, third.2", response.data().get(0).toString());
assertEquals("second.2", response.data().get(1).toString());
assertEquals("first.4, third.4", response.data().get(2).toString());
assertEquals("second.4", response.data().get(3).toString());
assertEquals("first.6, third.6", response.data().get(4).toString());
assertEquals("second.6", response.data().get(5).toString());
}
use of com.yahoo.processing.Processor in project vespa by vespa-engine.
the class AsyncExecutionTestCase method testAsyncExecution.
/**
* Execute a processing chain which forks off into multiple threads
*/
@Test
public void testAsyncExecution() {
// Create a chain
Chain<Processor> chain = new Chain<>(new CombineData(), new BlockingSplitter(2), new Get6DataItems(), new DataSource());
// Execute it
Request request = new Request();
request.properties().set("appendage", 1);
Response response = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()).process(request);
// Verify the result
assertEquals(6 * 2 - 1, response.data().asList().size());
assertEquals("first.2, third.2", response.data().get(0).toString());
assertEquals("second.2", response.data().get(1).toString());
assertEquals("first.3", response.data().get(2).toString());
assertEquals("second.3", response.data().get(3).toString());
assertEquals("third.3", response.data().get(4).toString());
// from the parallel execution
assertEquals("first.2", response.data().get(5).toString());
assertEquals("second.2", response.data().get(6).toString());
assertEquals("third.2", response.data().get(7).toString());
assertEquals("first.3", response.data().get(8).toString());
assertEquals("second.3", response.data().get(9).toString());
assertEquals("third.3", response.data().get(10).toString());
}
use of com.yahoo.processing.Processor 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.processing.Processor 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