diff options
author | Luke Chen <luke.chen@mongodb.com> | 2023-02-13 09:36:01 +1100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-12 23:23:59 +0000 |
commit | 01aef4b0a4f9dd02caa5dad310bd721a3565aa8b (patch) | |
tree | 36676c50891530e641b7552f7b37643495eb7bdc | |
parent | 6fd87f49a0f0a2a02d1962c2ab4198b1e71f8df3 (diff) | |
download | mongo-01aef4b0a4f9dd02caa5dad310bd721a3565aa8b.tar.gz |
Import wiredtiger: df67e6c2ba23b52c81a5d33eb2b43f08cda5a593 from branch mongodb-master
ref: 89a336be04..df67e6c2ba
for: 7.0.0-rc0
WT-10580 Rename object_prefix and prefix in Azure Connection Class
4 files changed, 32 insertions, 31 deletions
diff --git a/src/third_party/wiredtiger/ext/storage_sources/azure_store/azure_connection.cpp b/src/third_party/wiredtiger/ext/storage_sources/azure_store/azure_connection.cpp index 21d0267be98..dfd1934653a 100644 --- a/src/third_party/wiredtiger/ext/storage_sources/azure_store/azure_connection.cpp +++ b/src/third_party/wiredtiger/ext/storage_sources/azure_store/azure_connection.cpp @@ -34,10 +34,10 @@ #include <filesystem> #include <iostream> -azure_connection::azure_connection(const std::string &bucket_name, const std::string &obj_prefix) +azure_connection::azure_connection(const std::string &bucket_name, const std::string &bucket_prefix) : _azure_client(Azure::Storage::Blobs::BlobContainerClient::CreateFromConnectionString( std::getenv("AZURE_STORAGE_CONNECTION_STRING"), bucket_name)), - _bucket_name(bucket_name), _object_prefix(obj_prefix) + _bucket_name(bucket_name), _bucket_prefix(bucket_prefix) { // Confirm that we can access the bucket, else fail. bool exists; @@ -51,10 +51,10 @@ azure_connection::azure_connection(const std::string &bucket_name, const std::st // Build a list of all of the objects in the bucket. int azure_connection::list_objects( - const std::string &prefix, std::vector<std::string> &objects, bool list_single) const + const std::string &search_prefix, std::vector<std::string> &objects, bool list_single) const { Azure::Storage::Blobs::ListBlobsOptions blob_parameters; - blob_parameters.Prefix = prefix; + blob_parameters.Prefix = _bucket_prefix + search_prefix; // If list_single is true, set the maximum number of returned blobs in the list_blob_response to // one. if (list_single) @@ -81,7 +81,7 @@ azure_connection::list_objects( int azure_connection::put_object(const std::string &object_key, const std::string &file_path) const { - auto blob_client = _azure_client.GetBlockBlobClient(_object_prefix + object_key); + auto blob_client = _azure_client.GetBlockBlobClient(_bucket_prefix + object_key); // UploadFrom returns a UploadBlockBlobFromResult object describing the state of the updated // block blob on success and throws an exception on failure. try { @@ -99,7 +99,7 @@ azure_connection::put_object(const std::string &object_key, const std::string &f int azure_connection::delete_object(const std::string &object_key) const { - std::string obj = _object_prefix + object_key; + std::string obj = _bucket_prefix + object_key; auto object_client = _azure_client.GetBlobClient(obj); @@ -120,7 +120,7 @@ int azure_connection::read_object( const std::string &object_key, int64_t offset, size_t len, void *buf) const { - auto blob_client = _azure_client.GetBlockBlobClient(_object_prefix + object_key); + auto blob_client = _azure_client.GetBlockBlobClient(_bucket_prefix + object_key); // GetProperties returns a BlobProperties object containing the blob size on success // and throws an exception on failure. @@ -168,6 +168,7 @@ azure_connection::object_exists( const std::string &object_key, bool &exists, size_t &object_size) const { exists = false; + std::string obj = _bucket_prefix + object_key; object_size = 0; std::string obj = _object_prefix + object_key; diff --git a/src/third_party/wiredtiger/ext/storage_sources/azure_store/azure_connection.h b/src/third_party/wiredtiger/ext/storage_sources/azure_store/azure_connection.h index d03c1c96f06..4389f937728 100644 --- a/src/third_party/wiredtiger/ext/storage_sources/azure_store/azure_connection.h +++ b/src/third_party/wiredtiger/ext/storage_sources/azure_store/azure_connection.h @@ -54,9 +54,9 @@ static const std::map<Azure::Core::Http::HttpStatusCode, int32_t> to_errno = { */ class azure_connection { public: - azure_connection(const std::string &bucket_name, const std::string &obj_prefix = ""); + azure_connection(const std::string &bucket_name, const std::string &bucket_prefix = ""); int list_objects( - const std::string &prefix, std::vector<std::string> &objects, bool list_single) const; + const std::string &search_prefix, std::vector<std::string> &objects, bool list_single) const; int put_object(const std::string &object_key, const std::string &file_path) const; int delete_object(const std::string &object_key) const; int read_object(const std::string &object_key, int64_t offset, size_t len, void *buf) const; @@ -64,7 +64,7 @@ class azure_connection { private: const std::string _bucket_name; - const std::string _object_prefix; + const std::string _bucket_prefix; const Azure::Storage::Blobs::BlobContainerClient _azure_client; const int http_to_errno(const Azure::Core::RequestFailedException &e) const; diff --git a/src/third_party/wiredtiger/ext/storage_sources/azure_store/test/test_azure_connection.cpp b/src/third_party/wiredtiger/ext/storage_sources/azure_store/test/test_azure_connection.cpp index f020cc787d0..8879720572c 100644 --- a/src/third_party/wiredtiger/ext/storage_sources/azure_store/test/test_azure_connection.cpp +++ b/src/third_party/wiredtiger/ext/storage_sources/azure_store/test/test_azure_connection.cpp @@ -52,19 +52,19 @@ randomize_test_prefix() REQUIRE(std::strftime(time_str, sizeof(time_str), "%F-%H-%M-%S", std::localtime(&t)) != 0); - std::string obj_prefix("azuretest/unit/"); // To be concatenated with a random string. + std::string bucket_prefix("azuretest/unit/"); // To be concatenated with a random string. - obj_prefix += time_str; + bucket_prefix += time_str; // Create a random device and use it to generate a random seed to initialize the generator. std::random_device my_random_device; unsigned seed = my_random_device(); std::default_random_engine my_random_engine(seed); - obj_prefix += '/' + std::to_string(my_random_engine()); - obj_prefix += "--"; + bucket_prefix += '/' + std::to_string(my_random_engine()); + bucket_prefix += "--"; - return obj_prefix; + return bucket_prefix; } TEST_CASE("Testing Azure Connection Class", "azure-connection") @@ -74,9 +74,9 @@ TEST_CASE("Testing Azure Connection Class", "azure-connection") bool exists = false; size_t object_size = 0; - std::string obj_prefix = randomize_test_prefix(); + std::string bucket_prefix = randomize_test_prefix(); - azure_connection conn = azure_connection("myblobcontainer1", obj_prefix); + azure_connection conn = azure_connection("myblobcontainer1", bucket_prefix); azure_connection conn_bad = azure_connection("myblobcontainer1", "bad_prefix_"); std::vector<std::pair<std::string, std::string>> blob_objects; @@ -93,7 +93,7 @@ TEST_CASE("Testing Azure Connection Class", "azure-connection") // Add objects into the container. for (auto pair : blob_objects) { - auto blob_client = azure_client.GetBlockBlobClient(obj_prefix + pair.first); + auto blob_client = azure_client.GetBlockBlobClient(bucket_prefix + pair.first); blob_client.UploadFrom(create_file(pair.first, pair.second)); } @@ -122,20 +122,20 @@ TEST_CASE("Testing Azure Connection Class", "azure-connection") std::vector<std::string> objects; // No matching objects. Object size should be 0. - REQUIRE(conn.list_objects(obj_prefix + non_exist_object_key, objects, false) == 0); + REQUIRE(conn.list_objects(non_exist_object_key, objects, false) == 0); REQUIRE(objects.size() == 0); // No matching objects with list single functionality. Object size should be 0. - REQUIRE(conn.list_objects(obj_prefix + non_exist_object_key, objects, true) == 0); + REQUIRE(conn.list_objects(non_exist_object_key, objects, true) == 0); REQUIRE(objects.size() == 0); // List all objects. Object size should be 2. - REQUIRE(conn.list_objects(obj_prefix + object_name, objects, false) == 0); + REQUIRE(conn.list_objects(object_name, objects, false) == 0); REQUIRE(objects.size() == blob_objects.size()); objects.clear(); // List single. Object size should be 1. - REQUIRE(conn.list_objects(obj_prefix + object_name, objects, true) == 0); + REQUIRE(conn.list_objects(object_name, objects, true) == 0); REQUIRE(objects.size() == 1); objects.clear(); @@ -143,7 +143,7 @@ TEST_CASE("Testing Azure Connection Class", "azure-connection") SECTION("Test delete functionality for Azure.", "[azure-connection]") { - auto blob_client = azure_client.GetBlockBlobClient(obj_prefix + object_name + "1"); + auto blob_client = azure_client.GetBlockBlobClient(bucket_prefix + object_name + "1"); std::vector<std::string> container; blob_client.UploadFrom(create_file(object_name + "1", payload)); @@ -160,7 +160,7 @@ TEST_CASE("Testing Azure Connection Class", "azure-connection") } // Check that the object does not exist in the container. - REQUIRE(std::find(container.begin(), container.end(), obj_prefix + object_name + "1") == + REQUIRE(std::find(container.begin(), container.end(), bucket_prefix + object_name + "1") == std::end(container)); } @@ -171,7 +171,7 @@ TEST_CASE("Testing Azure Connection Class", "azure-connection") REQUIRE(conn.put_object(object_name + "1", path) == 0); - auto blob_client = azure_client.GetBlockBlobClient(obj_prefix + object_name + "1"); + auto blob_client = azure_client.GetBlockBlobClient(bucket_prefix + object_name + "1"); // Test that putting an object that doesn't exist locally returns -1. REQUIRE(conn.put_object(non_exist_object_key, non_exist_object_key + ".txt") == -1); @@ -182,11 +182,11 @@ TEST_CASE("Testing Azure Connection Class", "azure-connection") } // Check that the object exists in the container. - REQUIRE(std::find(container.begin(), container.end(), obj_prefix + object_name + "1") != + REQUIRE(std::find(container.begin(), container.end(), bucket_prefix + object_name + "1") != std::end(container)); // Check that when putting an object fails that object is not in the container. - REQUIRE(std::find(container.begin(), container.end(), obj_prefix + non_exist_object_key) == - std::end(container)); + REQUIRE(std::find(container.begin(), container.end(), + bucket_prefix + non_exist_object_key) == std::end(container)); blob_client.Delete(); } @@ -224,12 +224,12 @@ TEST_CASE("Testing Azure Connection Class", "azure-connection") // Delete the objects we added earlier so we have no objects in the container. for (auto pair : blob_objects) { - auto blob_client = azure_client.GetBlockBlobClient(obj_prefix + pair.first); + auto blob_client = azure_client.GetBlockBlobClient(bucket_prefix + pair.first); blob_client.Delete(); } // Sanity check that nothing exists. Azure::Storage::Blobs::ListBlobsOptions blob_parameters; - blob_parameters.Prefix = obj_prefix; + blob_parameters.Prefix = bucket_prefix; REQUIRE(azure_client.ListBlobs(blob_parameters).Blobs.size() == 0); } diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index a9c12587639..dffa76d4b34 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-master", - "commit": "89a336be04c4f934524963880c014ae3ec6b1064" + "commit": "df67e6c2ba23b52c81a5d33eb2b43f08cda5a593" } |