use of org.apache.pulsar.metadata.api.MetadataStoreException in project pulsar by apache.
the class ManagedLedgerErrorsTest method errorInRecovering5.
@Test
public void errorInRecovering5() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ledger.addEntry("entry".getBytes());
ledger.close();
@Cleanup("shutdown") ManagedLedgerFactory factory2 = new ManagedLedgerFactoryImpl(metadataStore, bkc);
metadataStore.failConditional(new MetadataStoreException("error"), (op, path) -> path.equals("/managed-ledgers/my_test_ledger") && op == FaultInjectionMetadataStore.OperationType.GET_CHILDREN);
try {
ledger = factory2.open("my_test_ledger");
fail("should fail");
} catch (ManagedLedgerException e) {
// ok
}
// It should be fine now
ledger = factory2.open("my_test_ledger");
}
use of org.apache.pulsar.metadata.api.MetadataStoreException in project pulsar by apache.
the class ManagedLedgerErrorsTest method errorInRecovering6.
@Test
public void errorInRecovering6() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ledger.openCursor("c1");
ledger.addEntry("entry".getBytes());
ledger.close();
@Cleanup("shutdown") ManagedLedgerFactory factory2 = new ManagedLedgerFactoryImpl(metadataStore, bkc);
metadataStore.failConditional(new MetadataStoreException("error"), (op, path) -> path.equals("/managed-ledgers/my_test_ledger/c1") && op == FaultInjectionMetadataStore.OperationType.GET);
try {
ledger = factory2.open("my_test_ledger");
fail("should fail");
} catch (ManagedLedgerException e) {
// ok
}
// It should be fine now
ledger = factory2.open("my_test_ledger");
}
use of org.apache.pulsar.metadata.api.MetadataStoreException in project pulsar by apache.
the class PersistentTopicsTest method testDeleteTopic.
@Test
public void testDeleteTopic() throws Exception {
final String topicName = "topic-1";
BrokerService brokerService = spy(pulsar.getBrokerService());
doReturn(brokerService).when(pulsar).getBrokerService();
persistentTopics.createNonPartitionedTopic(testTenant, testNamespace, topicName, false, null);
CompletableFuture<Void> deleteTopicFuture = new CompletableFuture<>();
deleteTopicFuture.completeExceptionally(new MetadataStoreException.NotFoundException());
doReturn(deleteTopicFuture).when(brokerService).deleteTopic(anyString(), anyBoolean(), anyBoolean());
persistentTopics.deleteTopic(testTenant, testNamespace, topicName, true, true, true);
//
CompletableFuture<Void> deleteTopicFuture2 = new CompletableFuture<>();
deleteTopicFuture2.completeExceptionally(new MetadataStoreException("test exception"));
doReturn(deleteTopicFuture2).when(brokerService).deleteTopic(anyString(), anyBoolean(), anyBoolean());
try {
persistentTopics.deleteTopic(testTenant, testNamespace, topicName, true, true, true);
} catch (Exception e) {
Assert.assertTrue(e instanceof RestException);
}
//
CompletableFuture<Void> deleteTopicFuture3 = new CompletableFuture<>();
deleteTopicFuture3.completeExceptionally(new MetadataStoreException.NotFoundException());
doReturn(deleteTopicFuture3).when(brokerService).deleteTopic(anyString(), anyBoolean(), anyBoolean());
try {
persistentTopics.deleteTopic(testTenant, testNamespace, topicName, false, true, true);
} catch (RestException e) {
Assert.assertEquals(e.getResponse().getStatus(), 404);
}
}
use of org.apache.pulsar.metadata.api.MetadataStoreException in project pulsar by apache.
the class ManagedCursorTest method errorCreatingCursor.
@Test(timeOut = 20000)
void errorCreatingCursor() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
bkc.failAfter(1, BKException.Code.NotEnoughBookiesException);
metadataStore.failConditional(new MetadataStoreException("error"), (op, path) -> path.equals("/managed-ledgers/my_test_ledger/c1") && op == FaultInjectionMetadataStore.OperationType.PUT);
try {
ledger.openCursor("c1");
fail("should have failed");
} catch (ManagedLedgerException e) {
// ok
}
}
use of org.apache.pulsar.metadata.api.MetadataStoreException in project pulsar by apache.
the class ManagedCursorTest method markDeleteWithZKErrors.
@Test(timeOut = 20000)
void markDeleteWithZKErrors() throws Exception {
ManagedLedger ledger = factory.open("my_test_ledger");
ManagedCursor cursor = ledger.openCursor("c1");
ledger.addEntry("dummy-entry-1".getBytes(Encoding));
List<Entry> entries = cursor.readEntries(100);
assertEquals(entries.size(), 1);
stopBookKeeper();
metadataStore.setAlwaysFail(new MetadataStoreException("error"));
try {
cursor.markDelete(entries.get(0).getPosition());
fail("Should have failed");
} catch (Exception e) {
// Expected
}
entries.forEach(e -> e.release());
}
Aggregations