Skip to content

Commit

Permalink
Add avro test
Browse files Browse the repository at this point in the history
  • Loading branch information
sushantmane committed Dec 19, 2024
1 parent 6d0c4bc commit 285323e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.linkedin.venice.exceptions.VeniceException;
import com.linkedin.venice.spark.input.hdfs.TestSparkInputFromHdfs;
import com.linkedin.venice.utils.ExceptionUtils;
import com.linkedin.venice.utils.Utils;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -56,9 +57,20 @@ public void testConstructorInitializationAndExceptions() throws IOException {
assertTrue(exception3.getMessage().contains("RecordReader cannot be null"));

// Case 4: Invalid SequenceFile
expectThrows(
Exception exception4 = expectThrows(
VeniceException.class,
() -> new VeniceVsonFileIterator(fileSystem, tempNonSeqFilePath, mockRecordReader));
assertTrue(ExceptionUtils.recursiveMessageContains(exception4, "not a SequenceFile"));

// Create avro file
File tempAvroFile = File.createTempFile("test-file", ".avro", tempDir);
Path tempAvroFilePath = new Path(tempAvroFile.getAbsolutePath());
TestSparkInputFromHdfs.writeAvroFile(tempDir, tempAvroFilePath.getName(), 1, 2);

Exception exception5 = expectThrows(
VeniceException.class,
() -> new VeniceVsonFileIterator(fileSystem, tempAvroFilePath, mockRecordReader));
assertTrue(ExceptionUtils.recursiveMessageContains(exception5, "not a SequenceFile"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private Map<String, String> getDefaultConfigs(File inputDir) {
return config;
}

private void writeAvroFile(File inputDir, String fileName, int start, int end) throws IOException {
public static void writeAvroFile(File inputDir, String fileName, int start, int end) throws IOException {
File file = new File(inputDir, fileName);

DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(AVRO_FILE_SCHEMA);
Expand Down

0 comments on commit 285323e

Please sign in to comment.