plusplusjiajia commented on code in PR #898:
URL: https://github.com/apache/iceberg-cpp/pull/898#discussion_r4110391219
##########
src/iceberg/test/arrow_s3_file_io_test.cc:
##########
@@ -237,6 +239,69 @@ TEST_F(ArrowS3FileIOTest, WarnsWhenNoCredentialApplies) {
EXPECT_TRUE(HasWarning(*logger));
}
+TEST_F(ArrowS3FileIOTest, DeleteFilesDispatchesAcrossCredentialPrefixes) {
+ auto result = MakeS3FileIO({});
+ ASSERT_THAT(result, IsOk());
+ auto* credentialed = result.value()->AsSupportsStorageCredentials();
+ ASSERT_NE(credentialed, nullptr);
+
+ auto credential = [](std::string_view prefix, std::string_view access_key) {
+ return StorageCredential{
+ .prefix = std::string(prefix),
+ .config = {{std::string(S3Properties::kAccessKeyId),
std::string(access_key)},
+ {std::string(S3Properties::kSecretAccessKey), "secret"}}};
+ };
+ ASSERT_THAT(credentialed->SetStorageCredentials({credential("s3://bucket-a",
"key-a"),
+ credential("s3://bucket-b",
"key-b")}),
+ IsOk());
+
+ auto status = result.value()->DeleteFiles({"s3://bucket-a/%ZZ.parquet",
+ "s3://bucket-a/second.parquet",
+ "s3://bucket-b/other.parquet"});
+ EXPECT_THAT(status, HasErrorMessage("Cannot parse URI"));
+}
+
+TEST_F(ArrowS3FileIOTest, OperationsSurviveConcurrentCredentialInstalls) {
+ auto result = MakeS3FileIO({});
+ ASSERT_THAT(result, IsOk());
+ auto* credentialed = result.value()->AsSupportsStorageCredentials();
+ ASSERT_NE(credentialed, nullptr);
+
+ auto credential = [](std::string_view access_key) {
+ return StorageCredential{
+ .prefix = "s3://bucket",
+ .config = {{std::string(S3Properties::kAccessKeyId),
std::string(access_key)},
+ {std::string(S3Properties::kSecretAccessKey), "secret"}}};
+ };
+ ASSERT_THAT(credentialed->SetStorageCredentials({credential("first")}),
IsOk());
+
+ std::atomic<bool> stop = false;
+ std::atomic<int> failures = 0;
+ std::vector<std::thread> operations;
+ operations.reserve(4);
+ for (int i = 0; i < 4; ++i) {
+ operations.emplace_back([&] {
+ while (!stop.load()) {
+ if (!result.value()->NewInputFile("s3://bucket/key").has_value()) {
Review Comment:
@wgtmac Thanks, added InputFileOutlivesCredentialInstall: it reads one
InputFile before and after an install.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]