Search in sources :

Example 11 with PingTxnStatus

use of io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus in project pravega by pravega.

the class TimeoutServiceTest method testPingFailureDisconnected.

@Test(timeout = 10000)
public void testPingFailureDisconnected() throws InterruptedException {
    VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, UUID.randomUUID(), LEASE, 10 * LEASE, SCALE_GRACE_PERIOD, null, executor).join();
    timeoutService.addTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE, txData.getMaxExecutionExpiryTime(), txData.getScaleGracePeriod());
    Optional<Throwable> result = timeoutService.getTaskCompletionQueue().poll((long) (0.75 * LEASE), TimeUnit.MILLISECONDS);
    Assert.assertNull(result);
    TxnStatus status = streamStore.transactionStatus(SCOPE, STREAM, txData.getId(), null, executor).join();
    Assert.assertEquals(TxnStatus.OPEN, status);
    // Stop timeoutService, and then try pinging the transaction.
    timeoutService.stopAsync();
    PingTxnStatus pingStatus = timeoutService.pingTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE);
    Assert.assertEquals(PingTxnStatus.Status.DISCONNECTED, pingStatus.getStatus());
    result = timeoutService.getTaskCompletionQueue().poll((long) (0.5 * LEASE), TimeUnit.MILLISECONDS);
    Assert.assertNull(result);
    // Check that the transaction status is still open, since timeoutService has been stopped.
    status = streamStore.transactionStatus(SCOPE, STREAM, txData.getId(), null, executor).join();
    Assert.assertEquals(TxnStatus.OPEN, status);
}
Also used : PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) VersionedTransactionData(io.pravega.controller.store.stream.VersionedTransactionData) TxnStatus(io.pravega.controller.store.stream.TxnStatus) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) Test(org.junit.Test)

Aggregations

PingTxnStatus (io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus)11 VersionedTransactionData (io.pravega.controller.store.stream.VersionedTransactionData)10 Test (org.junit.Test)10 TxnStatus (io.pravega.controller.store.stream.TxnStatus)9 UUID (java.util.UUID)8 Controller (io.pravega.controller.stream.api.grpc.v1.Controller)7 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)6 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)6 EventStreamWriterMock (io.pravega.controller.mocks.EventStreamWriterMock)6 SegmentHelperMock (io.pravega.controller.mocks.SegmentHelperMock)6 ControllerService (io.pravega.controller.server.ControllerService)6 SegmentHelper (io.pravega.controller.server.SegmentHelper)6 HostControllerStore (io.pravega.controller.store.host.HostControllerStore)6 HostStoreFactory (io.pravega.controller.store.host.HostStoreFactory)6 HostMonitorConfigImpl (io.pravega.controller.store.host.impl.HostMonitorConfigImpl)6 StreamMetadataStore (io.pravega.controller.store.stream.StreamMetadataStore)6 StreamStoreFactory (io.pravega.controller.store.stream.StreamStoreFactory)6 TaskMetadataStore (io.pravega.controller.store.task.TaskMetadataStore)6 TaskStoreFactory (io.pravega.controller.store.task.TaskStoreFactory)6 TxnState (io.pravega.controller.stream.api.grpc.v1.Controller.TxnState)6