Skip to content

Commit 0acaf3f

Browse files
authored
[@azure/arm-newrelicobservability] Fix the Test Case (#30021)
### Packages impacted by this PR @azure/arm-newrelicobservability ### Issues associated with this PR None ### Describe the problem that is addressed by this PR On June 6, 2024, an issue was reported by Manik Khandelwal as the `rushx build` command is failing for the `@azure/arm-newrelicobservability` SDK. The following error is reported: ``` test/newrelicobservability_operations_test.spec.ts.ts(56,7): error TS2353: Object literal may only specify known properties, and 'clientId' does not exist in type 'CreateTestCredentialOptions'. test/newrelicobservability_operations_test.spec.ts.ts(60,56): error TS2554: Expected 0-1 arguments, but got 2. ``` This PR has been created to fix this issue. ### 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? Looking at the root cause of the issue, the current code changes in the `newrelicobservability_operations_test.spec.ts.ts` (with client id & client secret) are added on March 21, 2024 (Refer #28829). At that time, there was no problem with the code and it was working fine. On May 6, 2024 some changes have been done in the `@azure-tools/test-credential` in which the `clientId` and `clientSecret` have been removed. Thus the reported error is happening. (Now, Ideally I would have expected that such issues would have been flagged by our CI while merging the changes for `@azure-tools/test-credential`. But, that did not happen. Refer the CI run in #29577. @HarshaNalluru for further investigation) In order to resolve the issue, I have removed the extra parameters. The `playback` mode is also running fine. The CI could be seen at https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3868221&view=results. Because of the artifact already exists, the check enforcer is not completing. But that is not a serious issue. I am overriding the check enforcer. ### Are there test cases added in this PR? _(If not, why?)_ No. The issue itself is in the test case. ### Provide a list of related PRs _(if any)_ 1. #28829 2. #29577 ### 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)_ - [ ] Added a changelog (if necessary) @xirzec @joheredi Please review and approve the PR
1 parent 6d67e92 commit 0acaf3f

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

sdk/newrelicobservability/arm-newrelicobservability/test/newrelicobservability_operations_test.spec.ts.ts

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ const replaceableVariables: Record<string, string> = {
2222
NewRelic_CLIENT_ID: "azure_client_id",
2323
NewRelic_CLIENT_SECRET: "azure_client_secret",
2424
NewRelic_TENANT_ID: "88888888-8888-8888-8888-888888888888",
25-
NewRelic_SUBSCRIPTION_ID: "azure_subscription_id"
25+
NewRelic_SUBSCRIPTION_ID: "azure_subscription_id",
2626
};
2727

2828
const recorderOptions: RecorderStartOptions = {
29-
envSetupForPlayback: replaceableVariables
29+
envSetupForPlayback: replaceableVariables,
30+
removeCentralSanitizers: [
31+
"AZSDK4001", // url should not be over-sanitized, fake env setup handles it already
32+
"AZSDK3493",
33+
],
3034
};
3135

3236
export const testPollingOptions = {
@@ -36,9 +40,7 @@ export const testPollingOptions = {
3640
describe("NewRelicObservability test", () => {
3741
let recorder: Recorder;
3842
let subscriptionId: string;
39-
let clientId: string;
4043
let tenantId: string;
41-
let clientSecret: string;
4244
let client: NewRelicObservability;
4345
let location: string;
4446
let resourceGroup: string;
@@ -47,22 +49,21 @@ describe("NewRelicObservability test", () => {
4749
beforeEach(async function (this: Context) {
4850
recorder = new Recorder(this.currentTest);
4951
await recorder.start(recorderOptions);
50-
subscriptionId = env.NewRelic_SUBSCRIPTION_ID || '';
51-
clientId = env.NewRelic_CLIENT_ID || '';
52-
tenantId = env.NewRelic_TENANT_ID || '';
53-
clientSecret = env.NewRelic_CLIENT_SECRET || '';
52+
subscriptionId = env.NewRelic_SUBSCRIPTION_ID || "";
53+
tenantId = env.NewRelic_TENANT_ID || "";
5454
const credentialOptions: CreateTestCredentialOptions = {
5555
tenantId,
56-
clientId,
57-
clientSecret
58-
}
56+
};
5957
// This is an example of how the environment variables are used
60-
const credential = createTestCredential(undefined, credentialOptions);
61-
client = new NewRelicObservability(credential, subscriptionId, recorder.configureClientOptions({}));
58+
const credential = createTestCredential(credentialOptions);
59+
client = new NewRelicObservability(
60+
credential,
61+
subscriptionId,
62+
recorder.configureClientOptions({}),
63+
);
6264
location = "centraluseuap";
6365
resourceGroup = "myjstest";
6466
resourcename = "resourcetest1";
65-
6667
});
6768

6869
afterEach(async function () {
@@ -86,22 +87,23 @@ describe("NewRelicObservability test", () => {
8687
firstName: "ZiWei",
8788
lastName: "Chen (WICRESOFT NORTH AMERICA LTD)",
8889
emailAddress: "[email protected]",
89-
phoneNumber: ""
90+
phoneNumber: "",
9091
},
9192
planData: {
9293
usageType: "PAYG",
9394
billingCycle: "MONTHLY",
94-
planDetails: "newrelic-pay-as-you-go-free-live@[email protected]_liftr_payg"
95+
planDetails:
96+
"newrelic-pay-as-you-go-free-live@[email protected]_liftr_payg",
9597
},
9698
},
97-
testPollingOptions);
99+
testPollingOptions,
100+
);
98101
assert.equal(res.name, resourcename);
99-
await delay(100000)
102+
await delay(100000);
100103
});
101104

102105
it("monitors get test", async function () {
103-
const res = await client.monitors.get(resourceGroup,
104-
resourcename);
106+
const res = await client.monitors.get(resourceGroup, resourcename);
105107
assert.equal(res.name, resourcename);
106108
});
107109

@@ -115,12 +117,14 @@ describe("NewRelicObservability test", () => {
115117

116118
it("monitors delete test", async function () {
117119
const resArray = new Array();
118-
const res = await client.monitors.beginDeleteAndWait(resourceGroup, "[email protected]", resourcename
119-
)
120+
const res = await client.monitors.beginDeleteAndWait(
121+
resourceGroup,
122+
123+
resourcename,
124+
);
120125
for await (let item of client.monitors.listByResourceGroup(resourceGroup)) {
121126
resArray.push(item);
122127
}
123128
assert.equal(resArray.length, 1);
124129
});
125-
126-
})
130+
});

0 commit comments

Comments
 (0)