-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@azure/monitor-query] Code Changes to add scope to Metrics Query Cli…
…ent and modify MetricsBatchOptionalParams (#26868) ### Packages impacted by this PR @azure/monitor-query ### Issues associated with this PR N/A ### Describe the problem that is addressed by this PR 1. In this release, In the `MetricsBatchOptionalParams`object, the names of the properties `endtime`, `orderby`, `starttime` are changed to `endTime`, `orderBy`, `startTime` respectively. 2. The scope value is not set correctly in the previous release. In this release, I am setting the scope value correctly. 3. The previous release did not have integration tests. With this PR, I have added the integration tests. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? There are no special design changes in this PR, other than setting the credential scope. ### Are there test cases added in this PR? _(If not, why?)_ One point to note is that the new tests are marked as skip. Because, the recordings will have subscription id in them which we do not want to expose. So, for CI, I have marked them as Skip. I am working on possible solutions to bypass this issue in the future. But, the tests have been run locally and the snapshots are provided below. ![image](https://github.com/Azure/azure-sdk-for-js/assets/602456/43e9149b-a882-4707-b43b-68b3f4df7211) ![image](https://github.com/Azure/azure-sdk-for-js/assets/602456/f89e32a2-2af9-45b6-a90e-1e1ddc504166) ### Provide a list of related PRs _(if any)_ N/A ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ N/A ### Checklists - [X] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [X] Added a changelog (if necessary) --------- Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com>
- Loading branch information
1 parent
f8e49a4
commit d726fe2
Showing
9 changed files
with
216 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
sdk/monitor/monitor-query/test/public/metricsBatchClient.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { assert } from "chai"; | ||
import { Context } from "mocha"; | ||
import { MetricsBatchQueryClient, MetricResultsResponseValuesItem } from "../../src"; | ||
import { | ||
RecorderAndMetricsBatchQueryClient, | ||
createRecorderAndMetricsBatchQueryClient, | ||
getMetricsBatchResourceIds, | ||
getMetricsBatchNamespace, | ||
getMetricsBatchNames, | ||
} from "./shared/testShared"; | ||
|
||
describe.skip("MetricsBatchClient live tests", function () { | ||
let resourceIds: string[]; | ||
let metricsNamespace: string; | ||
let metricNames: string[]; | ||
let metricsBatchQueryClient: MetricsBatchQueryClient; | ||
|
||
beforeEach(async function (this: Context) { | ||
const recordedClient: RecorderAndMetricsBatchQueryClient = | ||
await createRecorderAndMetricsBatchQueryClient(); | ||
resourceIds = getMetricsBatchResourceIds(); | ||
metricsNamespace = getMetricsBatchNamespace(); | ||
metricNames = getMetricsBatchNames(); | ||
metricsBatchQueryClient = recordedClient.client; | ||
}); | ||
|
||
// afterEach(async function () { | ||
// loggerForTest.verbose("Recorder: stopping"); | ||
// await recorder.stop(); | ||
// }); | ||
|
||
it("batch query with no resource ids", async () => { | ||
try { | ||
await metricsBatchQueryClient.queryBatch([], metricsNamespace, metricNames); | ||
assert.fail("Code should not reach here."); | ||
} catch (e) { | ||
assert.equal(1, 1); | ||
} | ||
}); | ||
|
||
it("batch query for 2 resource ids", async () => { | ||
const result: MetricResultsResponseValuesItem[] = await metricsBatchQueryClient.queryBatch( | ||
resourceIds, | ||
metricsNamespace, | ||
metricNames | ||
); | ||
assert.equal(result.length, 2); | ||
}); | ||
|
||
it("batch query for 1 resource id", async () => { | ||
const result: MetricResultsResponseValuesItem[] = await metricsBatchQueryClient.queryBatch( | ||
[resourceIds[0]], | ||
metricsNamespace, | ||
metricNames | ||
); | ||
assert.equal(result.length, 1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters