Skip to content

Commit

Permalink
Support V3 SimplePollerLike in RLC LRO (#2443)
Browse files Browse the repository at this point in the history
* Fix typo issues

* Update the reference property

* Remove the useLegacyLro options

* Update the template to adopt with v3 changes

* Update the lro flag and enable useLegacyV2Lro for load test

* Update the changes

* Update the swagger side with this options

* Update the flag in smoke test

* Update the integration testing in swagger repo

* Adopt the option useLegacyV2Lro for swagger way

* Revert change in smoke test

* Update packages/autorest.typescript/test/commands/smoke-test-list.ts

* Update the smoke test in typespec

* Update the test case for lro rpcClient

* Add test cases for lro rpc rlc

* Change to lro rpc

* Update the modular poller in rlc and disable legacy code in modular

* Add a warning

* Testing in local env

* Fix the exception issue during polling initial process

* regen lro code

* regen smoke-test code

* Update packages/typespec-ts/package.json

* Update packages/typespec-ts/package.json

* Update the lock file

* Remove the option for useLegacyV2Lro

* Revert testing changes

* Regenerate rlc lro with v3 version

* Update the modular test

* Regenerate smoke testing in swagger

* Refresh the smoke test in tsp

* Update the content

* regen smoke test

* regen integration code

* Should report the server message

* Update the package.json for rlc integration

* update the commands

* Update the smoke git diff

* update the rlc path

* Add extra steps to install dependencies

* Update the dependencies for browser testing

* Revert changes

* Update the install commands

* Remove the option useLegacyV2Lro

* Update the documents

* Update the swagger generation

* regen integration code

* regen smoke test

* remove the un-used command

* Update the scripts to install deps

* Update the RLC simplepollerlike with comments

* regen smoke test and integration

* regen smoke test tag rlc

* Update the namings

* Avoid breakings for toString

* Update the integration for swagger

* update changes

* regen test

* Update the lro template

* Support abort signal for modular lro

* regen integration test

* regen smoke test

* regen rlc swagger test

* Update the node version

* Update the smoke test

* update the ut name

* update the test cases

* Regen smoke testing

* update the smoke testing

---------

Co-authored-by: Jiao Di (MSFT) <80496810+v-jiaodi@users.noreply.github.com>
Co-authored-by: Di Jiao <v-jiaodi@microsoft.com>
  • Loading branch information
3 people authored Apr 24, 2024
1 parent b12beae commit efbba8d
Show file tree
Hide file tree
Showing 90 changed files with 4,262 additions and 536 deletions.
2 changes: 1 addition & 1 deletion .scripts/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Use Node 18"
- script: |
npm install -g @microsoft/rush
Expand Down
20 changes: 10 additions & 10 deletions .scripts/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ stages:
macOS_Node18:
Pool:
OSVmImage: "macOS-latest"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Linux_Node18:
Pool: ${{ parameters.LinuxPool }}
OSVmImage: "ubuntu-20.04"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Windows_Latest:
Pool:
OSVmImage: "Windows-latest"
Expand All @@ -134,11 +134,11 @@ stages:
macOS_Node18:
Pool:
OSVmImage: "macOS-latest"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Linux_Node18:
Pool: ${{ parameters.LinuxPool }}
OSVmImage: "ubuntu-20.04"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Windows_Latest:
Pool:
OSVmImage: "Windows-latest"
Expand Down Expand Up @@ -169,11 +169,11 @@ stages:
macOS_Node18:
Pool:
OSVmImage: "macOS-latest"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Linux_Node18:
Pool: ${{ parameters.LinuxPool }}
OSVmImage: "ubuntu-20.04"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
pool:
name: $[coalesce(variables['Pool'], '')]
vmImage: $[coalesce(variables['OSVmImage'], '')]
Expand Down Expand Up @@ -231,11 +231,11 @@ stages:
macOS_Node18:
Pool:
OSVmImage: "macOS-latest"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Linux_Node18:
Pool: ${{ parameters.LinuxPool }}
OSVmImage: "ubuntu-20.04"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Windows_Latest:
Pool:
OSVmImage: "Windows-latest"
Expand All @@ -261,11 +261,11 @@ stages:
macOS_Node18:
Pool:
OSVmImage: "macOS-latest"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Linux_Node18:
Pool: ${{ parameters.LinuxPool }}
OSVmImage: "ubuntu-20.04"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
# Windows_Latest:
# Pool:
# OSVmImage: "Windows-latest"
Expand Down
24 changes: 12 additions & 12 deletions .scripts/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
tar zxvf $(Pipeline.Workspace)/packages/$(TAR_NAME)
Expand All @@ -59,7 +59,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
cd $(Pipeline.Workspace)/packages
Expand Down Expand Up @@ -90,7 +90,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
tar zxvf $(Pipeline.Workspace)/packages/$(TAR_NAME)
Expand All @@ -113,7 +113,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
cd $(Pipeline.Workspace)/packages
Expand Down Expand Up @@ -145,7 +145,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
tar zxvf $(Pipeline.Workspace)/packages/$(TAR_NAME)
Expand All @@ -168,7 +168,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
cd $(Pipeline.Workspace)/packages
Expand Down Expand Up @@ -196,7 +196,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
tar zxvf $(Pipeline.Workspace)/packages/$(TAR_NAME)
Expand All @@ -221,7 +221,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
tar zxvf $(Pipeline.Workspace)/packages/$(TAR_NAME)
Expand All @@ -246,7 +246,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
tar zxvf $(Pipeline.Workspace)/packages/$(TAR_NAME)
Expand All @@ -270,7 +270,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
cd $(Pipeline.Workspace)/packages
Expand All @@ -293,7 +293,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
cd $(Pipeline.Workspace)/packages
Expand All @@ -316,7 +316,7 @@ stages:
steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"
versionSpec: "18.19.x"
displayName: "Install Node.js"
- script: |
cd $(Pipeline.Workspace)/packages
Expand Down
4 changes: 2 additions & 2 deletions .scripts/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
macOS_Node18:
Pool:
OSVmImage: "macOS-latest"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Linux_Node18:
Pool: ${{ parameters.LinuxPool }}
OSVmImage: "ubuntu-20.04"
NodeTestVersion: "18.x"
NodeTestVersion: "18.19.x"
Windows_Latest:
Pool:
OSVmImage: "Windows-latest"
Expand Down
14 changes: 12 additions & 2 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions packages/autorest.typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "6.0.18",
"scripts": {
"build": "tsc -p . && npm run copyFiles",
"build:test:browser": "tsc -p tsconfig.browser-test.json && webpack --config webpack.config.test.js",
"build:test:browser:rlc": "tsc -p tsconfig.browser-test.json && ts-node test/commands/prepare-deps.ts --browser && webpack --config webpack.config.test.js --env mode=rlc",
"build:test:browser": "tsc -p tsconfig.browser-test.json && ts-node test/commands/prepare-deps.ts --removal && webpack --config webpack.config.test.js --env mode=hlc",
"check:tree": "ts-node ./test/commands/check-clean-tree.ts",
"pack": "npm pack 2>&1",
"clean": "rimraf --glob test-browser test/**/node_modules",
Expand All @@ -12,7 +13,7 @@
"test:node": "npm run unit-test && npm run start-test-server:v2 & npm run integration-test:alone & npm run rlc-integration-test:alone & npm run test-version-tolerance & npm run stop-test-server",
"test:node:alone": "npm run unit-test && npm run integration-test:alone && npm run rlc-integration-test:alone && npm run test-version-tolerance",
"test:browser": "npm run start-test-server:v2 & npm run integration-test:browser & npm run rlc-integration-test:browser & npm run test-version-tolerance & npm run stop-test-server",
"test:browser:alone": "npm run integration-test:browser && npm run rlc-integration-test:browser && npm run test-version-tolerance",
"test:browser:alone": "npm run integration-test:browser && npm run rlc-integration-test:browser && npm run test-version-tolerance",
"rlc-test:node": "npm run unit-test && npm run start-test-server:v2 & npm run rlc-integration-test:alone && npm run stop-test-server",
"rlc-test:browser": "npm run start-test-server:v2 & npm run rlc-integration-test:browser && npm run stop-test-server",
"unit-test": "mocha -r ts-node/register \"./test/unit/**/*spec.ts\"",
Expand All @@ -23,9 +24,9 @@
"integration-test:alone": "mocha -r ts-node/register --timeout 2000 \"./test/integration/**/!(sampleTest).spec.ts\"",
"rlc-integration-test": "npm run start-test-server:v2 & npm run rlc-generate-and-test && npm run stop-test-server",
"rlc-integration-test:new": "npm-run-all start-test-server rlc-generate-and-test rlc-integration-test:alone stop-test-server",
"rlc-integration-test:browser": "npm run build:test:browser && karma start karma.conf.js",
"rlc-integration-test:browser": "npm run build:test:browser:rlc && karma start karma.conf.js",
"rlc-generate-and-test": "npm-run-all -s build rlc-generate-swaggers rlc-integration-test:alone rlc-integration-test:browser",
"rlc-integration-test:alone": "mocha -r ts-node/register --timeout 2000 \"./test/rlcIntegration/**/!(sampleTest).spec.ts\"",
"rlc-integration-test:alone": "ts-node test/commands/prepare-deps.ts && mocha -r ts-node/register --timeout 2000 \"./test/rlcIntegration/!(sampleTest).spec.ts\"",
"start-test-server": "ts-node test/commands/start-server.ts",
"start-test-server:v2": "autorest-testserver run --appendCoverage",
"stop-test-server": "autorest-testserver stop",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function transformPaths(model: CodeModel): Paths {
lroDetails: {
isLongRunning: isLongRunningOperation(operation)
},
isPageable: isPagingOperation(operation)
isPaging: isPagingOperation(operation)
}
};

Expand Down
10 changes: 10 additions & 0 deletions packages/autorest.typescript/test/commands/browser.package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"browser": {
"./utils/stream-helpers.js": "./utils/stream-helpers.browser.js",
"./utils/fileSystem.js": "./utils/fileSystem.browser.js",
"./utils/path.js": "./utils/path.browser.js"
},
"dependencies": {
"@azure/core-lro": "3.0.0-beta.1"
}
}
85 changes: 85 additions & 0 deletions packages/autorest.typescript/test/commands/prepare-deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { spawn } from "child_process";
import { existsSync } from "fs";
import { join } from "path";

async function main() {
const isBrowserTest = process.argv.includes("--browser");
const isRemoval = process.argv.includes("--removal");
if (isBrowserTest) {
await copyPackageJson();
await installDependencies(join(`${__dirname}`, "..", "..", "test-browser"));
} else if (isRemoval) {
await removeFiles([
join(`${__dirname}`, "..", "..", "test-browser", "package.json"),
join(`${__dirname}`, "..", "..", "test-browser", "node_modules")
]);
} else {
await installDependencies(
join(`${__dirname}`, "..", "..", "test", "rlcIntegration")
);
}
}

async function removeFiles(files: string[]) {
const existing = files.filter((file) => existsSync(file));
if (existing.length === 0) {
console.log("No dependencies to remove");
return;
}
runCommand("rm", ["-rf", ...existing]);
console.log("Removed dependencies for hlc browser tests", existing);
}

async function copyPackageJson() {
const srcPath = join(
`${__dirname}`,
"..",
"..",
"test",
"commands",
"browser.package.json"
);
const destPath = join(
`${__dirname}`,
"..",
"..",
"test-browser",
"package.json"
);
await runCommand("cp", [srcPath, destPath]);
}

async function installDependencies(path: string) {
await runCommand(
`npm${/^win/.test(process.platform) ? ".cmd" : ""}`,
["install"],
path
);
console.log("Installed dependencies for rlc browser tests", path);
}

async function runCommand(command: string, args: string[] = [], cwd = ".") {
return new Promise((resolve, reject) => {
const process = spawn(command, args, { cwd, shell: true });

let stdout = "";
let stderr = "";

process.stdout.on("data", (data) => (stdout += data.toString()));
process.stderr.on("data", (data) => (stderr += data.toString()));

process.on("close", () => {
resolve(stdout ?? stderr);
});

process.on("error", (error: any) => {
console.log(stdout, stderr, error);
reject(new Error(error));
});
});
}

main().catch((error) => {
console.error(error);
process.exit(-1);
});
2 changes: 1 addition & 1 deletion packages/autorest.typescript/test/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ export async function runAutorest(
console.error(error);
throw error;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1290,4 +1290,4 @@ const run = async () => {
run().catch(error => {
console.error(error);
process.exit(-1000);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"@azure/core-rest-pipeline": "^1.5.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.6.2",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0",
"@azure/core-lro": "3.0.0-beta.1",
"@azure/abort-controller": "^2.0.0",
"@azure/core-paging": "^1.5.0"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit efbba8d

Please sign in to comment.