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.

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 👍

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).

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