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

Recordings for storage #3194

Merged
merged 21 commits into from
Jan 18, 2022
Merged

Recordings for storage #3194

merged 21 commits into from
Jan 18, 2022

Conversation

vhvb1989
Copy link
Member

@vhvb1989 vhvb1989 commented Dec 17, 2021

Recordings for storage

Recordings for storage blobs
.vscode/cspell.json Outdated Show resolved Hide resolved
sdk/core/azure-core-test/inc/azure/core/test/test_base.hpp Outdated Show resolved Hide resolved
sdk/core/ci.yml Show resolved Hide resolved
@vhvb1989 vhvb1989 self-assigned this Dec 30, 2021
@vhvb1989
Copy link
Member Author

/azp run cpp - storage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vhvb1989 vhvb1989 marked this pull request as ready for review January 6, 2022 00:11
@vhvb1989 vhvb1989 requested a review from gearama January 6, 2022 00:11
@vhvb1989 vhvb1989 added Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files) test-enhancement test-reliability Issue that causes tests to be unreliable labels Jan 6, 2022
@vhvb1989
Copy link
Member Author

vhvb1989 commented Jan 6, 2022

/azp run cpp - storage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@Jinming-Hu Jinming-Hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me confirm one thing first, when running in LIVE mode, are different pipeline (Linux, Windows x64, Windows x86 etc.) running against the same storage account or different storage accounts? Since you've removed randomness, there could be problems if they run against the same account.

auto appendBlobClient = Azure::Storage::Blobs::AppendBlobClient::CreateFromConnectionString(
StandardStorageConnectionString(), m_containerName, RandomString());

auto const testName(GetTestName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes it obscure to use auto keyword here. I cannot figure out what the type is at the first glance. How about

const std::string testName = GetTestName();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const std::string testName(GetTestName()); that's how I did other places.

@vhvb1989
Copy link
Member Author

vhvb1989 commented Jan 6, 2022

Let me confirm one thing first, when running in LIVE mode, are different pipeline (Linux, Windows x64, Windows x86 etc.) running against the same storage account or different storage accounts? Since you've removed randomness, there could be problems if they run against the same account.

Yes, each pipeline creates an instance of storage, so, it won't be collision 💥

@vhvb1989
Copy link
Member Author

vhvb1989 commented Jan 6, 2022

Finally got coverage for cpp - storage - ci:
https://dev.azure.com/azure-sdk/public/_build/results?buildId=1277527&view=codecoverage-tab

@Jinming-Hu
Copy link
Member

Finally got coverage for cpp - storage - ci: https://dev.azure.com/azure-sdk/public/_build/results?buildId=1277527&view=codecoverage-tab

The coverage looks real good.

@vhvb1989
Copy link
Member Author

vhvb1989 commented Jan 6, 2022

Finally got coverage for cpp - storage - ci: https://dev.azure.com/azure-sdk/public/_build/results?buildId=1277527&view=codecoverage-tab

The coverage looks real good.

It's a little bit below the real coverage from cpp - storage ( live test ) because some tests are LIVEONLY like sas and some tests depending on datetimes comparison

Copy link
Member

@Jinming-Hu Jinming-Hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vhvb1989 ,this is a huge PR and it may take quite some time for me to review it. Unfortunately, I have some higher priority task to do recently. So maybe I cannot review it until Feb.

@vhvb1989
Copy link
Member Author

vhvb1989 commented Jan 7, 2022

Hi @vhvb1989 ,this is a huge PR and it may take quite some time for me to review it. Unfortunately, I have some higher priority task to do recently. So maybe I cannot review it until Feb.

Can you hold on to any making changes to Storage tests? Otherwise there would be lots of conflicts.

Also? Since all these changes are for tests only. Can we just notice that the Coverage is still the same for approving? And then you can gradually keep reviewing in the future and I can address any detail you see in there.

You know, waiting until Feb will be hard to keep this PR on sync

@vhvb1989
Copy link
Member Author

vhvb1989 commented Jan 7, 2022

/azp run cpp - storage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Jinming-Hu
Copy link
Member

All right, I'll try to spare some time to review this PR before Feb.

@vhvb1989
Copy link
Member Author

/azp run cpp - storage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@Jinming-Hu Jinming-Hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep reviewing the rest of the PR tomorrow

@@ -207,7 +207,7 @@ jobs:
Location: ${{ parameters.Location }}
SubscriptionConfiguration: ${{ parameters.SubscriptionConfiguration }}

- script: ctest -C Debug --tests-regex ${{ parameters.CtestRegex }} --no-compress-output -T Test
- script: ctest -V -C Debug --tests-regex ${{ parameters.CtestRegex }} --no-compress-output -T Test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR


- RECORD

When setting `AZURE_TEST_MODE=RECORD`, test cases will run the as when running `LIVE`. All the AZURE service network responses are recorded in a json file within the /recordings folder from the /test/ut directory. Use this test mode to generate pre-recorded data to be used on `PLAYBACK` mode.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test cases will run the as when running LIVE.

extra the?

*/
class WithMemoryBodyStream : public Azure::Core::IO::BodyStream {
private:
std::vector<uint8_t> m_memory;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to make a copy here.

}

public:
CircularBodyStream(size_t size, uint8_t fillWith)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is used in storage tests. But buffer with the same byte or with circular data is far from ideal for storage testing scenario. Consider using runtime-generating random data that only depends on seed and offset. Here is a good example. We always use it for storage tests.

// than 10Kb) and download it later.
// The request for upload will contain the payload to upload.
// Then the request for download will use the symbol to generate a bodyStream.
std::unique_ptr<uint8_t> m_symbol;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since m_symbol is never null, why do we need std::unique_ptr here? How about just

    uint8_t m_symbol;


public:
const static Azure::ETag DummyETag;
const static Azure::ETag DummyETag2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move DummyMd5 and DummyCrc64 here.

std::string name(m_testContext.GetTestSuiteName() + m_testContext.GetTestName());
// Make sure the name is less than 63 characters long
auto const nameSize = name.size();
size_t const maxContainerNameSize = 63;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, we have a naming rule for const variables. They should start with uppercase letters.

return x * 1024 * 1024 * 1024 * 1024;
}

class CryptFunctionsTest : public StorageTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just use StorageTest if the definition is empty?

Comment on lines +200 to +207
template <class T> T InitClientOptions()
{
// Run instrumentation before creating the client
T options;
PrepareOptions(options);
return options;
}

Copy link
Member

@Jinming-Hu Jinming-Hu Jan 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need template here?

How about just

void InitClientOptions(Azure::Core::_internal::ClientOptions& options) {
  PrepareOptions(options);
}

Or mayber we should make PrepareOptions protected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to enable InitClientOptions() to be called without creating the options first. Like:

auto client = BlobClient(url, credential, InitClientOptions());

otherwise, the pattern would be
BlobClientOptions options;
InitClientOptions(options); // The name would change to PreparaClientOptions
auto client = BlobClient(url, credential, options);

Comment on lines +187 to +196
Azure::Storage::Blobs::BlobClientOptions options;

m_client = InitTestClient<
Azure::Storage::Blobs::BlobContainerClient,
Azure::Storage::Blobs::BlobClientOptions>(
Azure::Storage::Blobs::BlobContainerClient::CreateFromConnectionString(
StandardStorageConnectionString(), m_containerName)
.GetUrl(),
&m_credential,
options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need InitTestClient at all in the first place. What's the value of this function, with all the complexity of template stuff?

Azure::Storage::Blobs::BlobClientOptions options;
InitClientOptions(options);
m_client = std::make_unique<Azure::Storage::Blobs::BlobContainerClient>(
            Azure::Storage::Blobs::BlobContainerClient::CreateFromConnectionString(
                StandardStorageConnectionString(), m_containerName).GetUrl(),
            &m_credential,
            options);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InitTestClient<ClientClass, OptionsClass>() make it possible to re-use this call from any service. It is useful for any test case that creates a client with a tokenCredential.

The method is not a must-call method, anyway. From the test case, we can call InitClientOptions and InitCredential as well.

At the end, what we need is to let the test-framework to take care of updating the client options and credentials to support playback.

Copy link
Member

@Jinming-Hu Jinming-Hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quit. This PR is too complicated. Let's just merge it. What's the worst thing that can happen anyway.

@vhvb1989
Copy link
Member Author

/azp run cpp - storage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vhvb1989
Copy link
Member Author

/azp run cpp - storage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vhvb1989
Copy link
Member Author

/azp run cpp - storage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files) test-enhancement test-reliability Issue that causes tests to be unreliable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants