Skip to content

Enable some storage test cases #4856

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

Merged
merged 5 commits into from
Aug 9, 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_789a3955d8"
"Tag": "cpp/storage_62e8551aa8"
}
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,10 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_FALSE(userDelegationKey.Value.empty());
}

TEST_F(BlobServiceClientTest, DISABLED_RenameBlobContainer)
TEST_F(BlobServiceClientTest, RenameBlobContainer_PLAYBACKONLY_)
{
auto serviceClient = *m_blobServiceClient;
const std::string prefix = RandomString();
const std::string prefix = LowercaseRandomString() + "2";

const std::string srcContainerName = prefix + "src";
auto srcContainerClient = serviceClient.CreateBlobContainer(srcContainerName).Value;
Expand All @@ -481,13 +481,12 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_THROW(srcContainerClient.GetProperties(), StorageException);
EXPECT_NO_THROW(destContainerClient.GetProperties());

Blobs::BlobLeaseClient leaseClient(
destContainerClient, Blobs::BlobLeaseClient::CreateUniqueLeaseId());
Blobs::BlobLeaseClient leaseClient(destContainerClient, RandomUUID());
leaseClient.Acquire(std::chrono::seconds(60));

const std::string destContainerName2 = prefix + "dest2";
Blobs::RenameBlobContainerOptions renameOptions;
renameOptions.SourceAccessConditions.LeaseId = Blobs::BlobLeaseClient::CreateUniqueLeaseId();
renameOptions.SourceAccessConditions.LeaseId = RandomUUID();
EXPECT_THROW(
serviceClient.RenameBlobContainer(destContainerName, destContainerName2, renameOptions),
StorageException);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ namespace Azure { namespace Storage { namespace Test {
}
}

TEST_F(BlockBlobClientTest, DISABLED_LastAccessTime)
TEST_F(BlockBlobClientTest, LastAccessTime)
{
auto blobClient = *m_blockBlobClient;

Expand Down Expand Up @@ -1101,7 +1101,7 @@ namespace Azure { namespace Storage { namespace Test {
std::this_thread::sleep_for(ImmutabilityMaxLength);
}

TEST_F(BlockBlobClientTest, DISABLED_LegalHold)
TEST_F(BlockBlobClientTest, LegalHold_PLAYBACKONLY_)
{
const auto testName = m_blobName;
auto blobClient = *m_blockBlobClient;
Expand Down
10 changes: 10 additions & 0 deletions sdk/storage/azure-storage-common/test/ut/test_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ namespace Azure { namespace Storage { namespace Test {
std::seed_seq seedSeq(seedStr.begin(), seedStr.end());
m_randomGenerator.seed(seedSeq);
}
const std::string playbackOnlyToken = PlaybackOnlyToken;
const std::string testName = m_testContext.GetTestName();
if (testName.length() >= playbackOnlyToken.length()
&& testName.substr(testName.length() - playbackOnlyToken.length()) == playbackOnlyToken)
{
if (m_testContext.IsLiveMode())
{
SkipTest();
}
}
}

void StorageTest::TearDown()
Expand Down
26 changes: 17 additions & 9 deletions sdk/storage/azure-storage-common/test/ut/test_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <azure/storage/common/internal/constants.hpp>
#include <azure/storage/common/storage_common.hpp>

#include <cctype>
#include <chrono>
#include <cstdint>
#include <limits>
Expand Down Expand Up @@ -55,17 +56,22 @@ namespace Azure { namespace Storage {
*/
std::string GetIdentifier() const
{
size_t MaxLength = 63;
std::string name = m_testContext.GetTestSuiteName() + m_testContext.GetTestName();
if (name[0] == '-')
const size_t MaxLength = 63;
const std::string name = m_testContext.GetTestSuiteName() + m_testContext.GetTestName();
std::string formattedName;
for (const auto c : name)
{
name = name.substr(1);
if (std::isalnum(c))
{
formattedName += c;
}
if (formattedName.length() >= MaxLength)
{
break;
}
}
if (name.length() > MaxLength)
{
name.resize(MaxLength);
}
return name;

return formattedName;
}

/**
Expand Down Expand Up @@ -173,6 +179,8 @@ namespace Azure { namespace Storage {

private:
std::mt19937_64 m_randomGenerator;

constexpr static const char* PlaybackOnlyToken = "_PLAYBACKONLY_";
};

constexpr inline unsigned long long operator""_KB(unsigned long long x) { return x * 1024; }
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/test-resources-post.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ New-AzStorageEncryptionScope -ResourceGroupName $ResourceGroupName -StorageAccou

Enable-AzStorageBlobDeleteRetentionPolicy -ResourceGroupName $ResourceGroupName -StorageAccountName $DeploymentOutputs['DATALAKE_ACCOUNT_NAME'] -RetentionDays 7

Enable-AzStorageBlobLastAccessTimeTracking -ResourceGroupName $ResourceGroupName -StorageAccountName $DeploymentOutputs['ACCOUNT_NAME'] -PassThru

# This script is used to wait until XCache is refreshed for the service properties (30s), and role assignment takes effect (300s).

Start-Sleep -s 300