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

[Unified Recorder] Call proxy-tool through dev-tool #18322

Merged
merged 80 commits into from
Nov 20, 2021

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Oct 22, 2021

Issue #17042

TODO

  • Running this script will create a background process which would end when called "docker stop"
  • Volume will be hard-coded - will be evaluated to be the root of the repo
  • Should not start the container in live mode, this is only meant for record and playback modes
    • - We should load the .env and check the TEST_MODE variable before starting
  • Instead of the latest tag, pick up the tag from Powershell script
  • Check http://localhost:5000 & https://localhost:5001
    • - Only start docker run if they are not active
  • Helpful commands
    • - dev-tool test-proxy start
    • - dev-tool test:node --mocha "<options>"
    • - dev-tool test:browser --karma "<options>"
  • If docker run fails, throw the error (Logs the output in the file, so all good?)
  • docker run command should run in the background
  • After starting http://localhost:5000 & https://localhost:5001 (Not doing)
  • dev-tool command will be used in the respective SDKs to run this script before the tests are run for both node and browser
    • node
    • browser
  • @scbedd raised
    • As we depend on concurrently and run the docker run .. and mocha .. commands in parallel, there might be a case where tests start running and docker run .. is still setting up the test proxy. Make sure the tests only run when the test proxy is active.

Future PRs

  • Allow providing docker run options along with the mocha and karma options for the test commands
  • Call mocha programmatically
    • experiment with using dev-tool's own register instead of ts-node/register. That way we can really centralize the concerns in our own config/scripts.
  • Call karma programatically
  • @witemple-msft's comment
    • All of this is nitpicky, but it's best to be explicit about the mutability of the volume. If we are running in playback mode, we should bind the volume read-only. In record mode, we should bind it read-write. On Linux hosts that have SELInux (Red Hat, Fedora), we'll also need the Z flag to relabel the volume. We can test for SELinux using the selinuxenabled command, and that'll exit 0 if it's enabled on the machine:
  • @scbedd raise a couple of interesting points
    • docker run .. with concurrently stops gracefully when the tests end in Linux and Mac but not on windows, though the process(concurrently) ends. Figure out a way to properly stop the docker run .. in windows.

@ghost ghost added the dev-tool Issues related to the Azure SDK for JS dev-tool label Oct 22, 2021
@check-enforcer
Copy link

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run js - [service] - ci

Copy link
Member

@witemple-msft witemple-msft left a comment

Choose a reason for hiding this comment

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

Overall I think this is pretty clever. The idea to just hit the /info endpoint of the proxy tool and start it when running the tests if it's not already running seems like it's going to be a nice developer experience.

I have a few broad questions:

  1. What do we tell developers in error messages if they don't have docker?
  2. Is there any setup required on the local machine for this to work?

Other than that, I have some feedback from the dev-tool perspective and some changes that we will need to make.

common/tools/dev-tool/src/commands/index.ts Outdated Show resolved Hide resolved
common/tools/dev-tool/src/commands/testNode.ts Outdated Show resolved Hide resolved
common/tools/dev-tool/src/commands/testNode.ts Outdated Show resolved Hide resolved
common/tools/dev-tool/src/commands/testNode.ts Outdated Show resolved Hide resolved
common/tools/dev-tool/src/commands/testNode.ts Outdated Show resolved Hide resolved
common/tools/dev-tool/src/commands/testNode.ts Outdated Show resolved Hide resolved
common/tools/dev-tool/src/commands/testNode.ts Outdated Show resolved Hide resolved
common/tools/dev-tool/src/util/testProxyUtils.ts Outdated Show resolved Hide resolved
import { spawn } from "child_process";
import fs from "fs";
import path from "path";
import { IncomingMessage, request, RequestOptions } from "http";
Copy link
Member

Choose a reason for hiding this comment

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

I'm in favor of using a simpler HTTP client in dev-tool such as axios.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only HTTP request that is made in the whole of dev-tool.
I don't want to take a dependency on another package if this serves my purpose.

Copy link
Member

Choose a reason for hiding this comment

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

Very well, When/if we have more HTTP usage I'd like to replace it with axios, node-fetch, etc. (something a little bit more "batteries-included").

Copy link
Contributor

Choose a reason for hiding this comment

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

core-rest-pipelines should help 🤔 at least in the future

Copy link
Member Author

Choose a reason for hiding this comment

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

That'll add circular dependencies @sadasant.
core packages depend on dev-tool

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want to use core for incidental stuff in dev-tool. It's designed for the client libraries and unless we really have some kind of request pipeline in dev-tool where performance and consistent configurability with the clients is important, I think it'll be nicer to just use a simple API.

Copy link
Contributor

Choose a reason for hiding this comment

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

That'll add circular dependencies @sadasant.

Not if you pin a version 🤔 since dev-tools is only a devDependency. But I agree with Will 👍

common/tools/dev-tool/src/commands/testNode.ts Outdated Show resolved Hide resolved
Comment on lines -24 to 26
-ArgumentList "--storage-location '${{ parameters.rootFolder }}'" `
-ArgumentList "--storage-location ${{ parameters.rootFolder }}" `
-NoNewWindow -PassThru -RedirectStandardOutput $(Build.SourcesDirectory)/test-proxy.log
displayName: 'Run the testproxy - windows'
Copy link
Member Author

Choose a reason for hiding this comment

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

@scbedd for 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.

Analyze step will be fixed once this fix goes into the tools repo. Azure/azure-sdk-tools#2290

Copy link
Contributor

@sadasant sadasant left a comment

Choose a reason for hiding this comment

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

Looks really clean 🙂

Copy link
Member

@jeremymeng jeremymeng left a comment

Choose a reason for hiding this comment

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

Looking forward to enjoying all the benefits that proxy-tool brings us!


import { subCommand, makeCommandInfo } from "../../framework/command";

export const commandInfo = makeCommandInfo("run", "run scripts such as test:node");
Copy link
Member

Choose a reason for hiding this comment

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

nit: test:node not accurate if the sub commands include both node and browser?


export default leafCommand(commandInfo, async (options) => {
return runTestsWithProxyTool({
command: `nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace ${options.mocha}`,
Copy link
Member

Choose a reason for hiding this comment

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

do we still have packages that bundle the nodejs tests? I hope -r esm still work with those if any exists

Copy link
Member Author

Choose a reason for hiding this comment

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

So, three ways of running the packages

  • js rollup bundle
  • js dist-esm files
  • ts sources

I'll check if test:node-js-input is working for both 1st and 2nd.

@HarshaNalluru
Copy link
Member Author

/azp run js - test-utils - ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@HarshaNalluru HarshaNalluru merged commit 2de7b65 into Azure:main Nov 20, 2021
@HarshaNalluru HarshaNalluru deleted the harshan/issue/17042 branch November 20, 2021 09:12
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-js that referenced this pull request Apr 20, 2022
Azure Networking 2021-08-01 release of monthly branch (Azure#18440)

* Adds base for updating Microsoft.Network from version stable/2021-05-01 to version 2021-08-01

* Updates readme

* Updates API version in new specs and examples

* Add AppGw swagger changes for L4 proxy (Azure#17561)

* Add AppGw swagger changes for L4 proxy

* Fix Lint Errors

* fix prettier checks

* HubRoutingPreference in VirtualHub (Azure#17609)

* commit1

* commit2

Co-authored-by: Khushboo Baheti <[email protected]>

* MultipleApipa feature VpnSiteLinkConnection and  VirtualNetworkGatewayConnection (Azure#17672)

* VngConnection

* VpnSiteLinkConnection

* fixes

* fixes

* fix2

* fixes

Co-authored-by: Khushboo Baheti <[email protected]>

* Virtual Wan P2S MultiPool feature swagger changes (Azure#17620)

* Virtual Wan P2S MultiPool feature swagger changes

* Fix Swagger LintDiff errors

* Fix LintDiff errors

* Fix errors

* Fix spec

* Fix spec

* Fix spec

* Fix LintDiff errors

* Fix LintDiff errors

* Fix SDK azure-sdk-for-net generation error

* Remove suppression

* Fix errors

* Fix Lintdiff error

* Fix PrettierCheck

* changes (Azure#18002)

* Revert "changes (Azure#18002)" (Azure#18014)

This reverts commit 320ed6a6fc5a68e8af43da303f8e1caaacf24708.

* Add nic auxiliary mode (Azure#17577)

* Add nic auxiliary mode

* fix spacing

* Fixing prettier check

* Restoring package-lock file

* Restoring package json

Co-authored-by: Prachi Bhavsar <[email protected]>

* Connection Draining add new properties (Azure#18052)

* merge

* fix

* fix

* Adding express route port authorization apis (Azure#17582)

* adding apis and updating resource to support ports auth

* moving change to 2021-08-01

* minor: removing change from 2020-07-01

* lintdiff : adding type object

* minor: fixing prettier

* adding authorizations to ports property

* fixing circuitResourceUri property name

* fixing model validation

* changing circuit resource uri type to string

* removing authorizations child reosurce from parent property

* Fix Azure Firewall Policy regressions. Back fix validation issues (Azure#18233)

* Fix regressions in Firewall Policy Swagger / give firewallPolicy.json some love

* Additional lint violations

* remove breaking changes for next time. TO DO

* Revert "remove breaking changes for next time. TO DO"

This reverts commit 8f44a174c73c02d18d829f6dfb1d990488770b23.

* Reintroduce api-version for idps signature based routes. Create better names for enums to be generated in SDKs

* standardize enum names with FirewallPolicy prefix

* Azure Firewall Support of Private IP Ranges in IDPS (Azure#18320)

* Azure Firewall Support of Private IP Ranges in IDPS

* make sure all arrays have x-ms-identifiers

* FirewallPolicy not Firewall policy

fix spellcheck validation

* Ability to update tags on firewall policies (Azure#18322)

* Support updating of Azure Firewall Policy Tags. Includes HTTP Patch example

* Use common-types ErrorDetail

* Ability to update tags for Firewall Policies

* spell check fix for firewallpolicy

* Use future release api-version for example

* Added flush conn to nsg (Azure#18393)

* Added flush conn to nsg

* Updated flushConn to correct location

* Updated description

* Modified T/F to Enabled/Disabled

* Refactoring so that null value appears first

* Reverted FlushConnection to boolean value instead of string

* Revert "Added flush conn to nsg (Azure#18393)" (Azure#18576)

This reverts commit 6541d305880d1cf580496adc01f55197a01e992c.

* Fixing typo in response of idps private ip range feature (Azure#18574)

* Use common-type api version (Azure#18729)

Co-authored-by: Ben Eshed <[email protected]>

* fix (Azure#18417)

Co-authored-by: Tianen <[email protected]>
Co-authored-by: gk-ms <[email protected]>
Co-authored-by: Khushboo Baheti <[email protected]>
Co-authored-by: Khushboo Baheti <[email protected]>
Co-authored-by: Nilambari <[email protected]>
Co-authored-by: nimaller <[email protected]>
Co-authored-by: pracsb <[email protected]>
Co-authored-by: Prachi Bhavsar <[email protected]>
Co-authored-by: Matthew Yang <[email protected]>
Co-authored-by: utbarn-ms <[email protected]>
Co-authored-by: Ben Eshed <[email protected]>
Co-authored-by: Satya-anshu <[email protected]>
Co-authored-by: bewaterspassover <[email protected]>
Co-authored-by: Ben Eshed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-tool Issues related to the Azure SDK for JS dev-tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants