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);
}
Aggregations