use of io.pravega.controller.stream.api.grpc.v1.Controller.TxnState in project pravega by pravega.
the class TimeoutServiceTest method testControllerPingFailureDisconnected.
@Test(timeout = 10000)
public void testControllerPingFailureDisconnected() throws InterruptedException {
TxnId txnId = controllerService.createTransaction(SCOPE, STREAM, LEASE, SCALE_GRACE_PERIOD).thenApply(x -> ModelHelper.decode(x.getKey())).join();
Optional<Throwable> result = timeoutService.getTaskCompletionQueue().poll((long) (0.75 * LEASE), TimeUnit.MILLISECONDS);
Assert.assertNull(result);
TxnState status = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId).join();
Assert.assertEquals(TxnState.State.OPEN, status.getState());
// Stop timeoutService, and then try pinging the transaction.
timeoutService.stopAsync();
PingTxnStatus pingStatus = controllerService.pingTransaction(SCOPE, STREAM, txnId, LEASE).join();
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 = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId).join();
Assert.assertEquals(TxnState.State.OPEN, status.getState());
}
Aggregations