Storage tests improvement (#4382)

This commit is contained in:
JinmingHu 2023-02-23 11:10:27 +08:00 committed by GitHub
parent 78eabdc1af
commit 737037d1af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 22 deletions

View File

@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/storage",
"Tag": "cpp/storage_fc079eacac"
"Tag": "cpp/storage_925cef0316"
}

View File

@ -26,8 +26,8 @@ namespace Azure { namespace Storage { namespace Test {
m_appendBlobClient = std::make_shared<Blobs::AppendBlobClient>(
m_blobContainerClient->GetAppendBlobClient(m_blobName));
m_appendBlobClient->Create();
std::vector<uint8_t> blobContent1(static_cast<size_t>(1_KB), 'x');
std::vector<uint8_t> blobContent2(static_cast<size_t>(512), 'a');
std::vector<uint8_t> blobContent1 = RandomBuffer(static_cast<size_t>(1_KB));
std::vector<uint8_t> blobContent2 = RandomBuffer(512);
auto blobContent = Azure::Core::IO::MemoryBodyStream(blobContent1.data(), blobContent1.size());
m_appendBlobClient->AppendBlock(blobContent);
blobContent = Azure::Core::IO::MemoryBodyStream(blobContent2.data(), blobContent2.size());

View File

@ -538,7 +538,7 @@ namespace Azure { namespace Storage { namespace Test {
}
{
std::string containerName = GetLowercaseIdentifier() + "1";
std::string blobName = GetTestName() + "1";
std::string blobName = RandomString() + "1";
Blobs::BlobClientOptions options;
options.EncryptionScope = testEncryptionScope;
auto containerClient2 = GetBlobContainerClientForTest(containerName, options);
@ -581,7 +581,7 @@ namespace Azure { namespace Storage { namespace Test {
containerClient2.Delete();
}
{
std::string blobName = GetTestName() + "2";
std::string blobName = RandomString() + "2";
Blobs::BlobClientOptions options;
options.EncryptionScope = testEncryptionScope;
auto appendBlobClient

View File

@ -48,7 +48,7 @@ namespace Azure { namespace Storage { namespace Test {
m_blobUploadOptions.HttpHeaders.ContentEncoding = "identity";
m_blobUploadOptions.HttpHeaders.ContentHash.Value.clear();
m_blobUploadOptions.AccessTier = Azure::Storage::Blobs::Models::AccessTier::Hot;
m_blobContent = std::vector<uint8_t>(static_cast<size_t>(1_KB), 'x');
m_blobContent = RandomBuffer(static_cast<size_t>(1_KB));
auto blobContent
= Azure::Core::IO::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
m_blockBlobClient->Upload(blobContent, m_blobUploadOptions);
@ -187,7 +187,7 @@ namespace Azure { namespace Storage { namespace Test {
tags["key2"] = "value2";
tags["key3 +-./:=_"] = "v1 +-./:=_";
std::vector<uint8_t> blobContent(10, 'a');
std::vector<uint8_t> blobContent = RandomBuffer(10);
{
Blobs::UploadBlockBlobOptions options;
options.Tags = tags;
@ -1221,7 +1221,7 @@ namespace Azure { namespace Storage { namespace Test {
TEST_F(BlockBlobClientTest, UploadFromUri)
{
auto srcBlobClient = *m_blockBlobClient;
std::vector<uint8_t> blobContent(100, 'a');
std::vector<uint8_t> blobContent = RandomBuffer(100);
srcBlobClient.UploadFrom(blobContent.data(), blobContent.size());
std::map<std::string, std::string> srcTags;
srcTags["srctags"] = "a1212";
@ -1302,7 +1302,7 @@ namespace Azure { namespace Storage { namespace Test {
{
auto blobClient = *m_blockBlobClient;
const std::vector<uint8_t> content(static_cast<size_t>(1), 'a');
const std::vector<uint8_t> content = RandomBuffer(1);
const std::string blockId = Base64EncodeText(std::string(64, '0'));
auto blockContent = Azure::Core::IO::MemoryBodyStream(content.data(), content.size());
blobClient.StageBlock(blockId, blockContent);

View File

@ -29,7 +29,7 @@ namespace Azure { namespace Storage { namespace Test {
m_blobName = RandomString();
m_pageBlobClient = std::make_shared<Blobs::PageBlobClient>(
m_blobContainerClient->GetPageBlobClient(m_blobName));
m_blobContent = std::vector<uint8_t>(static_cast<size_t>(1_KB), 'x');
m_blobContent = RandomBuffer(static_cast<size_t>(1_KB));
auto blobContent
= Azure::Core::IO::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
m_pageBlobClient->Create(2_KB);

View File

@ -52,13 +52,11 @@ namespace Azure { namespace Storage { namespace Test {
}
};
m_testContext.RenameTest(GetTestName());
auto peekPolicyPtr = std::make_unique<PeekHttpRequestPolicy>(callback);
Blobs::BlobClientOptions clientOptions = InitClientOptions<Blobs::BlobClientOptions>();
clientOptions.PerRetryPolicies.emplace_back(std::move(peekPolicyPtr));
auto containerClient = Azure::Storage::Blobs::BlobContainerClient::CreateFromConnectionString(
StandardStorageConnectionString(), GetTestNameLowerCase(), clientOptions);
StandardStorageConnectionString(), LowercaseRandomString(), clientOptions);
containerClient.DeleteIfExists();
EXPECT_FALSE(timeout.HasValue());

View File

@ -217,8 +217,8 @@ namespace Azure { namespace Storage { namespace Test {
TEST_F(DataLakeFileClientTest, FileDataActions)
{
const int32_t bufferSize = 4 * 1024; // 4KB data size
std::vector<uint8_t> buffer(bufferSize, 'x');
const int32_t bufferSize = 10;
std::vector<uint8_t> buffer = RandomBuffer(bufferSize);
auto bufferStream = std::make_unique<Azure::Core::IO::MemoryBodyStream>(
Azure::Core::IO::MemoryBodyStream(buffer));
auto properties1 = m_fileClient->GetProperties();
@ -468,8 +468,8 @@ namespace Azure { namespace Storage { namespace Test {
TEST_F(DataLakeFileClientTest, FileReadReturns)
{
const int32_t bufferSize = 4 * 1024; // 4KB data size
std::vector<uint8_t> buffer(bufferSize, 'x');
const int32_t bufferSize = 20;
std::vector<uint8_t> buffer = RandomBuffer(bufferSize);
auto bufferStream = std::make_unique<Azure::Core::IO::MemoryBodyStream>(
Azure::Core::IO::MemoryBodyStream(buffer));
std::string newFileName("fileForTest");

View File

@ -45,8 +45,6 @@ namespace Azure { namespace Storage { namespace Test {
StorageTest::SetUp();
m_options = InitClientOptions<Queues::QueueClientOptions>();
m_testName = GetTestName();
m_testNameLowercase = GetTestNameLowerCase();
m_queueServiceClient = std::make_shared<Queues::QueueServiceClient>(
Queues::QueueServiceClient::CreateFromConnectionString(
StandardStorageConnectionString(), m_options));
@ -55,8 +53,6 @@ namespace Azure { namespace Storage { namespace Test {
std::shared_ptr<Queues::QueueServiceClient> m_queueServiceClient;
Queues::QueueClientOptions m_options;
std::string m_testName;
std::string m_testNameLowercase;
};
TEST_F(QueueServiceClientTest, ListQueues)
@ -268,7 +264,7 @@ namespace Azure { namespace Storage { namespace Test {
TEST_F(QueueServiceClientTest, CreateDeleteQueue)
{
std::string queueName = m_testNameLowercase;
std::string queueName = LowercaseRandomString();
auto queueClient = m_queueServiceClient->CreateQueue(queueName);
EXPECT_NO_THROW(queueClient.Value.GetProperties());