You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "clesaec (via GitHub)" <gi...@apache.org> on 2023/08/09 12:21:51 UTC

[GitHub] [avro] clesaec opened a new pull request, #2431: AVRO-3826: Common tests for C++ module

clesaec opened a new pull request, #2431:
URL: https://github.com/apache/avro/pull/2431

   <!--
   
   *Thank you very much for contributing to Apache Avro - we are happy that you want to help us improve Avro. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Avro a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/AVRO/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "AVRO-XXXX: [component] Title of the pull request", where *AVRO-XXXX* should be replaced by the actual issue number. 
       The *component* is optional, but can help identify the correct reviewers faster: either the language ("java", "python") or subsystem such as "build" or "doc" are good candidates.  
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests. You can [build the entire project](https://github.com/apache/avro/blob/master/BUILD.md) or just the [language-specific SDK](https://avro.apache.org/project/how-to-contribute/#unit-tests).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Every commit message references Jira issues in their subject lines. In addition, commits follow the guidelines from [How to write a good git commit message](https://chris.beams.io/posts/git-commit/)
       1. Subject is separated from body by a blank line
       1. Subject is limited to 50 characters (not including Jira issue reference)
       1. Subject does not end with a period
       1. Subject uses the imperative mood ("add", not "adding")
       1. Body wraps at 72 characters
       1. Body explains "what" and "why", not "how"
   
   -->
   
   ## What is the purpose of the change
   
   this ticket [AVRO-3591](https://issues.apache.org/jira/browse/AVRO-3591) aims to have common test suite for differents modules.
   This PR complete it with task [AVRO-3826](https://issues.apache.org/jira/browse/AVRO-3826) for C++ module (currently, it exists for Java, Rust and C).
   
   
   ## Verifying this change
   
   As this PR only add a unit test to C++ module, the only thing to do is "./build.sh test" command at this module.
   
   
   ## Documentation
   
   - Does this pull request introduce a new feature? (no)
   - If yes, how is the feature documented? (not applicable)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] clesaec merged pull request #2431: AVRO-3826: Common tests for C++ module

Posted by "clesaec (via GitHub)" <gi...@apache.org>.
clesaec merged PR #2431:
URL: https://github.com/apache/avro/pull/2431


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] clesaec commented on a diff in pull request #2431: AVRO-3826: Common tests for C++ module

Posted by "clesaec (via GitHub)" <gi...@apache.org>.
clesaec commented on code in PR #2431:
URL: https://github.com/apache/avro/pull/2431#discussion_r1289716525


##########
lang/c++/test/CommonsSchemasTests.cc:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+#include <boost/test/included/unit_test.hpp>
+#include <boost/test/unit_test.hpp>
+#include <filesystem>
+#include "DataFile.hh"
+#include "Compiler.hh"
+#include "ValidSchema.hh"
+#include "Generic.hh"
+
+
+using avro::validatingDecoder;
+using avro::GenericReader;
+using avro::DataFileReader;
+using avro::DataFileWriter;
+using avro::GenericDatum;
+
+
+void testCommonSchema(const std::filesystem::path &dir_path)
+{
+	const std::filesystem::path& schemaFile = dir_path / "schema.json";
+	std::ifstream in(schemaFile.c_str());
+
+	avro::ValidSchema schema;
+	avro::compileJsonSchema(in, schema);
+
+	const std::filesystem::path& dataFile = dir_path / "data.avro";
+
+
+	GenericDatum datum(schema);
+	const std::filesystem::path& outputDataFile = dir_path / "data_out.avro";
+
+
+	DataFileReader<GenericDatum> reader(dataFile.c_str());
+	DataFileWriter<GenericDatum> writer(outputDataFile.c_str(), schema);
+
+	while (reader.read(datum)) {
+        avro::GenericRecord& rec =  datum.value<avro::GenericRecord>();
+        BOOST_CHECK(rec.fieldCount() >= 0);
+        writer.write(datum);
+	}
+	writer.close();
+	reader.close();
+
+	GenericDatum datumOrig(schema);
+	GenericDatum datumNew(schema);
+
+	DataFileReader<GenericDatum> readerOrig(dataFile.c_str());
+	DataFileReader<GenericDatum> readerNew(outputDataFile.c_str());
+	while (readerOrig.read(datumOrig)) {
+	    BOOST_CHECK(readerNew.read(datumNew));
+        avro::GenericRecord& rec1 =  datumOrig.value<avro::GenericRecord>();
+        avro::GenericRecord& rec2 =  datumNew.value<avro::GenericRecord>();
+        BOOST_CHECK_EQUAL(rec1.fieldCount(), rec2.fieldCount());
+	}
+	BOOST_CHECK(!readerNew.read(datumNew));
+
+
+	std::filesystem::remove(outputDataFile);
+}
+
+
+
+void testCommonsSchemas()
+{
+	const std::filesystem::path commons_schemas{"../../share/test/data/schemas"};
+	for (auto const& dir_entry : std::filesystem::directory_iterator{commons_schemas}) {

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] clesaec commented on a diff in pull request #2431: AVRO-3826: Common tests for C++ module

Posted by "clesaec (via GitHub)" <gi...@apache.org>.
clesaec commented on code in PR #2431:
URL: https://github.com/apache/avro/pull/2431#discussion_r1289678039


##########
lang/c++/test/CommonsSchemasTests.cc:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+#include <boost/test/included/unit_test.hpp>
+#include <boost/test/unit_test.hpp>
+#include <filesystem>
+#include "DataFile.hh"
+#include "Compiler.hh"
+#include "ValidSchema.hh"
+#include "Generic.hh"
+
+
+using avro::validatingDecoder;
+using avro::GenericReader;
+using avro::DataFileReader;
+using avro::DataFileWriter;
+using avro::GenericDatum;
+
+
+void testCommonSchema(const std::filesystem::path &dir_path)
+{
+	const std::filesystem::path& schemaFile = dir_path / "schema.json";
+	std::ifstream in(schemaFile.c_str());
+
+	avro::ValidSchema schema;
+	avro::compileJsonSchema(in, schema);
+
+	const std::filesystem::path& dataFile = dir_path / "data.avro";
+
+
+	GenericDatum datum(schema);
+	const std::filesystem::path& outputDataFile = dir_path / "data_out.avro";
+
+
+	DataFileReader<GenericDatum> reader(dataFile.c_str());
+	DataFileWriter<GenericDatum> writer(outputDataFile.c_str(), schema);
+
+	while (reader.read(datum)) {
+        avro::GenericRecord& rec =  datum.value<avro::GenericRecord>();
+        BOOST_CHECK(rec.fieldCount() >= 0);
+        writer.write(datum);
+	}
+	writer.close();
+	reader.close();
+
+	GenericDatum datumOrig(schema);
+	GenericDatum datumNew(schema);
+
+	DataFileReader<GenericDatum> readerOrig(dataFile.c_str());
+	DataFileReader<GenericDatum> readerNew(outputDataFile.c_str());
+	while (readerOrig.read(datumOrig)) {
+	    BOOST_CHECK(readerNew.read(datumNew));
+        avro::GenericRecord& rec1 =  datumOrig.value<avro::GenericRecord>();
+        avro::GenericRecord& rec2 =  datumNew.value<avro::GenericRecord>();
+        BOOST_CHECK_EQUAL(rec1.fieldCount(), rec2.fieldCount());
+	}
+	BOOST_CHECK(!readerNew.read(datumNew));
+
+
+	std::filesystem::remove(outputDataFile);
+}
+
+
+
+void testCommonsSchemas()
+{
+	const std::filesystem::path commons_schemas{"../../share/test/data/schemas"};
+	for (auto const& dir_entry : std::filesystem::directory_iterator{commons_schemas}) {

Review Comment:
   ok, i see; this kind of test is mostly for CI. I will change that the same way, doing the test only is the directory exists.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] clesaec commented on a diff in pull request #2431: AVRO-3826: Common tests for C++ module

Posted by "clesaec (via GitHub)" <gi...@apache.org>.
clesaec commented on code in PR #2431:
URL: https://github.com/apache/avro/pull/2431#discussion_r1289718963


##########
lang/c++/test/CommonsSchemasTests.cc:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+#include <boost/test/included/unit_test.hpp>
+#include <boost/test/unit_test.hpp>
+#include <filesystem>
+#include "DataFile.hh"
+#include "Compiler.hh"
+#include "ValidSchema.hh"
+#include "Generic.hh"
+
+
+using avro::validatingDecoder;
+using avro::GenericReader;
+using avro::DataFileReader;
+using avro::DataFileWriter;
+using avro::GenericDatum;
+
+
+void testCommonSchema(const std::filesystem::path &dir_path)
+{
+	const std::filesystem::path& schemaFile = dir_path / "schema.json";
+	std::ifstream in(schemaFile.c_str());
+
+	avro::ValidSchema schema;
+	avro::compileJsonSchema(in, schema);
+
+	const std::filesystem::path& dataFile = dir_path / "data.avro";
+
+
+	GenericDatum datum(schema);
+	const std::filesystem::path& outputDataFile = dir_path / "data_out.avro";
+
+
+	DataFileReader<GenericDatum> reader(dataFile.c_str());
+	DataFileWriter<GenericDatum> writer(outputDataFile.c_str(), schema);
+
+	while (reader.read(datum)) {
+        avro::GenericRecord& rec =  datum.value<avro::GenericRecord>();
+        BOOST_CHECK(rec.fieldCount() >= 0);
+        writer.write(datum);
+	}
+	writer.close();
+	reader.close();
+
+	GenericDatum datumOrig(schema);
+	GenericDatum datumNew(schema);
+
+	DataFileReader<GenericDatum> readerOrig(dataFile.c_str());
+	DataFileReader<GenericDatum> readerNew(outputDataFile.c_str());
+	while (readerOrig.read(datumOrig)) {
+	    BOOST_CHECK(readerNew.read(datumNew));
+        avro::GenericRecord& rec1 =  datumOrig.value<avro::GenericRecord>();
+        avro::GenericRecord& rec2 =  datumNew.value<avro::GenericRecord>();
+        BOOST_CHECK_EQUAL(rec1.fieldCount(), rec2.fieldCount());
+	}
+	BOOST_CHECK(!readerNew.read(datumNew));
+
+
+	std::filesystem::remove(outputDataFile);
+}
+
+
+
+void testCommonsSchemas()
+{
+	const std::filesystem::path commons_schemas{"../../share/test/data/schemas"};
+	for (auto const& dir_entry : std::filesystem::directory_iterator{commons_schemas}) {

Review Comment:
   just realize i mixed 2 PR ... I need to remove second commit



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] martin-g commented on a diff in pull request #2431: AVRO-3826: Common tests for C++ module

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2431:
URL: https://github.com/apache/avro/pull/2431#discussion_r1288459468


##########
lang/c++/test/CommonsSchemasTests.cc:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+#include <boost/test/included/unit_test.hpp>
+#include <boost/test/unit_test.hpp>
+#include <filesystem>
+#include "DataFile.hh"
+#include "Compiler.hh"
+#include "ValidSchema.hh"
+#include "Generic.hh"
+
+
+using avro::validatingDecoder;
+using avro::GenericReader;
+using avro::DataFileReader;
+using avro::DataFileWriter;
+using avro::GenericDatum;
+
+
+void testCommonSchema(const std::filesystem::path &dir_path)
+{
+	const std::filesystem::path& schemaFile = dir_path / "schema.json";
+	std::ifstream in(schemaFile.c_str());
+
+	avro::ValidSchema schema;
+	avro::compileJsonSchema(in, schema);
+
+	const std::filesystem::path& dataFile = dir_path / "data.avro";
+
+
+	GenericDatum datum(schema);
+	const std::filesystem::path& outputDataFile = dir_path / "data_out.avro";
+
+
+	DataFileReader<GenericDatum> reader(dataFile.c_str());
+	DataFileWriter<GenericDatum> writer(outputDataFile.c_str(), schema);
+
+	while (reader.read(datum)) {
+        avro::GenericRecord& rec =  datum.value<avro::GenericRecord>();
+        BOOST_CHECK(rec.fieldCount() >= 0);
+        writer.write(datum);
+	}
+	writer.close();
+	reader.close();
+
+	GenericDatum datumOrig(schema);
+	GenericDatum datumNew(schema);
+
+	DataFileReader<GenericDatum> readerOrig(dataFile.c_str());
+	DataFileReader<GenericDatum> readerNew(outputDataFile.c_str());
+	while (readerOrig.read(datumOrig)) {
+	    BOOST_CHECK(readerNew.read(datumNew));
+        avro::GenericRecord& rec1 =  datumOrig.value<avro::GenericRecord>();
+        avro::GenericRecord& rec2 =  datumNew.value<avro::GenericRecord>();
+        BOOST_CHECK_EQUAL(rec1.fieldCount(), rec2.fieldCount());
+	}
+	BOOST_CHECK(!readerNew.read(datumNew));
+
+
+	std::filesystem::remove(outputDataFile);
+}
+
+
+
+void testCommonsSchemas()
+{
+	const std::filesystem::path commons_schemas{"../../share/test/data/schemas"};
+	for (auto const& dir_entry : std::filesystem::directory_iterator{commons_schemas}) {

Review Comment:
   How does this deal with missing paths ?
   I'm asking because I had this issues recently in the Rust SDK:
   - the email for testing a release candidate points to https://dist.apache.org/repos/dist/dev/avro/avro-1.11.2-rc1/cpp/ - the `.tar.gz` there is just the sources of `lang/cpp` and there is no `../../share/...`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] clesaec commented on a diff in pull request #2431: AVRO-3826: Common tests for C++ module

Posted by "clesaec (via GitHub)" <gi...@apache.org>.
clesaec commented on code in PR #2431:
URL: https://github.com/apache/avro/pull/2431#discussion_r1289725839


##########
lang/c++/test/CommonsSchemasTests.cc:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+#include <boost/test/included/unit_test.hpp>
+#include <boost/test/unit_test.hpp>
+#include <filesystem>
+#include "DataFile.hh"
+#include "Compiler.hh"
+#include "ValidSchema.hh"
+#include "Generic.hh"
+
+
+using avro::validatingDecoder;
+using avro::GenericReader;
+using avro::DataFileReader;
+using avro::DataFileWriter;
+using avro::GenericDatum;
+
+
+void testCommonSchema(const std::filesystem::path &dir_path)
+{
+	const std::filesystem::path& schemaFile = dir_path / "schema.json";
+	std::ifstream in(schemaFile.c_str());
+
+	avro::ValidSchema schema;
+	avro::compileJsonSchema(in, schema);
+
+	const std::filesystem::path& dataFile = dir_path / "data.avro";
+
+
+	GenericDatum datum(schema);
+	const std::filesystem::path& outputDataFile = dir_path / "data_out.avro";
+
+
+	DataFileReader<GenericDatum> reader(dataFile.c_str());
+	DataFileWriter<GenericDatum> writer(outputDataFile.c_str(), schema);
+
+	while (reader.read(datum)) {
+        avro::GenericRecord& rec =  datum.value<avro::GenericRecord>();
+        BOOST_CHECK(rec.fieldCount() >= 0);
+        writer.write(datum);
+	}
+	writer.close();
+	reader.close();
+
+	GenericDatum datumOrig(schema);
+	GenericDatum datumNew(schema);
+
+	DataFileReader<GenericDatum> readerOrig(dataFile.c_str());
+	DataFileReader<GenericDatum> readerNew(outputDataFile.c_str());
+	while (readerOrig.read(datumOrig)) {
+	    BOOST_CHECK(readerNew.read(datumNew));
+        avro::GenericRecord& rec1 =  datumOrig.value<avro::GenericRecord>();
+        avro::GenericRecord& rec2 =  datumNew.value<avro::GenericRecord>();
+        BOOST_CHECK_EQUAL(rec1.fieldCount(), rec2.fieldCount());
+	}
+	BOOST_CHECK(!readerNew.read(datumNew));
+
+
+	std::filesystem::remove(outputDataFile);
+}
+
+
+
+void testCommonsSchemas()
+{
+	const std::filesystem::path commons_schemas{"../../share/test/data/schemas"};
+	for (auto const& dir_entry : std::filesystem::directory_iterator{commons_schemas}) {

Review Comment:
   That's better  :) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org