use of io.pravega.shared.metrics.OpStatsData in project pravega by pravega.
the class PravegaRequestProcessorTest method testCreateSegment.
@Test(timeout = 20000)
public void testCreateSegment() throws Exception {
// Set up PravegaRequestProcessor instance to execute requests against
String streamSegmentName = "testCreateSegment";
@Cleanup ServiceBuilder serviceBuilder = newInlineExecutionInMemoryBuilder(getBuilderConfig());
serviceBuilder.initialize();
StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
ServerConnection connection = mock(ServerConnection.class);
InOrder order = inOrder(connection);
PravegaRequestProcessor processor = new PravegaRequestProcessor(store, connection);
// Execute and Verify createSegment/getStreamSegmentInfo calling stack is executed as design.
processor.createSegment(new WireCommands.CreateSegment(1, streamSegmentName, WireCommands.CreateSegment.NO_SCALE, 0, ""));
assertTrue(append(streamSegmentName, 1, store));
processor.getStreamSegmentInfo(new WireCommands.GetStreamSegmentInfo(1, streamSegmentName, ""));
assertTrue(append(streamSegmentName, 2, store));
order.verify(connection).send(new WireCommands.SegmentCreated(1, streamSegmentName));
order.verify(connection).send(Mockito.any(WireCommands.StreamSegmentInfo.class));
// TestCreateSealDelete may executed before this test case,
// so createSegmentStats may record 1 or 2 createSegment operation here.
OpStatsData createSegmentStats = processor.getCreateStreamSegment().toOpStatsData();
assertNotEquals(0, createSegmentStats.getNumSuccessfulEvents());
assertEquals(0, createSegmentStats.getNumFailedEvents());
}
Aggregations