EnricoMi commented on code in PR #44990:
URL: https://github.com/apache/arrow/pull/44990#discussion_r1881734474
##########
cpp/src/arrow/dataset/file_parquet_encryption_test.cc:
##########
@@ -151,31 +159,56 @@ class DatasetEncryptionTestBase : public ::testing::Test {
// Create the dataset
ASSERT_OK_AND_ASSIGN(auto dataset, dataset_factory->Finish());
+ std::vector<std::future<Result<std::shared_ptr<Table>>>> threads;
+
+ // Read dataset above multiple times concurrently to see that is
thread-safe.
// Reuse the dataset above to scan it twice to make sure decryption works
correctly.
- for (size_t i = 0; i < 2; ++i) {
- // Read dataset into table
- ASSERT_OK_AND_ASSIGN(auto scanner_builder, dataset->NewScan());
- ASSERT_OK_AND_ASSIGN(auto scanner, scanner_builder->Finish());
- ASSERT_OK_AND_ASSIGN(auto read_table, scanner->ToTable());
-
- // Verify the data was read correctly
- ASSERT_OK_AND_ASSIGN(auto combined_table, read_table->CombineChunks());
- // Validate the table
- ASSERT_OK(combined_table->ValidateFull());
- AssertTablesEqual(*combined_table, *table_);
+ const size_t attempts = concurrently ? 1000 : 2;
+ for (size_t i = 0; i < attempts; ++i) {
+ if (concurrently) {
+ threads.push_back(std::async(DatasetEncryptionTestBase::read,
dataset));
+ } else {
+ ASSERT_OK_AND_ASSIGN(auto read_table, read(dataset));
+ AssertTablesEqual(*read_table, *table_);
+ }
+ }
+ if (concurrently) {
+ for (auto& thread : threads) {
+ ASSERT_OK_AND_ASSIGN(auto read_table, thread.get());
+ AssertTablesEqual(*read_table, *table_);
+ }
}
}
+ static Result<std::shared_ptr<Table>> read(const std::shared_ptr<Dataset>&
dataset) {
+ // Read dataset into table
+ ARROW_ASSIGN_OR_RAISE(auto scanner_builder, dataset->NewScan());
+ ARROW_ASSIGN_OR_RAISE(auto scanner, scanner_builder->Finish());
+ ARROW_ASSIGN_OR_RAISE(auto read_table, scanner->ToTable());
+
+ // Verify the data was read correctly
+ ARROW_ASSIGN_OR_RAISE(auto combined_table, read_table->CombineChunks());
+ // Validate the table
+ RETURN_NOT_OK(combined_table->ValidateFull());
+ return combined_table;
+ }
+
protected:
std::shared_ptr<fs::FileSystem> file_system_;
std::shared_ptr<Table> table_;
std::shared_ptr<Partitioning> partitioning_;
std::shared_ptr<parquet::encryption::CryptoFactory> crypto_factory_;
std::shared_ptr<parquet::encryption::KmsConnectionConfig>
kms_connection_config_;
+
+ private:
Review Comment:
removed
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]