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

[EngSys] upgrade dev dependency puppeteer to ^22.0.0 #28200

Merged
merged 17 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
332 changes: 96 additions & 236 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sdk/core/core-amqp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"karma-mocha": "^2.0.1",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"ts-node": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-sse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.2",
"ts-node": "^10.0.0",
"typescript": "~5.3.3"
Expand Down
36 changes: 12 additions & 24 deletions sdk/core/core-xml/test/xml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ describe("XML serializer", function () {
// @ts-expect-error - intentional error for test
await parseXML(undefined);
assert.fail("Expected error");
} catch (error: any) {
} catch (err) {
assert.ok(err instanceof Error);
const error = err as Error;
assert.ok(
error.message.indexOf("Document is empty") !== -1 || // Chrome
error.message.includes("Document is empty") || // NodeJS v8
error.message.includes("This page contains the following errors") || // Chrome
(error.message.startsWith("XML Parsing Error: syntax error") &&
error.message.indexOf("undefined") !== -1), // Firefox
error.message.includes("undefined")), // Firefox
`error.message ("${error.message}") should have contained "Document is empty" or "undefined"`,
);
}
Expand All @@ -26,11 +29,14 @@ describe("XML serializer", function () {
// @ts-expect-error - intentional error for test
await parseXML(null);
assert.fail("Expected error");
} catch (error: any) {
} catch (err) {
assert.ok(err instanceof Error);
const error = err as Error;
assert.ok(
error.message.indexOf("Document is empty") !== -1 || // Chrome
error.message.includes("Document is empty") || // NodeJS v8
error.message.includes("This page contains the following errors") || // Chrome
(error.message.startsWith("XML Parsing Error: syntax error") &&
error.message.indexOf("null") !== -1), // Firefox
error.message.includes("null")), // Firefox
`error.message ("${error.message}") should have contained "Document is empty" or "null"`,
);
}
Expand Down Expand Up @@ -442,24 +448,6 @@ describe("XML serializer", function () {
);
});

it("with element with attribute and value", async function () {
const xml = stringifyXML(
{
fruit: {
$: {
healthy: "true",
},
_: "yum",
},
},
{ rootName: "fruits" },
);
assert.deepStrictEqual(
xml,
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><fruits><fruit healthy="true">yum</fruit></fruits>`,
);
});

it("with element with child empty element", async function () {
const xml = stringifyXML(
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"ts-node": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/ts-http-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"karma-sourcemap-loader": "^0.3.8",
"karma": "^6.3.0",
"mocha": "^10.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"typescript": "~5.3.3",
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"mocha": "^10.0.0",
"moment": "^2.24.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"ts-node": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/identity/identity-broker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"cross-env": "^7.0.2",
"eslint": "^8.0.0",
"mocha": "^10.0.0",
"puppeteer": "^20.5.0",
"puppeteer": "^21.0.0",
"rimraf": "^5.0.1",
"typescript": "~5.3.3",
"sinon": "^17.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/identity/identity-cache-persistence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"eslint": "^8.0.0",
"inherits": "^2.0.3",
"mocha": "^10.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"typescript": "~5.3.3",
"util": "^0.12.1",
Expand Down
2 changes: 1 addition & 1 deletion sdk/identity/identity-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"eslint": "^8.0.0",
"inherits": "^2.0.3",
"mocha": "^10.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"typescript": "~5.3.3",
Expand Down
2 changes: 1 addition & 1 deletion sdk/identity/identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"mocha": "^10.0.0",
"ms": "^2.1.3",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"ts-node": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/keyvault/keyvault-certificates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"source-map-support": "^0.5.9",
Expand Down
2 changes: 1 addition & 1 deletion sdk/keyvault/keyvault-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"esm": "^3.2.18",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"sinon": "^17.0.0",
"source-map-support": "^0.5.9",
"typescript": "~5.3.3",
Expand Down
2 changes: 1 addition & 1 deletion sdk/keyvault/keyvault-keys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"source-map-support": "^0.5.9",
Expand Down
12 changes: 9 additions & 3 deletions sdk/keyvault/keyvault-keys/test/public/keyClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { testPollerProperties } from "./utils/recorderUtils";
import { authenticate, envSetupForPlayback } from "./utils/testAuthentication";
import TestClient from "./utils/testClient";
import { stringToUint8Array, uint8ArrayToString } from "./utils/crypto";
import { isBrowser } from "@azure/core-util";

describe("Keys client - create, read, update and delete operations", () => {
const keyPrefix = `CRUD${env.KEY_NAME || "KeyName"}`;
Expand All @@ -30,7 +31,7 @@ describe("Keys client - create, read, update and delete operations", () => {

// These tests rely on the attestation URI inside the Release Policy, which is sanitized by the test recorder.
// Using a bodiless matcher to ignore the differences that this causes.
recorder.setMatcher("BodilessMatcher");
await recorder.setMatcher("BodilessMatcher");
await recorder.start(envSetupForPlayback);

const authentication = await authenticate(getServiceVersion(), recorder);
Expand Down Expand Up @@ -263,7 +264,7 @@ describe("Keys client - create, read, update and delete operations", () => {
"Unexpected key name in result from beginDeleteKey().",
);
await poller.pollUntilDone();
let getResult = await poller.getResult();
let getResult = poller.getResult();
assert.equal(
getResult!.name,
keyName,
Expand Down Expand Up @@ -452,7 +453,12 @@ describe("Keys client - create, read, update and delete operations", () => {
}
});

it("can create an exportable key and release it", async () => {
it("can create an exportable key and release it", async function (this: Context) {
// Recorder sanitizer issue
// https://github.com/Azure/azure-sdk-for-js/issues/28455
if (isPlaybackMode() && isBrowser) {
this.skip();
}
const keyName = recorder.variable(
"exportkey",
`exportkey-${Math.floor(Math.random() * 1000)}`,
Expand Down
2 changes: 1 addition & 1 deletion sdk/keyvault/keyvault-secrets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"source-map-support": "^0.5.9",
Expand Down
2 changes: 1 addition & 1 deletion sdk/notificationhubs/notification-hubs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^5.0.5",
"ts-node": "^10.9.1",
"typescript": "~5.3.3",
Expand Down
2 changes: 1 addition & 1 deletion sdk/openai/openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.2",
"ts-node": "^10.0.0",
"typescript": "~5.3.3"
Expand Down
2 changes: 1 addition & 1 deletion sdk/servicebus/service-bus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"moment": "^2.24.0",
"c8": "^8.0.0",
"promise": "^8.0.3",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"ts-node": "^10.0.0",
"typescript": "~5.3.3",
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob-changefeed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"source-map-support": "^0.5.9",
"ts-node": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"source-map-support": "^0.5.9",
"ts-node": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-file-datalake/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"source-map-support": "^0.5.9",
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-file-share/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"sinon": "^17.0.0",
"source-map-support": "^0.5.9",
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-internal-avro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"source-map-support": "^0.5.9",
"ts-node": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-queue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.0",
"source-map-support": "^0.5.9",
"ts-node": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/template/template-dpg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"c8": "^8.0.0",
"puppeteer": "^19.2.2",
"puppeteer": "^21.0.0",
"rimraf": "^3.0.2",
"ts-node": "^10.0.0",
"typescript": "~5.3.3",
Expand Down
2 changes: 1 addition & 1 deletion sdk/test-utils/recorder/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- Clarify error when attempting to redirect a request but the recorder has not been started
- Forward mismatch error when recording file cannot be found during `start` call in playback mode
- Add more descriptive message in the case that the test proxy has not been started before running the tests

- Ignore `Accept-Language` header for browsers in Playback mode.
## 3.0.0 (2023-03-07)

### Features Added
Expand Down
33 changes: 30 additions & 3 deletions sdk/test-utils/recorder/src/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { addTransform, Transform } from "./transform";
import { createRecordingRequest } from "./utils/createRecordingRequest";
import { logger } from "./log";
import { setRecordingOptions } from "./options";
import { isNode } from "@azure/core-util";
import { isBrowser, isNode } from "@azure/core-util";
import { env } from "./utils/env";
import { decodeBase64 } from "./utils/encoding";
import { AdditionalPolicyConfig } from "@azure/core-client";
Expand All @@ -52,6 +52,7 @@ export class Recorder {
private sessionFile?: string;
private assetsJson?: string;
private variables: Record<string, string>;
private matcherSet = false;

constructor(private testContext?: Test | undefined) {
logger.info(`[Recorder#constructor] Creating a recorder instance in ${getTestMode()} mode`);
Expand Down Expand Up @@ -216,6 +217,12 @@ export class Recorder {
* - sanitizerOptions - Generated recordings are updated by the "proxy-tool" based on the sanitizer options provided, these santizers are applied only in "record" mode.
*/
async start(options: RecorderStartOptions): Promise<void> {
if (isBrowser && isPlaybackMode()) {
Copy link
Member

Choose a reason for hiding this comment

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

Were changes in the recorder related to the upgrade or something found in passing?

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see #28455 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes there's some behavior changes in headers being sent (Accept-Language). I updated sanitizers in recorder and keyvault. However some keyvault tests still failed.

Copy link
Member

Choose a reason for hiding this comment

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

I need to re-record keyvault tests with the new service version some time in the next few days (it's not fully deployed yet). Hopefully just rerecording will fix the problem but if not I will investigate further at that time :)

Copy link
Member

Choose a reason for hiding this comment

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

Also, I am curious what the change to Accept-Language was. I remember this being a bugbear for me when playing back tests in the past since the locale on my machine was en-CA instead of en-US which is what was present in the recordings.

Copy link
Member Author

@jeremymeng jeremymeng Feb 5, 2024

Choose a reason for hiding this comment

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

IIRC ideally the header should be ignored by test-proxy. Not sure what was the exact issue that prevented it from happening.

Copy link
Member

Choose a reason for hiding this comment

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

We wanted to do this here Azure/azure-sdk-tools#6152 but didn't in the end, presumably due to engsys objection. @HarshaNalluru do you recall why?

Copy link
Member

Choose a reason for hiding this comment

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

Their resistance was that it might have unintended consequences and is disruptive keeping other languages as well in mind.

From JS perspective, it should be safe, and we need to move forward with this change, so doing it in JS recorder makes sense.

Copy link
Member

@HarshaNalluru HarshaNalluru Feb 5, 2024

Choose a reason for hiding this comment

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

Move this to a new method "preStart()" or similar, and call that here to keep the code clean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

if (!this.matcherSet) {
await this.setMatcher("CustomDefaultMatcher");
this.matcherSet = true;
}
}
if (isLiveMode()) return;
logger.info(`[Recorder#start] Starting the recorder in ${getTestMode()} mode`);
this.stateManager.state = "started";
Expand Down Expand Up @@ -379,13 +386,33 @@ export class Recorder {
/**
* Sets the matcher for the current recording to the matcher specified.
*/
async setMatcher(matcher: Matcher, options?: CustomMatcherOptions): Promise<void> {
async setMatcher(matcher: Matcher, options: CustomMatcherOptions = {}): Promise<void> {
if (isPlaybackMode()) {
if (!this.httpClient) {
throw new RecorderError("httpClient should be defined in playback mode");
}

await setMatcher(Recorder.url, this.httpClient, matcher, this.recordingId, options);
const excludedHeaders = isBrowser
? (options.excludedHeaders ?? []).concat("Accept-Language")
Copy link
Member

@HarshaNalluru HarshaNalluru Feb 5, 2024

Choose a reason for hiding this comment

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

Can you add a comment explaining why? for future reference

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

: options.excludedHeaders;

const updatedOptions = {
...options,
excludedHeaders,
};
if (matcher === "BodilessMatcher") {
updatedOptions.compareBodies = false;
await setMatcher(
Recorder.url,
this.httpClient,
"CustomDefaultMatcher",
this.recordingId,
updatedOptions,
);
} else {
await setMatcher(Recorder.url, this.httpClient, matcher, this.recordingId, updatedOptions);
}
this.matcherSet = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/test-utils/recorder/test/testProxyClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe("TestProxyClient functions", () => {
env.TEST_MODE = testMode;
const recordingId = "dummy-recording-id";
clientHttpClient.sendRequest = (req): Promise<PipelineResponse> => {
if (req.url.endsWith(paths.setRecordingOptions)) {
if (req.url.endsWith(paths.setRecordingOptions) || req.url.endsWith(paths.setMatcher)) {
return Promise.resolve({
headers: createHttpHeaders(),
status: 200,
Expand Down
Loading
Loading