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

Add Live TestMode and Skip Recording Concepts #6134

Closed
wants to merge 29 commits into from

Conversation

alzimmermsft
Copy link
Member

@alzimmermsft alzimmermsft commented Nov 1, 2019

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
Member Author

/azp run java - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@alzimmermsft
Copy link
Member Author

/azp run java - storage - tests

@azure-pipelines
Copy link

Azure Pipelines failed to run 1 pipeline(s).

@alzimmermsft
Copy link
Member Author

/azp run java - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@alzimmermsft
Copy link
Member Author

/azp run java - appconfiguration - tests

@alzimmermsft
Copy link
Member Author

/azp run java - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@alzimmermsft
Copy link
Member Author

/azp run java - storage - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@sima-zhu sima-zhu left a comment

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
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
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
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
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
Member Author

/azp run java - storage - tests

@azure-pipelines
Copy link

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
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
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
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