Search in sources :

Example 11 with SystemProducerException

use of org.apache.samza.system.SystemProducerException in project samza by apache.

the class TestAzureBlobSystemProducer method testFlushWhenWriterCloseFails.

@Test
public void testFlushWhenWriterCloseFails() throws Exception {
    doThrow(new SystemProducerException("failed")).when(mockAzureWriter).close();
    systemProducer.register(SOURCE);
    systemProducer.start();
    systemProducer.send(SOURCE, ome);
    try {
        systemProducer.flush(SOURCE);
        Assert.fail("Expected exception not thrown.");
    } catch (SystemProducerException e) {
    }
    verify(mockErrorCounter).inc();
}
Also used : SystemProducerException(org.apache.samza.system.SystemProducerException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with SystemProducerException

use of org.apache.samza.system.SystemProducerException in project samza by apache.

the class TestAzureBlobSystemProducer method testSendWhenWriterFails.

@Test
public void testSendWhenWriterFails() throws Exception {
    doThrow(new SystemProducerException("failed")).when(mockAzureWriter).write(ome);
    systemProducer.register(SOURCE);
    systemProducer.start();
    try {
        systemProducer.send(SOURCE, ome);
        Assert.fail("Expected exception not thrown.");
    } catch (SystemProducerException e) {
    }
    verify(mockErrorCounter).inc();
}
Also used : SystemProducerException(org.apache.samza.system.SystemProducerException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with SystemProducerException

use of org.apache.samza.system.SystemProducerException in project samza by apache.

the class TestAzureBlobSystemProducer method testSendWhenWriterCreateFails.

@Test
public void testSendWhenWriterCreateFails() throws Exception {
    AzureBlobConfig azureBlobConfig = new AzureBlobConfig(getBasicConfigs());
    AzureBlobSystemProducer systemProducer = spy(new AzureBlobSystemProducer(SYSTEM_NAME, azureBlobConfig, mockMetricsRegistry));
    PowerMockito.whenNew(AzureBlobAvroWriter.class).withAnyArguments().thenThrow(new SystemProducerException("Failed"));
    // bypass Azure connection setup
    doNothing().when(systemProducer).setupAzureContainer();
    systemProducer.register(SOURCE);
    systemProducer.start();
    try {
        systemProducer.send(SOURCE, ome);
        Assert.fail("Expected exception not thrown.");
    } catch (SystemProducerException e) {
    }
    verify(mockErrorCounter).inc();
}
Also used : AzureBlobConfig(org.apache.samza.system.azureblob.AzureBlobConfig) SystemProducerException(org.apache.samza.system.SystemProducerException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

SystemProducerException (org.apache.samza.system.SystemProducerException)13 IOException (java.io.IOException)6 Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 BlobStorageException (com.azure.storage.blob.models.BlobStorageException)5 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)3 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)2 AzureBlobConfig (org.apache.samza.system.azureblob.AzureBlobConfig)2 BlobServiceAsyncClient (com.azure.storage.blob.BlobServiceAsyncClient)1 SkuName (com.azure.storage.blob.models.SkuName)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 OutgoingMessageEnvelope (org.apache.samza.system.OutgoingMessageEnvelope)1 AzureBlobClientBuilder (org.apache.samza.system.azureblob.AzureBlobClientBuilder)1 Mockito.anyString (org.mockito.Mockito.anyString)1