Search in sources :

Example 6 with DeleteScopeStatus

use of io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus 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());
}
Also used : ScalingPolicy(io.pravega.client.stream.ScalingPolicy) CreateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) Test(org.junit.Test)

Example 7 with DeleteScopeStatus

use of io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus 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().scalingPolicy(policy1).build();
    ResultObserver<CreateStreamStatus> result4 = new ResultObserver<>();
    this.controllerService.createStream(ModelHelper.decode(SCOPE2, STREAM1, 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());
    // Delete empty scope, should throw
    ResultObserver<DeleteScopeStatus> result8 = new ResultObserver<>();
    AssertExtensions.assertThrows("Call to delete scope did not throw on empty scope", () -> this.controllerService.deleteScope(ModelHelper.createScopeInfo(""), result8), ex -> ex instanceof IllegalArgumentException);
}
Also used : ScalingPolicy(io.pravega.client.stream.ScalingPolicy) CreateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) Test(org.junit.Test)

Example 8 with DeleteScopeStatus

use of io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus in project pravega by pravega.

the class ControllerServiceImplTest method deleteScopeRecursiveTests.

@Test
public void deleteScopeRecursiveTests() {
    CreateScopeStatus createScopeStatus;
    DeleteScopeStatus deleteScopeStatus;
    // Delete empty scope (containing no streams)
    ResultObserver<CreateScopeStatus> result1 = new ResultObserver<>();
    this.controllerService.createScope(ModelHelper.createScopeInfo(SCOPE3), result1);
    createScopeStatus = result1.get();
    assertEquals("Create Scope", CreateScopeStatus.Status.SUCCESS, createScopeStatus.getStatus());
    // Delete Non-existent scope SCOPE3
    ResultObserver<DeleteScopeStatus> result6 = new ResultObserver<>();
    this.controllerService.deleteScopeRecursive(ModelHelper.createScopeInfo("SCOPE3"), result6);
    deleteScopeStatus = result6.get();
    assertEquals("Delete non existent scope", DeleteScopeStatus.Status.SUCCESS, deleteScopeStatus.getStatus());
    ResultObserver<DeleteScopeStatus> result8 = new ResultObserver<>();
    AssertExtensions.assertThrows("Call to delete scope did not throw on empty scope", () -> this.controllerService.deleteScopeRecursive(ModelHelper.createScopeInfo(""), result8), ex -> ex instanceof IllegalArgumentException);
}
Also used : CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) Test(org.junit.Test)

Aggregations

DeleteScopeStatus (io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus)7 Test (org.junit.Test)6 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)5 CreateScopeStatus (io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus)5 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)4 CreateStreamStatus (io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus)4 Controller (io.pravega.controller.stream.api.grpc.v1.Controller)3 CreateTxnRequest (io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest)2 DeleteStreamStatus (io.pravega.controller.stream.api.grpc.v1.Controller.DeleteStreamStatus)2 GetSegmentsRequest (io.pravega.controller.stream.api.grpc.v1.Controller.GetSegmentsRequest)2 NodeUri (io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri)2 PingTxnRequest (io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnRequest)2 PingTxnStatus (io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus)2 ScaleRequest (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleRequest)2 ScaleResponse (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse)2 ScaleStatusRequest (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusRequest)2 ScaleStatusResponse (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusResponse)2 ScopeInfo (io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo)2 SegmentId (io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId)2 SegmentRanges (io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRanges)2