use of io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus.Status 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.PingTxnStatus.Status 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.PingTxnStatus.Status 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);
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus.Status in project pravega by pravega.
the class ControllerServiceImplTest method createStreamTests.
@Test
public void createStreamTests() {
final ScalingPolicy policy1 = ScalingPolicy.fixed(2);
final ScalingPolicy policy2 = ScalingPolicy.fixed(3);
final StreamConfiguration configuration1 = StreamConfiguration.builder().scope(SCOPE1).streamName(STREAM1).scalingPolicy(policy1).build();
final StreamConfiguration configuration2 = StreamConfiguration.builder().scope(SCOPE1).streamName(STREAM2).scalingPolicy(policy2).build();
final StreamConfiguration configuration3 = StreamConfiguration.builder().scope("SCOPE3").streamName(STREAM2).scalingPolicy(policy2).build();
CreateStreamStatus status;
// region checkStream
ResultObserver<CreateScopeStatus> result = new ResultObserver<>();
this.controllerService.createScope(ScopeInfo.newBuilder().setScope(SCOPE1).build(), result);
Assert.assertEquals(result.get().getStatus(), CreateScopeStatus.Status.SUCCESS);
ResultObserver<CreateStreamStatus> result1 = new ResultObserver<>();
this.controllerService.createStream(ModelHelper.decode(configuration1), result1);
status = result1.get();
Assert.assertEquals(status.getStatus(), CreateStreamStatus.Status.SUCCESS);
ResultObserver<CreateStreamStatus> result2 = new ResultObserver<>();
this.controllerService.createStream(ModelHelper.decode(configuration2), result2);
status = result2.get();
Assert.assertEquals(status.getStatus(), CreateStreamStatus.Status.SUCCESS);
// endregion
// region duplicate create stream
ResultObserver<CreateStreamStatus> result3 = new ResultObserver<>();
this.controllerService.createStream(ModelHelper.decode(configuration1), result3);
status = result3.get();
Assert.assertEquals(status.getStatus(), CreateStreamStatus.Status.STREAM_EXISTS);
// endregion
// create stream for non-existent scope
ResultObserver<CreateStreamStatus> result4 = new ResultObserver<>();
this.controllerService.createStream(ModelHelper.decode(configuration3), result4);
status = result4.get();
Assert.assertEquals(status.getStatus(), CreateStreamStatus.Status.SCOPE_NOT_FOUND);
// create stream with invalid stream name "abc/def"
ResultObserver<CreateStreamStatus> result5 = new ResultObserver<>();
final StreamConfiguration configuration4 = StreamConfiguration.builder().scope("SCOPE3").streamName("abc/def").scalingPolicy(policy2).build();
this.controllerService.createStream(ModelHelper.decode(configuration4), result5);
status = result5.get();
assertEquals(status.getStatus(), CreateStreamStatus.Status.INVALID_STREAM_NAME);
// Create stream with an internal stream name.
ResultObserver<CreateStreamStatus> result6 = new ResultObserver<>();
final StreamConfiguration configuration6 = StreamConfiguration.builder().scope(SCOPE1).streamName(NameUtils.getInternalNameForStream("abcdef")).scalingPolicy(policy2).build();
this.controllerService.createStream(ModelHelper.decode(configuration6), result6);
status = result6.get();
assertEquals(status.getStatus(), CreateStreamStatus.Status.SUCCESS);
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus.Status in project pravega by pravega.
the class ControllerServiceImplTest method createScopeTests.
@Test
public void createScopeTests() {
CreateScopeStatus status;
// region createScope
ResultObserver<CreateScopeStatus> result1 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE1), result1);
status = result1.get();
assertEquals(status.getStatus(), CreateScopeStatus.Status.SUCCESS);
ResultObserver<CreateScopeStatus> result2 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE2), result2);
status = result2.get();
assertEquals(status.getStatus(), CreateScopeStatus.Status.SUCCESS);
// endregion
// region duplicate create scope
ResultObserver<CreateScopeStatus> result3 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE2), result3);
status = result3.get();
assertEquals(status.getStatus(), CreateScopeStatus.Status.SCOPE_EXISTS);
// endregion
// region with invalid scope with name "abc/def'
ResultObserver<CreateScopeStatus> result4 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo("abc/def"), result4);
status = result4.get();
assertEquals(status.getStatus(), CreateScopeStatus.Status.INVALID_SCOPE_NAME);
// endregion
}
Aggregations