Skip to content

Add Live TestMode and Skip Recording Concepts#6134

Closed
alzimmermsft wants to merge 29 commits into
Azure:masterfrom
alzimmermsft:AzCore_AddLiveMode
Closed

Add Live TestMode and Skip Recording Concepts#6134
alzimmermsft wants to merge 29 commits into
Azure:masterfrom
alzimmermsft:AzCore_AddLiveMode

Conversation

@alzimmermsft

@alzimmermsft alzimmermsft commented Nov 1, 2019

Copy link
Copy Markdown
Member

Implements #5174

This PR introduces two new concepts to the Azure Core testing framework.

A new value LIVE was added to the TestMode enum. This state is used to indicate that tests should be ran against a live service without recording the network calls, this is meant to help reduce the overhead of testing by removing the recording process. The use case for this change is to remove recording tests during the nightly validation and in cases where sensitive information that hasn't been masked is being sent during testing.

A new test annotation, DoNotRecord, was added. This annotation is meant to be used with tests that don't want their network calls record or they make no network calls but surrounding testing infrastructure does. This annotation has an optional parameter of skipInPlayback which is meant to be used with tests that make network calls but won't be recorded due to the inability to redact sensitive data or they call into code paths that cannot be mocked.

@alzimmermsft
alzimmermsft requested a review from g2vinay November 1, 2019 20:56
@alzimmermsft

Copy link
Copy Markdown
Member Author

/azp run java - storage - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@alzimmermsft

Copy link
Copy Markdown
Member Author

/azp run java - storage - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines failed to run 1 pipeline(s).

@alzimmermsft

Copy link
Copy Markdown
Member Author

/azp run java - storage - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@alzimmermsft

Copy link
Copy Markdown
Member Author

/azp run java - appconfiguration - tests

@alzimmermsft

Copy link
Copy Markdown
Member Author

/azp run java - storage - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@alzimmermsft

Copy link
Copy Markdown
Member Author

/azp run java - storage - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@sima-zhu sima-zhu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we actually need the doNotRecord flag?

Is this a duplicate concept with LIVE?

Can I have an example which RECORD or PLAYBACK have to set DoNotRecord to true but it does not apply to LIVE?

return Objects.requireNonNull(client);
if (testMode == TestMode.PLAYBACK && !testRunVerifier.doNotRecordTest()) {
clientBuilder.httpClient(interceptorManager.getPlaybackClient());
} else if (testMode == TestMode.RECORD && !testRunVerifier.doNotRecordTest()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the reason to check test testRunVerifier.doNotRecordTest()?

If we don't want record, can we simply setup env to LIVE

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LIVE and DoNotRecord serve slightly different but related purposes. LIVE won't record anything but the DoNotRecord annotation is meant for tests that shouldn't have any data recorded.

if (testMode == TestMode.PLAYBACK && !testRunVerifier.doNotRecordTest()) {
clientBuilder.httpClient(interceptorManager.getPlaybackClient());
} else if (testMode == TestMode.RECORD && !testRunVerifier.doNotRecordTest()) {
clientBuilder.httpClient(new NettyAsyncHttpClientBuilder().wiretap(true).build())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This one applies to LIVE mode. Better to put in both RECORD and LIVE

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LIVE won't need Netty wiretap set to true as it doesn't need to inspect the request or response for recording purposes.

@alzimmermsft

Copy link
Copy Markdown
Member Author

/azp run java - storage - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@Azure Azure deleted a comment from azure-pipelines Bot Nov 20, 2019
*/
@Retention(RUNTIME)
@Target({METHOD})
public @interface DoNotRecord {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just for my understanding, why would any test run only in live mode but shouldn't be recorded?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Tests that contain information that cannot be recorded into a playback JSON such as random UUIDs generated by methods called.

@alzimmermsft

Copy link
Copy Markdown
Member Author

Closing in favor of #6671

@alzimmermsft
alzimmermsft deleted the AzCore_AddLiveMode branch March 20, 2020 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants