use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus in project pravega by pravega.
the class ControllerServiceImplTest method deleteStreamTests.
@Test
public void deleteStreamTests() {
CreateScopeStatus createScopeStatus;
CreateStreamStatus createStreamStatus;
DeleteStreamStatus deleteStreamStatus;
final StreamConfiguration configuration1 = StreamConfiguration.builder().scope(SCOPE1).streamName(STREAM1).scalingPolicy(ScalingPolicy.fixed(4)).build();
// Create a test scope.
ResultObserver<CreateScopeStatus> result1 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE1), result1);
createScopeStatus = result1.get();
assertEquals("Create Scope", CreateScopeStatus.Status.SUCCESS, createScopeStatus.getStatus());
// Try deleting a non-existent stream.
ResultObserver<DeleteStreamStatus> result2 = new ResultObserver<>();
this.controllerService.deleteStream(ModelHelper.createStreamInfo(SCOPE3, "dummyStream"), result2);
deleteStreamStatus = result2.get();
assertEquals("Delete Non-existent stream", DeleteStreamStatus.Status.STREAM_NOT_FOUND, deleteStreamStatus.getStatus());
// Try deleting a non-existent stream.
ResultObserver<DeleteStreamStatus> result3 = new ResultObserver<>();
this.controllerService.deleteStream(ModelHelper.createStreamInfo("dummyScope", "dummyStream"), result3);
deleteStreamStatus = result3.get();
assertEquals("Delete Non-existent stream", DeleteStreamStatus.Status.STREAM_NOT_FOUND, deleteStreamStatus.getStatus());
// Create a test stream.
ResultObserver<CreateStreamStatus> result4 = new ResultObserver<>();
this.controllerService.createStream(ModelHelper.decode(configuration1), result4);
createStreamStatus = result4.get();
Assert.assertEquals("Create stream", CreateStreamStatus.Status.SUCCESS, createStreamStatus.getStatus());
// Try deleting the test stream without sealing it first.
ResultObserver<DeleteStreamStatus> result5 = new ResultObserver<>();
this.controllerService.deleteStream(ModelHelper.createStreamInfo(SCOPE1, STREAM1), result5);
deleteStreamStatus = result5.get();
assertEquals("Delete non-sealed stream", DeleteStreamStatus.Status.STREAM_NOT_SEALED, deleteStreamStatus.getStatus());
// Seal the test stream.
ResultObserver<UpdateStreamStatus> result6 = new ResultObserver<>();
this.controllerService.sealStream(ModelHelper.createStreamInfo(SCOPE1, STREAM1), result6);
UpdateStreamStatus updateStreamStatus = result6.get();
assertEquals("Seal stream", UpdateStreamStatus.Status.SUCCESS, updateStreamStatus.getStatus());
// Delete the sealed stream.
ResultObserver<DeleteStreamStatus> result7 = new ResultObserver<>();
this.controllerService.deleteStream(ModelHelper.createStreamInfo(SCOPE1, STREAM1), result7);
deleteStreamStatus = result7.get();
assertEquals("Delete sealed stream", DeleteStreamStatus.Status.SUCCESS, deleteStreamStatus.getStatus());
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus in project pravega by pravega.
the class ControllerServiceImplTest method deleteScopeTests.
@Test
public void deleteScopeTests() {
CreateScopeStatus createScopeStatus;
DeleteScopeStatus deleteScopeStatus;
CreateStreamStatus createStreamStatus;
// Delete empty scope (containing no streams) SCOPE3
ResultObserver<CreateScopeStatus> result1 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE3), result1);
createScopeStatus = result1.get();
assertEquals("Create Scope", CreateScopeStatus.Status.SUCCESS, createScopeStatus.getStatus());
ResultObserver<DeleteScopeStatus> result2 = new ResultObserver<>();
this.controllerService.deleteScope(ModelHelper.createScopeInfo(SCOPE3), result2);
deleteScopeStatus = result2.get();
assertEquals("Delete Empty scope", DeleteScopeStatus.Status.SUCCESS, deleteScopeStatus.getStatus());
// To verify that SCOPE3 is infact deleted in above delete call
ResultObserver<DeleteScopeStatus> result7 = new ResultObserver<>();
this.controllerService.deleteScope(ModelHelper.createScopeInfo(SCOPE3), result7);
deleteScopeStatus = result7.get();
assertEquals("Verify that Scope3 is infact deleted", DeleteScopeStatus.Status.SCOPE_NOT_FOUND, deleteScopeStatus.getStatus());
// Delete Non-empty Scope SCOPE2
ResultObserver<CreateScopeStatus> result3 = new ResultObserver<>();
this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE2), result3);
createScopeStatus = result3.get();
assertEquals("Create Scope", CreateScopeStatus.Status.SUCCESS, createScopeStatus.getStatus());
final ScalingPolicy policy1 = ScalingPolicy.fixed(2);
final StreamConfiguration configuration1 = StreamConfiguration.builder().scope(SCOPE2).streamName(STREAM1).scalingPolicy(policy1).build();
ResultObserver<CreateStreamStatus> result4 = new ResultObserver<>();
this.controllerService.createStream(ModelHelper.decode(configuration1), result4);
createStreamStatus = result4.get();
assertEquals(createStreamStatus.getStatus(), CreateStreamStatus.Status.SUCCESS);
ResultObserver<DeleteScopeStatus> result5 = new ResultObserver<>();
this.controllerService.deleteScope(ModelHelper.createScopeInfo(SCOPE2), result5);
deleteScopeStatus = result5.get();
assertEquals("Delete non empty scope", DeleteScopeStatus.Status.SCOPE_NOT_EMPTY, deleteScopeStatus.getStatus());
// Delete Non-existent scope SCOPE3
ResultObserver<DeleteScopeStatus> result6 = new ResultObserver<>();
this.controllerService.deleteScope(ModelHelper.createScopeInfo("SCOPE3"), result6);
deleteScopeStatus = result6.get();
assertEquals("Delete non existent scope", DeleteScopeStatus.Status.SCOPE_NOT_FOUND, deleteScopeStatus.getStatus());
}
Aggregations