Search in sources :

Example 1 with OpStatsData

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());
}
Also used : InOrder(org.mockito.InOrder) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Cleanup(lombok.Cleanup) ServiceBuilder(io.pravega.segmentstore.server.store.ServiceBuilder) StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) SynchronousStreamSegmentStore(io.pravega.segmentstore.server.mocks.SynchronousStreamSegmentStore) OpStatsData(io.pravega.shared.metrics.OpStatsData) WireCommands(io.pravega.shared.protocol.netty.WireCommands) Test(org.junit.Test)

Aggregations

StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)1 SynchronousStreamSegmentStore (io.pravega.segmentstore.server.mocks.SynchronousStreamSegmentStore)1 ServiceBuilder (io.pravega.segmentstore.server.store.ServiceBuilder)1 OpStatsData (io.pravega.shared.metrics.OpStatsData)1 WireCommands (io.pravega.shared.protocol.netty.WireCommands)1 Cleanup (lombok.Cleanup)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 InOrder (org.mockito.InOrder)1