Search in sources :

Example 6 with WireCommandFailedException

use of io.pravega.controller.server.WireCommandFailedException 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

WireCommandFailedException (io.pravega.controller.server.WireCommandFailedException)6 SegmentHelper (io.pravega.controller.server.SegmentHelper)4 List (java.util.List)4 Test (org.junit.Test)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Unpooled (io.netty.buffer.Unpooled)3 Futures (io.pravega.common.concurrent.Futures)3 GrpcAuthHelper (io.pravega.controller.server.security.auth.GrpcAuthHelper)3 StoreException (io.pravega.controller.store.stream.StoreException)3 Map (java.util.Map)3 UUID (java.util.UUID)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 ByteBuf (io.netty.buffer.ByteBuf)2 HashTableIteratorItem (io.pravega.client.tables.impl.HashTableIteratorItem)2 TableSegmentEntry (io.pravega.client.tables.impl.TableSegmentEntry)2 TableSegmentKey (io.pravega.client.tables.impl.TableSegmentKey)2 TableSegmentKeyVersion (io.pravega.client.tables.impl.TableSegmentKeyVersion)2 Exceptions (io.pravega.common.Exceptions)2 BitConverter (io.pravega.common.util.BitConverter)2