use of com.oath.cyclops.async.adapters.Queue in project bender by Nextdoor.
the class ForkOperationTest method testNullOpFork.
@Test
public void testNullOpFork() {
/*
* Setup the pipeline of operation processors
*/
List<List<OperationProcessor>> forks = new ArrayList<List<OperationProcessor>>();
List<OperationProcessor> fork1 = new ArrayList<OperationProcessor>();
DummyNullOperation nullOp = new DummyNullOperation();
fork1.add(new OperationProcessor(new DummyOperationFactory(nullOp)));
forks.add(fork1);
ForkOperation op = new ForkOperation(forks);
/*
* Create thread that supplies input events
*/
Queue<InternalEvent> inputQueue = new Queue<InternalEvent>();
supply(10, inputQueue);
/*
* Process
*/
Stream<InternalEvent> input = inputQueue.stream();
Stream<InternalEvent> output = op.getOutputStream(input);
List<String> actual = output.map(InternalEvent::getEventString).collect(Collectors.toList());
assertEquals(0, actual.size());
}
use of com.oath.cyclops.async.adapters.Queue in project bender by Nextdoor.
the class ForkOperationTest method testForkMonitoringParallel.
@Test
public void testForkMonitoringParallel() {
/*
* Setup the pipeline of operation processors
*/
List<List<OperationProcessor>> forks = new ArrayList<List<OperationProcessor>>();
List<OperationProcessor> fork1 = new ArrayList<OperationProcessor>();
fork1.add(new OperationProcessor(new DummyOperationFactory()));
forks.add(fork1);
List<OperationProcessor> fork2 = new ArrayList<OperationProcessor>();
fork2.add(new OperationProcessor(new DummyThrottleOperationFactory()));
forks.add(fork2);
ForkOperation op = new ForkOperation(forks);
/*
* Create thread that supplies input events
*/
Queue<InternalEvent> inputQueue = new Queue<InternalEvent>();
supply(10, inputQueue);
/*
* Process
*/
Stream<InternalEvent> input = inputQueue.stream();
Stream<InternalEvent> output = op.getOutputStream(input);
List<String> outputEvents = output.map(InternalEvent::getEventString).collect(Collectors.toList());
Monitor m = Monitor.getInstance();
List<Stat> stats = m.getStats();
Map<String, String> actual = new HashMap<String, String>();
for (Stat stat : stats) {
String key = String.format("%s.%s", stat.getTags().iterator().next().getValue(), stat.getName());
actual.put(key, "" + stat.getValue());
}
assertEquals("0", actual.get("com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperation.error.count"));
assertEquals("10", actual.get("com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperation.success.count"));
assertEquals("10", actual.get("com.nextdoor.bender.testutils.DummyThrottleOperationHelper.DummyThrottleOperation.success.count"));
assertEquals("0", actual.get("com.nextdoor.bender.testutils.DummyThrottleOperationHelper.DummyThrottleOperation.error.count"));
}
use of com.oath.cyclops.async.adapters.Queue in project bender by Nextdoor.
the class ForkOperationTest method testForkMonitoringSeries.
@Test
public void testForkMonitoringSeries() {
/*
* Setup the pipeline of operation processors
*/
List<List<OperationProcessor>> forks = new ArrayList<List<OperationProcessor>>();
List<OperationProcessor> fork1 = new ArrayList<OperationProcessor>();
fork1.add(new OperationProcessor(new DummyThrottleOperationFactory()));
fork1.add(new OperationProcessor(new DummyOperationFactory()));
forks.add(fork1);
ForkOperation op = new ForkOperation(forks);
/*
* Create thread that supplies input events
*/
Queue<InternalEvent> inputQueue = new Queue<InternalEvent>();
supply(10, inputQueue);
/*
* Process
*/
Stream<InternalEvent> input = inputQueue.stream();
Stream<InternalEvent> output = op.getOutputStream(input);
List<String> outputEvents = output.map(InternalEvent::getEventString).collect(Collectors.toList());
Monitor m = Monitor.getInstance();
List<Stat> stats = m.getStats();
Map<String, String> actual = new HashMap<String, String>();
for (Stat stat : stats) {
String key = String.format("%s.%s", stat.getTags().iterator().next().getValue(), stat.getName());
actual.put(key, "" + stat.getValue());
}
assertEquals("0", actual.get("com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperation.error.count"));
assertEquals("10", actual.get("com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperation.success.count"));
assertEquals("10", actual.get("com.nextdoor.bender.testutils.DummyThrottleOperationHelper.DummyThrottleOperation.success.count"));
assertEquals("0", actual.get("com.nextdoor.bender.testutils.DummyThrottleOperationHelper.DummyThrottleOperation.error.count"));
}
use of com.oath.cyclops.async.adapters.Queue in project bender by Nextdoor.
the class ForkOperationTest method testSingleFork.
@Test
public void testSingleFork() {
/*
* Setup the pipeline of operation processors
*/
List<List<OperationProcessor>> forks = new ArrayList<List<OperationProcessor>>();
List<OperationProcessor> fork1 = new ArrayList<OperationProcessor>();
fork1.add(new OperationProcessor(new DummyOperationFactory()));
forks.add(fork1);
ForkOperation op = new ForkOperation(forks);
/*
* Create thread that supplies input events
*/
Queue<InternalEvent> inputQueue = new Queue<InternalEvent>();
supply(2, inputQueue);
/*
* Process
*/
Stream<InternalEvent> input = inputQueue.stream();
Stream<InternalEvent> output = op.getOutputStream(input);
List<String> actual = output.map(InternalEvent::getEventString).collect(Collectors.toList());
List<String> expected = Arrays.asList("0", "1");
assertEquals(2, actual.size());
assertTrue(expected.containsAll(actual));
}
use of com.oath.cyclops.async.adapters.Queue in project bender by Nextdoor.
the class ForkOperationTest method testNullOpFork1.
@Test
public void testNullOpFork1() {
/*
* Setup the pipeline of operation processors
*/
List<List<OperationProcessor>> forks = new ArrayList<List<OperationProcessor>>();
List<OperationProcessor> fork1 = new ArrayList<OperationProcessor>();
fork1.add(new OperationProcessor(new DummyOperationFactory()));
forks.add(fork1);
List<OperationProcessor> fork2 = new ArrayList<OperationProcessor>();
DummyNullOperation nullOp = new DummyNullOperation();
fork2.add(new OperationProcessor(new DummyOperationFactory(nullOp)));
forks.add(fork2);
ForkOperation op = new ForkOperation(forks);
/*
* Create thread that supplies input events
*/
Queue<InternalEvent> inputQueue = new Queue<InternalEvent>();
supply(10, inputQueue);
/*
* Process
*/
Stream<InternalEvent> input = inputQueue.stream();
Stream<InternalEvent> output = op.getOutputStream(input);
List<String> actual = output.map(InternalEvent::getEventString).collect(Collectors.toList());
assertEquals(10, actual.size());
}
Aggregations