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

[MetricsAdvisor] Added tests for Data Feed CRUD operations (1/4) #17721

Merged
merged 1 commit into from
Jan 4, 2021

Conversation

kinelski
Copy link
Member

@kinelski kinelski commented Dec 29, 2020

Part of #15913.
This PR is part of a huge set of changes that fixes the issue mentioned above. These changes were separated into 4 chunks to reduce the review burden. This PR consists of:

  • Non-live DataFeed tests for every CRUD operation (argument validation + cancellation token validation).
  • A disposable Data Feed helper class for tests, with the same logic used by similar types added in past PRs.
  • Live DataFeed tests for Create/Get methods. Two tests were added for every possible type of data feed (13 types). The tests are pretty much the same, so the validation and setup logic could easily be extracted into separate methods.

@kinelski kinelski added Client This issue points to a problem in the data-plane of the library. Cognitive - Metrics Advisor labels Dec 29, 2020
@kinelski kinelski self-assigned this Dec 29, 2020

var createdDataSource = createdDataFeed.DataSource as AzureApplicationInsightsDataFeedSource;

var expectedKey = TestEnvironment.Mode == RecordedTestMode.Playback ? "Sanitized" : "key";
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately we can't check the authentication strings in Data Feed tests, since they're always sanitized during recording. This issue is only present in Playback, though.

Copy link
Member

Choose a reason for hiding this comment

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

So to make sure I understand, the service doesn't check that it can connect to the specified DataFeeed, right? which is why u can pass whatever?
Can anyone access the ApiKey property? or the client needs to be created with a specific role or something for someone to get that value

Copy link
Member

Choose a reason for hiding this comment

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

And the idea is not to suppress this sanitization in case someone uses a real key and then it gets logged?

Copy link
Member Author

Choose a reason for hiding this comment

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

So to make sure I understand, the service doesn't check that it can connect to the specified DataFeeed, right? which is why u can pass whatever?

Correct.

Can anyone access the ApiKey property? or the client needs to be created with a specific role or something for someone to get that value

According to the service, it's only returned if you have the admin role for that Data Feed (which is always true for the person who created it).

And the idea is not to suppress this sanitization in case someone uses a real key and then it gets logged?

Exactly.

@kinelski kinelski marked this pull request as ready for review December 29, 2020 22:35
@kinelski kinelski changed the title [MetricsAdvisor] Added tests for Data Feed CRUD operations (1/3) [MetricsAdvisor] Added tests for Data Feed CRUD operations (1/4) Dec 31, 2020
Assert.That(dataFeed.Name, Is.EqualTo(expectedName));
Assert.That(dataFeed.Description, Is.Not.Null.And.Empty);
Assert.That(dataFeed.Status, Is.EqualTo(DataFeedStatus.Active));
Assert.That(dataFeed.AccessMode, Is.EqualTo(DataFeedAccessMode.Private));
Copy link
Member

Choose a reason for hiding this comment

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

is this the default of the service? Should it actually be nullable on our side?

Copy link
Member Author

Choose a reason for hiding this comment

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

We use the same model for the UpdateDataFeed operation, and an AccessMode doesn't need to be specified. So we're making it nullable.

Copy link
Member

@maririos maririos left a comment

Choose a reason for hiding this comment

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

LGTM, just a bunch of unrelated behavior service questions

@kinelski kinelski merged commit eb5cb0c into Azure:master Jan 4, 2021
@kinelski kinelski deleted the ma-feed branch January 4, 2021 22:49
annelo-msft pushed a commit to annelo-msft/azure-sdk-for-net that referenced this pull request Feb 17, 2021
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. Cognitive - Metrics Advisor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants