Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage tests improvement #4382

Merged
merged 3 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/storage/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/storage",
"Tag": "cpp/storage_fc079eacac"
"Tag": "cpp/storage_925cef0316"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Jinming-Hu marked this conversation as resolved.
Show resolved Hide resolved
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();
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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)
Expand Down Expand Up @@ -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());

Expand Down