Search in sources :

Example 1 with DFSDeltaWriterAdapter

use of org.apache.hudi.integ.testsuite.writer.DFSDeltaWriterAdapter in project hudi by apache.

the class TestDFSHoodieTestSuiteWriterAdapter method testDFSTwoFilesWriteWithRollover.

@Test
public void testDFSTwoFilesWriteWithRollover() throws IOException {
    DeltaInputWriter<GenericRecord> mockFileSinkWriter = Mockito.mock(AvroFileDeltaInputWriter.class);
    DeltaWriteStats mockDeltaWriteStats = Mockito.mock(DeltaWriteStats.class);
    when(mockFileSinkWriter.getNewWriter()).thenReturn(mockFileSinkWriter);
    when(mockFileSinkWriter.canWrite()).thenReturn(false, true);
    when(mockFileSinkWriter.getDeltaWriteStats()).thenReturn(mockDeltaWriteStats);
    DeltaWriterAdapter<GenericRecord> dfsDeltaWriterAdapter = new DFSDeltaWriterAdapter(mockFileSinkWriter);
    Iterator<GenericRecord> mockIterator = Mockito.mock(Iterator.class);
    when(mockIterator.hasNext()).thenReturn(true, true, true, false);
    dfsDeltaWriterAdapter.write(mockIterator);
    Mockito.verify(mockFileSinkWriter, times(2)).canWrite();
    Mockito.verify(mockFileSinkWriter, times(1)).getNewWriter();
    Mockito.verify(mockFileSinkWriter, times(2)).close();
}
Also used : DFSDeltaWriterAdapter(org.apache.hudi.integ.testsuite.writer.DFSDeltaWriterAdapter) GenericRecord(org.apache.avro.generic.GenericRecord) DeltaWriteStats(org.apache.hudi.integ.testsuite.writer.DeltaWriteStats) Test(org.junit.jupiter.api.Test)

Example 2 with DFSDeltaWriterAdapter

use of org.apache.hudi.integ.testsuite.writer.DFSDeltaWriterAdapter in project hudi by apache.

the class TestDFSHoodieTestSuiteWriterAdapter method testDFSOneFileWrite.

@Test
public void testDFSOneFileWrite() throws IOException {
    DeltaInputWriter<GenericRecord> mockFileSinkWriter = Mockito.mock(AvroFileDeltaInputWriter.class);
    DeltaWriteStats mockDeltaWriteStats = Mockito.mock(DeltaWriteStats.class);
    when(mockFileSinkWriter.getNewWriter()).thenReturn(mockFileSinkWriter);
    when(mockFileSinkWriter.canWrite()).thenReturn(true);
    when(mockFileSinkWriter.getDeltaWriteStats()).thenReturn(mockDeltaWriteStats);
    DeltaWriterAdapter<GenericRecord> dfsDeltaWriterAdapter = new DFSDeltaWriterAdapter(mockFileSinkWriter);
    JavaRDD<GenericRecord> records = TestUtils.makeRDD(jsc, 10);
    dfsDeltaWriterAdapter.write(records.collect().iterator());
    Mockito.verify(mockFileSinkWriter, times(10)).canWrite();
    Mockito.verify(mockFileSinkWriter, times(1)).close();
}
Also used : DFSDeltaWriterAdapter(org.apache.hudi.integ.testsuite.writer.DFSDeltaWriterAdapter) GenericRecord(org.apache.avro.generic.GenericRecord) DeltaWriteStats(org.apache.hudi.integ.testsuite.writer.DeltaWriteStats) Test(org.junit.jupiter.api.Test)

Aggregations

GenericRecord (org.apache.avro.generic.GenericRecord)2 DFSDeltaWriterAdapter (org.apache.hudi.integ.testsuite.writer.DFSDeltaWriterAdapter)2 DeltaWriteStats (org.apache.hudi.integ.testsuite.writer.DeltaWriteStats)2 Test (org.junit.jupiter.api.Test)2