-
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.
Integrate Asset-Sync Features (#23405)
* updating create recording request * first draft. need to integrate node tests and then reach out to harsha * commiting prettier update * repair ascension algo * add initial assets.json. update gitignore. * move textanalytics recordings. time to try the node tests! * remaining recorder updates. properly setting the assets.json path now * using a different version of the proxy to ensure that we include all the bugfixes from recently * bunch of changes for RECORDING_ASSETS_PATH * lint applied * Update sdk/test-utils/recorder/src/utils/utils.ts Co-authored-by: Timo van Veenendaal <timov@microsoft.com> * Update sdk/test-utils/recorder/src/utils/createRecordingRequest.ts Co-authored-by: Timo van Veenendaal <timov@microsoft.com> * Update sdk/test-utils/recorder/src/utils/relativePathCalculator.browser.ts Co-authored-by: Timo van Veenendaal <timov@microsoft.com> * Update sdk/test-utils/recorder/src/utils/utils.ts Co-authored-by: Timo van Veenendaal <timov@microsoft.com> * Update sdk/test-utils/recorder/src/utils/utils.ts * Update sdk/test-utils/recorder/src/utils/createRecordingRequest.ts Co-authored-by: Timo van Veenendaal <timov@microsoft.com> * repair imports * linting commit * resolve failing node tests * handle undefined set in environment variable * commit recordings update now that the source has been updated * fix pipeline * if (!fs.existsSync(assetsPath)) return undefined; * format * fix lint * Some refactors; calculate assets path in browser using existing environment variable * Re-add second environment variable * undo assets changes Co-authored-by: Timo van Veenendaal <timov@microsoft.com> Co-authored-by: Harsha Nalluru <sanallur@microsoft.com>
- Loading branch information
1 parent
9fc4cba
commit 312a78f
Showing
9 changed files
with
135 additions
and
49 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
40 changes: 38 additions & 2 deletions
40
sdk/test-utils/recorder/src/utils/relativePathCalculator.browser.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 |
---|---|---|
@@ -1,6 +1,42 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
export function relativeRecordingsPath(): never { | ||
throw new Error("Attempted to use the function meant for node in a browser."); | ||
import { env } from "./env"; | ||
import { RecorderError } from "./utils"; | ||
|
||
export function relativeRecordingsPath(): string { | ||
if (env.RECORDINGS_RELATIVE_PATH) { | ||
return env.RECORDINGS_RELATIVE_PATH; | ||
} else { | ||
throw new RecorderError( | ||
"RECORDINGS_RELATIVE_PATH was not set while in browser mode. Ensure that process.env.RELATIVE_RECORDINGS_PATH has been set properly in your Karma configuration." | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* ONLY WORKS IN THE NODE.JS ENVIRONMENT | ||
* | ||
* Returns the potential assets.json for the project using `process.cwd()`. | ||
* | ||
* Note for browser tests: | ||
* 1. Supposed to be called from karma.conf.js in the package for which the testing is being done. | ||
* 2. Set this `RECORDING_ASSETS_PATH` as an env variable | ||
* ```js | ||
* const { relativeRecordingsPathForBrowser } = require("@azure-tools/test-recorder-new"); | ||
* process.env.RECORDING_ASSETS_PATH = relativeRecordingsPathForBrowser(); | ||
* ``` | ||
* 3. Add "RECORDING_ASSETS_PATH" in the `envPreprocessor` array to let this be loaded in the browser environment. | ||
* ``` | ||
* envPreprocessor: ["RECORDING_ASSETS_PATH"], | ||
* ``` | ||
* | ||
* `RECORDING_ASSETS_PATH` in the browser environment is used in the recorder to tell the proxy-tool about whether or not to pass additional body argument | ||
* `x-recording-assets-file` to playback|record/Start. Doing so enables the proxy to auto-restore files from a remote location. | ||
* | ||
* @export | ||
* @returns {string} location of the relative path to discovered assets.json - `sdk/storage/storage-blob/assets.json` for example. | ||
*/ | ||
export function relativeAssetsPath(): string | undefined { | ||
return env.RECORDING_ASSETS_PATH; | ||
} |
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