Search in sources :

Example 6 with PravegaTablesStoreHelper

use of io.pravega.controller.store.PravegaTablesStoreHelper in project pravega by pravega.

the class PravegaTablesKVTMetadataStoreTest method testPartiallyDeletedScope.

@Test(timeout = 30000)
public void testPartiallyDeletedScope() throws Exception {
    final String scopeName = "partialScope";
    PravegaTablesStoreHelper storeHelperSpy = spy(new PravegaTablesStoreHelper(segmentHelperMockForTables, GrpcAuthHelper.getDisabledAuthHelper(), executor));
    WireCommandFailedException wcfe = new WireCommandFailedException(WireCommandType.READ_TABLE_KEYS, WireCommandFailedException.Reason.TableKeyDoesNotExist);
    when(storeHelperSpy.getKeysPaginated(anyString(), any(), anyInt(), anyLong())).thenReturn(CompletableFuture.failedFuture(new CompletionException(StoreException.create(StoreException.Type.DATA_NOT_FOUND, wcfe, "kvTablesInScope not found."))));
    StreamMetadataStore testStreamStore = TestStreamStoreFactory.createPravegaTablesStreamStore(PRAVEGA_ZK_CURATOR_RESOURCE.client, executor, storeHelperSpy);
    KVTableMetadataStore testKVStore = TestStreamStoreFactory.createPravegaTablesKVStore(PRAVEGA_ZK_CURATOR_RESOURCE.client, executor, storeHelperSpy);
    OperationContext context = testStreamStore.createScopeContext(scopeName, 0L);
    CompletableFuture<Controller.CreateScopeStatus> createScopeFuture = testStreamStore.createScope(scopeName, context, executor);
    Controller.CreateScopeStatus status = createScopeFuture.get();
    Assert.assertEquals(Controller.CreateScopeStatus.Status.SUCCESS, status.getStatus());
    String token = Controller.ContinuationToken.newBuilder().build().getToken();
    Pair<List<String>, String> kvtList = testKVStore.listKeyValueTables(scopeName, token, 2, context, executor).get();
    Assert.assertEquals(0, kvtList.getKey().size());
    Assert.assertEquals(token, kvtList.getValue());
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) PravegaTablesStoreHelper(io.pravega.controller.store.PravegaTablesStoreHelper) CompletionException(java.util.concurrent.CompletionException) List(java.util.List) WireCommandFailedException(io.pravega.controller.server.WireCommandFailedException) Test(org.junit.Test)

Aggregations

PravegaTablesStoreHelper (io.pravega.controller.store.PravegaTablesStoreHelper)6 Test (org.junit.Test)5 SegmentHelper (io.pravega.controller.server.SegmentHelper)4 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)3 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)3 GrpcAuthHelper (io.pravega.controller.server.security.auth.GrpcAuthHelper)3 PravegaTablesScope (io.pravega.controller.store.PravegaTablesScope)3 List (java.util.List)3 Exceptions (io.pravega.common.Exceptions)2 Futures (io.pravega.common.concurrent.Futures)2 PravegaZkCuratorResource (io.pravega.controller.PravegaZkCuratorResource)2 SegmentHelperMock (io.pravega.controller.mocks.SegmentHelperMock)2 TestOperationContext (io.pravega.controller.store.TestOperationContext)2 VersionedMetadata (io.pravega.controller.store.VersionedMetadata)2 ZKStoreHelper (io.pravega.controller.store.ZKStoreHelper)2 OperationContext (io.pravega.controller.store.stream.OperationContext)2 CommittingTransactionsRecord (io.pravega.controller.store.stream.records.CommittingTransactionsRecord)2 EpochTransitionRecord (io.pravega.controller.store.stream.records.EpochTransitionRecord)2 StreamConfigurationRecord (io.pravega.controller.store.stream.records.StreamConfigurationRecord)2 NameUtils (io.pravega.shared.NameUtils)2