@Test(timeout = 10000) public void testControllerPingFailureMaxExecutionTimeExceeded() throws InterruptedException { int lease = 10; TxnId txnId = controllerService.createTransaction(SCOPE, STREAM, lease) .thenApply(x -> ModelHelper.decode(x.getKey())) .join(); TxnState txnState = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId).join(); Assert.assertEquals(TxnState.State.OPEN, txnState.getState()); PingTxnStatus pingStatus = controllerService.pingTransaction(SCOPE, STREAM, txnId, 1000 * lease).join(); Assert.assertEquals(PingTxnStatus.Status.MAX_EXECUTION_TIME_EXCEEDED, pingStatus.getStatus()); txnState = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId).join(); Assert.assertEquals(TxnState.State.OPEN, txnState.getState()); }
@Test(timeout = 10000) public void testControllerPingLeaseTooLarge() { int lease = 10; TxnId txnId = controllerService.createTransaction(SCOPE, STREAM, lease) .thenApply(x -> ModelHelper.decode(x.getKey())) .join(); PingTxnStatus pingStatus = controllerService.pingTransaction(SCOPE, STREAM, txnId, Config.MAX_LEASE_VALUE + 1).join(); Assert.assertEquals(PingTxnStatus.Status.LEASE_TOO_LARGE, pingStatus.getStatus()); pingStatus = controllerService.pingTransaction(SCOPE, STREAM, txnId, 1000 * lease + 1).join(); Assert.assertEquals(PingTxnStatus.Status.MAX_EXECUTION_TIME_EXCEEDED, pingStatus.getStatus()); UUID txnId1 = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join(); VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId1, LEASE, 2 * LEASE, null, executor).join(); txnId = ModelHelper.decode(txData.getId()); pingStatus = controllerService.pingTransaction(SCOPE, STREAM, txnId, Config.MAX_LEASE_VALUE + 1).join(); Assert.assertEquals(PingTxnStatus.Status.LEASE_TOO_LARGE, pingStatus.getStatus()); pingStatus = controllerService.pingTransaction(SCOPE, STREAM, txnId, 3 * LEASE).join(); Assert.assertEquals(PingTxnStatus.Status.MAX_EXECUTION_TIME_EXCEEDED, pingStatus.getStatus()); }
@Test(timeout = 10000) public void testControllerPingSuccess() throws InterruptedException { TxnId txnId = controllerService.createTransaction(SCOPE, STREAM, LEASE) .thenApply(x -> ModelHelper.decode(x.getKey())) .join(); Optional<Throwable> result = timeoutService.getTaskCompletionQueue().poll((long) (0.75 * LEASE), TimeUnit.MILLISECONDS); Assert.assertNull(result); TxnState txnState = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId).join(); Assert.assertEquals(TxnState.State.OPEN, txnState.getState()); PingTxnStatus pingStatus = controllerService.pingTransaction(SCOPE, STREAM, txnId, LEASE).join(); Assert.assertEquals(PingTxnStatus.Status.OK, pingStatus.getStatus()); result = timeoutService.getTaskCompletionQueue().poll((long) (0.5 * LEASE), TimeUnit.MILLISECONDS); Assert.assertNull(result); txnState = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId).join(); Assert.assertEquals(TxnState.State.OPEN, txnState.getState()); result = timeoutService.getTaskCompletionQueue().poll((long) (0.8 * LEASE), TimeUnit.MILLISECONDS); Assert.assertNotNull(result); txnState = controllerService.checkTransactionStatus(SCOPE, STREAM, txnId).join(); Assert.assertEquals(TxnState.State.ABORTING, txnState.getState()); }
Assert.assertEquals(0, tx3.getVersion().asIntVersion().getIntValue()); Assert.assertEquals(1, tx4get.getVersion().asIntVersion().getIntValue()); Assert.assertEquals(PingTxnStatus.Status.OK, pingStatus.getStatus());
Assert.assertEquals(PingTxnStatus.Status.OK, pingStatus.getStatus());
@Test(timeout = 10000) public void testPingSuccess() throws InterruptedException { UUID txnId = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join(); VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId, LEASE, 10 * LEASE, null, executor).join(); timeoutService.addTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE, txData.getMaxExecutionExpiryTime()); 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); PingTxnStatus pingStatus = timeoutService.pingTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE); Assert.assertEquals(PingTxnStatus.Status.OK, pingStatus.getStatus()); result = timeoutService.getTaskCompletionQueue().poll((long) (0.5 * LEASE), TimeUnit.MILLISECONDS); Assert.assertNull(result); status = streamStore.transactionStatus(SCOPE, STREAM, txData.getId(), null, executor).join(); Assert.assertEquals(TxnStatus.OPEN, status); result = timeoutService.getTaskCompletionQueue().poll((long) (0.8 * LEASE), TimeUnit.MILLISECONDS); Assert.assertNotNull(result); status = streamStore.transactionStatus(SCOPE, STREAM, txData.getId(), null, executor).join(); Assert.assertEquals(TxnStatus.ABORTING, status); }
@Test(timeout = 10000) public void testPingFailureDisconnected() throws InterruptedException { UUID txnId = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join(); VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId, LEASE, 10 * LEASE, null, executor).join(); timeoutService.addTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE, txData.getMaxExecutionExpiryTime()); 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); }
@Test(timeout = 10000) public void testControllerPingFailureDisconnected() throws InterruptedException { TxnId txnId = controllerService.createTransaction(SCOPE, STREAM, LEASE) .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()); }
@Test(timeout = 10000) public void testPingFailureMaxExecutionTimeExceeded() throws InterruptedException { UUID txnId = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join(); VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId, LEASE, 2 * LEASE, null, executor).join(); timeoutService.addTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE, txData.getMaxExecutionExpiryTime()); TxnStatus status = streamStore.transactionStatus(SCOPE, STREAM, txData.getId(), null, executor).join(); Assert.assertEquals(TxnStatus.OPEN, status); // 3 * LEASE > 2 * LEASE PingTxnStatus pingStatus = timeoutService.pingTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), 3 * LEASE); Assert.assertEquals(PingTxnStatus.Status.MAX_EXECUTION_TIME_EXCEEDED, pingStatus.getStatus()); status = streamStore.transactionStatus(SCOPE, STREAM, txData.getId(), null, executor).join(); Assert.assertEquals(TxnStatus.OPEN, status); }
@Test(timeout = 10000) public void testPingLeaseTooLarge() { UUID txnId = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join(); VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId, LEASE, 10 * LEASE, null, executor).join(); timeoutService.addTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE, txData.getMaxExecutionExpiryTime()); Version version = txData.getVersion(); PingTxnStatus pingStatus = timeoutService.pingTxn(SCOPE, STREAM, txData.getId(), version, Config.MAX_LEASE_VALUE + 1); Assert.assertEquals(PingTxnStatus.Status.LEASE_TOO_LARGE, pingStatus.getStatus()); pingStatus = timeoutService.pingTxn(SCOPE, STREAM, txData.getId(), version, 10 * LEASE + 1); Assert.assertEquals(PingTxnStatus.Status.MAX_EXECUTION_TIME_EXCEEDED, pingStatus.getStatus()); }