[
https://issues.apache.org/jira/browse/AVRO-2452?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Kengo Seki updated AVRO-2452:
-----------------------------
Component/s: (was: c)
python
> Interop tests should check the number of records
> ------------------------------------------------
>
> Key: AVRO-2452
> URL: https://issues.apache.org/jira/browse/AVRO-2452
> Project: Apache Avro
> Issue Type: Test
> Components: java, python
> Reporter: Kengo Seki
> Assignee: Kengo Seki
> Priority: Major
>
> Currently, data interop tests for Java and Python2 don't check the number of
> records in the input file, so they will pass if the file is accidentally
> empty.
> {code:title=lang/java/ipc/src/test/java/org/apache/avro/DataFileInteropTest.java}
> private <T extends Object> void readFiles(DatumReaderProvider<T> provider)
> throws IOException {
> for (File f : Objects.requireNonNull(DATAFILE_DIR.listFiles())) {
> System.out.println("Reading: " + f.getName());
> try (FileReader<? extends Object> reader = DataFileReader.openReader(f,
> provider.get())) {
> for (Object datum : reader) {
> Assert.assertNotNull(datum);
> }
> }
> }
> }
> {code}
> {code:title=lang/py/test/test_datafile_interop.py}
> # read data in binary from file
> reader = open(os.path.join('@INTEROP_DATA_DIR@', f), 'rb')
> datum_reader = io.DatumReader()
> dfr = datafile.DataFileReader(reader, datum_reader)
> for datum in dfr:
> assert datum is not None
> {code}
> They should also check the number of records in the file, just as the PHP and
> Ruby's ones.
> {code:title=lang/php/test/InterOpTest.php}
> $this->assertNotEquals(0, count($data),
> sprintf("no data read from %s", $file_name));
> foreach ($data as $idx => $datum)
> $this->assertNotNull($datum, sprintf("null datum from %s", $file_name));
> {code}
> {code:title=lang/ruby/interop/test_interop.rb}
> i = 0
> r.each do |datum|
> i += 1
> assert_not_nil datum, "nil datum from #{fn}"
> end
> assert_not_equal 0, i, "no data read in from #{fn}"
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)