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

[Recorder] Unified recorder prototyping with storage-queue/data-tables SDKs #15826

Merged
merged 117 commits into from
Aug 26, 2021

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Jun 17, 2021

Issue #15829

Leveraging Proxy Tool

    /// Core V1 SDKs - For services depending on core-http
    const recorder = new TestProxyHttpClientCoreV1(file);
    const options: StoragePipelineOptions = {};
    options.httpClient = recorder;
    const client = new QueueServiceClient(env.STORAGE_SAS_URL, undefined, options);
    await recorder.start();
    await client.createQueue((isNode ? "node-" : "browser-") + "1320");
    await recorder.stop();


    /// Core V2 SDKs - For services depending on core-rest-pipeline
    const recorder = new TestProxyHttpClient(file);
    const client = TableClient.fromConnectionString(env.TABLES_SAS_CONNECTION_STRING, "newtable");
    client.pipeline.addPolicy(recorderHttpPolicy(recorder));
    await recorder.start();
    await client.createTable();
    const simpleEntity: TableEntity = createSimpleEntity();
    await client.createEntity(simpleEntity);
    await client.deleteTable();
    await recorder.stop();

Running the proxy server

Run this command

  • docker run -p 5000:5000 azsdkengsys.azurecr.io/engsys/ubuntu_testproxy_server:latest

Reference: https://github.com/Azure/azure-sdk-tools/tree/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy#via-docker-image

To use the proxy-tool in your test, pass this option in cli --test-proxy http://localhost:5000(Make sure the port is same as what you have used to run the docker run command).

Running the tests at test-utils/testing-recorder-new

  • Navigate to the test-utils/testing-recorder-new folder
  • Run rush update && rush build -t .
  • Run rushx test:node
  • Run rushx test:browser
  • [Based on the TEST_MODE, the tests will be run]

Very Next Steps

@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

@HarshaNalluru HarshaNalluru mentioned this pull request Jun 17, 2021
97 tasks
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.

A lot of stuff you're probably already aware of on a first review, mostly nitpicks, couple of things to take a look at. Super excited for this!

sdk/test-utils/recorder-v2/tsconfig.json Outdated Show resolved Hide resolved
sdk/test-utils/recorder-v2/tsconfig.json Outdated Show resolved Hide resolved
sdk/test-utils/recorder-v2/tsconfig.json Outdated Show resolved Hide resolved
sdk/test-utils/recorder-v2/test/test.spec.ts Outdated Show resolved Hide resolved
sdk/test-utils/recorder-v2/src/index.ts Outdated Show resolved Hide resolved
sdk/test-utils/recorder-v2/package.json Outdated Show resolved Hide resolved
sdk/test-utils/recorder-v2/package.json Outdated Show resolved Hide resolved
sdk/test-utils/recorder-v2/package.json Outdated Show resolved Hide resolved
sdk/test-utils/recorder-v2/package.json Outdated Show resolved Hide resolved
sdk/test-utils/recorder-v2/src/index.ts Outdated Show resolved Hide resolved
rush.json Outdated Show resolved Hide resolved
const client = BlobServiceClient.fromConnectionString(connString, options);

// await client.createContainer("harshan-" + `${Math.ceil(Math.random() * 1000) + 1000}`);
await client.createContainer("harshan-1043");
Copy link
Member

Choose a reason for hiding this comment

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

Question.

@HarshaNalluru HarshaNalluru changed the base branch from feature/unified-recorder to main June 23, 2021 21:28
@HarshaNalluru HarshaNalluru force-pushed the harshan/recorder/unified branch from 5f4726c to 62e7e54 Compare July 9, 2021 01:23
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.

I added some comments that I think are valuable. Nonetheless, I think this PR is good! Make sure CI passes and do a final re-read, then take a victory lap 👏 🏏

@mikeharder
Copy link
Member

I think we should provide configureClient() methods like we do for perf:

/**
* configureClientOptionsCoreV1
*
* For core-v1 - libraries depending on core-http
* Apply this method on the client options to get the proxy tool support
*
* Note: httpClient must be part of the options bag, it is required for the perf framework to update the underlying client properly
*/
public configureClientOptionsCoreV1<T>(options: T & { httpClient?: HttpClient }): T {
if (this.parsedOptions["test-proxy"].value) {
this.testProxyHttpClientV1 = getHttpClientV1(this.parsedOptions["test-proxy"].value!);
options.httpClient = this.testProxyHttpClientV1;
}
return options;
}
/**
* configureClient
*
* For core-v2 - libraries depending on core-rest-pipeline
* Apply this method on the client to get the proxy tool support.
*
* Note: Client must expose the pipeline property which is required for the perf framework to add its policies correctly
*/
public configureClient<T>(client: T & { pipeline: Pipeline }): T {
if (this.parsedOptions["test-proxy"].value) {
this.testProxyHttpClient = getHttpClient(this.parsedOptions["test-proxy"].value!);
client.pipeline.addPolicy(testProxyHttpPolicy(this.testProxyHttpClient));
}
return client;
}
}

@HarshaNalluru: Is this what you mean by "Adopt the design that I added for perf framework with proxy-tool"?

@HarshaNalluru
Copy link
Member Author

HarshaNalluru commented Aug 26, 2021

Yes, @mikeharder. But I also want to provide the users with the recorder object to be able to start and stop or do other operations, I thought I would figure out the design later on.

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.

Just some minor comments

"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"rollup-plugin-shim": "^1.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

maybe in a follow-up PR, rollup plugins can be removed from dep list when shared config is used.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding it to the other list

Copy link
Member Author

Choose a reason for hiding this comment

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

});
};
await client.start();
expect(client.recordingId).to.eql(recordingId);
Copy link
Member

Choose a reason for hiding this comment

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

TIL: eql is also valid

options.httpClient = recorder;
const client = new QueueServiceClient(env.STORAGE_SAS_URL, undefined, options);
await recorder.start();
await client.createQueue((isNode ? "node-" : "browser-") + "1320");
Copy link
Member

Choose a reason for hiding this comment

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

would creating queue with the same name fail if running in Live mode multiple times?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. Succeeds, doesn't matter.

Copy link
Member Author

Choose a reason for hiding this comment

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

And the different names here is just to distinguish during the development.

Copy link
Member

Choose a reason for hiding this comment

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

I meant running node tests in Live mode multiple times, it would not fail even node-1320 queue 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.

I got the question, it "succeeds" was the answer for that question. 🙂
(Shouldn't have provided unnecessary details. 🤦‍♂️)

@HarshaNalluru HarshaNalluru enabled auto-merge (squash) August 26, 2021 22:59
@HarshaNalluru
Copy link
Member Author

/check-enforcer override

@HarshaNalluru HarshaNalluru merged commit 85437db into Azure:main Aug 26, 2021
@HarshaNalluru HarshaNalluru deleted the harshan/recorder/unified branch August 26, 2021 23:02
@HarshaNalluru HarshaNalluru restored the harshan/recorder/unified branch August 26, 2021 23:03
@HarshaNalluru HarshaNalluru deleted the harshan/recorder/unified branch August 26, 2021 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants