felipecrv commented on code in PR #39207:
URL: https://github.com/apache/arrow/pull/39207#discussion_r1425875126
##########
cpp/src/arrow/filesystem/azurefs_test.cc:
##########
@@ -193,51 +265,123 @@ TEST(AzureFileSystem, OptionsCompare) {
EXPECT_TRUE(options.Equals(options));
}
-class AzureFileSystemTest : public ::testing::Test {
+struct PreexistingData {
+ public:
+ using RNG = std::mt19937_64;
+
public:
+ const std::string container_name;
+ static constexpr char const* kObjectName = "test-object-name";
+
+ static constexpr char const* kLoremIpsum = R"""(
+Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
+incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
+nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
+culpa qui officia deserunt mollit anim id est laborum.
+)""";
+
+ public:
+ explicit PreexistingData(RNG& rng) :
container_name{RandomContainerName(rng)} {}
+
+ // Accessors
+ std::string ContainerPath() const { return container_name + '/'; }
+ std::string ObjectPath() const { return ContainerPath() + kObjectName; }
+ std::string NotFoundObjectPath() const { return ContainerPath() +
"not-found"; }
+
+ std::string RandomDirectoryPath(RNG& rng) {
+ return internal::ConcatAbstractPath(container_name,
RandomDirectoryName(rng));
+ }
+
+ // Utilities
+
+ static std::string RandomContainerName(RNG& rng) { return RandomChars(32,
rng); }
+ static std::string RandomDirectoryName(RNG& rng) { return RandomChars(32,
rng); }
+
+ static std::string RandomLine(int lineno, std::size_t width, RNG& rng) {
+ auto line = std::to_string(lineno) + ": ";
+ line += RandomChars(width - line.size() - 1, rng);
+ line += '\n';
+ return line;
+ }
+
+ static std::size_t RandomIndex(std::size_t end, RNG& rng) {
+ return std::uniform_int_distribution<std::size_t>(0, end - 1)(rng);
+ }
+
+ static std::string RandomChars(std::size_t count, RNG& rng) {
+ auto const fillers = std::string("abcdefghijlkmnopqrstuvwxyz0123456789");
+ std::uniform_int_distribution<std::size_t> d(0, fillers.size() - 1);
+ std::string s;
+ std::generate_n(std::back_inserter(s), count, [&] { return
fillers[d(rng)]; });
+ return s;
+ }
+};
+
+class AzureFileSystemTest : public ::testing::Test {
+ protected:
+ // Set in constructor
+ std::mt19937_64 rng_;
+
+ // Set in SetUp()
+ int64_t debug_log_start_ = 0;
+ bool set_up_succeeded_ = false;
+ AzureOptions options_;
+
std::shared_ptr<FileSystem> fs_;
std::unique_ptr<Blobs::BlobServiceClient> blob_service_client_;
- std::unique_ptr<Files::DataLake::DataLakeServiceClient>
datalake_service_client_;
- AzureOptions options_;
- std::mt19937_64 generator_;
- std::string container_name_;
- bool suite_skipped_ = false;
+ std::unique_ptr<DataLake::DataLakeServiceClient> datalake_service_client_;
- AzureFileSystemTest() : generator_(std::random_device()()) {}
+ public:
+ AzureFileSystemTest() : rng_(std::random_device()()) {}
Review Comment:
We want that so that we don't create container names that collide between
test runs. Test cleanups try to delete all containers from the storage account,
but it's never guaranteed.
--
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]