use of io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus in project pravega by pravega.
the class TimeoutServiceTest method testPingSuccess.
@Test(timeout = 10000)
public void testPingSuccess() throws InterruptedException {
UUID txnId = UUID.randomUUID();
VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId, 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);
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);
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus in project pravega by pravega.
the class TimeoutServiceTest method testPingFailureMaxExecutionTimeExceeded.
@Test(timeout = 10000)
public void testPingFailureMaxExecutionTimeExceeded() throws InterruptedException {
VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, UUID.randomUUID(), LEASE, 2 * LEASE, SCALE_GRACE_PERIOD, null, executor).join();
timeoutService.addTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE, txData.getMaxExecutionExpiryTime(), txData.getScaleGracePeriod());
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);
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus 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);
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus in project pravega by pravega.
the class TimeoutServiceTest method testUnknownTxnPingSuccess.
@Test(timeout = 10000)
public void testUnknownTxnPingSuccess() throws InterruptedException {
UUID txnId = UUID.randomUUID();
VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId, LEASE, 10 * LEASE, SCALE_GRACE_PERIOD, null, executor).join();
TxnId tx = TxnId.newBuilder().setHighBits(txnId.getMostSignificantBits()).setLowBits(txnId.getLeastSignificantBits()).build();
controllerService.pingTransaction(SCOPE, STREAM, tx, LEASE);
TxnStatus status = streamStore.transactionStatus(SCOPE, STREAM, txData.getId(), null, executor).join();
Assert.assertEquals(TxnStatus.OPEN, status);
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus in project pravega by pravega.
the class TimeoutServiceTest method testTimeout.
@Test(timeout = 10000)
public void testTimeout() throws InterruptedException {
UUID txnId = UUID.randomUUID();
VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId, LEASE, 10 * LEASE, SCALE_GRACE_PERIOD, null, executor).join();
long begin = System.currentTimeMillis();
timeoutService.addTxn(SCOPE, STREAM, txData.getId(), txData.getVersion(), LEASE, txData.getMaxExecutionExpiryTime(), txData.getScaleGracePeriod());
Optional<Throwable> result = timeoutService.getTaskCompletionQueue().poll((long) (1.3 * LEASE), TimeUnit.MILLISECONDS);
long end = System.currentTimeMillis();
Assert.assertNotNull(result);
log.info("Delay until timeout = " + (end - begin));
Assert.assertTrue((end - begin) >= LEASE);
TxnStatus status = streamStore.transactionStatus(SCOPE, STREAM, txData.getId(), null, executor).join();
Assert.assertEquals(TxnStatus.ABORTING, status);
}
Aggregations