Skip to content

[Key Vault] Fixing min-max tests by moving test utilities to test/public#19959

Merged
sadasant merged 28 commits intoAzure:mainfrom
sadasant:fix14955
Jan 29, 2022
Merged

[Key Vault] Fixing min-max tests by moving test utilities to test/public#19959
sadasant merged 28 commits intoAzure:mainfrom
sadasant:fix14955

Conversation

@sadasant
Copy link
Contributor

@sadasant sadasant commented Jan 21, 2022

This PR focuses on moving the test utilities on the Key Vault packages from test/utils to test/public/utils, with the caveat that any references to non-public API would need to either be copied to test/public/ somewhere, or moved to test/internal.

Fixes #14955

@sadasant sadasant self-assigned this Jan 21, 2022
@ghost ghost added the KeyVault label Jan 21, 2022
Copy link
Member

@KarishmaGhiya KarishmaGhiya left a comment

Choose a reason for hiding this comment

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

sorry i didn't notice the ci failing. had approved since the min-max tests pass

@sadasant sadasant marked this pull request as ready for review January 21, 2022 22:21
@sadasant sadasant requested a review from maorleger as a code owner January 21, 2022 22:21
@sadasant sadasant changed the title [Key Vault] Fixing 14955 [Key Vault] Fixing min-max tests by moving test utilities to test/public Jan 21, 2022
@sadasant
Copy link
Contributor Author

/azp run js - keyvault-certificates - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@maorleger maorleger left a comment

Choose a reason for hiding this comment

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

Thanks so much for taking this effort! I left a few comments but I have some open-ended questions / concerns if you don't mind

  1. Requiring utils to be in public folder feels implicit and brittle since nothing lets me know if I don't follow this convention. I can definitely imagine a situation where I break this in the future. Are there any options to encode this into a linter or CI validation or something? @KarishmaGhiya
  2. It sounds like the outcome of not doing this is that test coverage gets missed in min/max testing is that right? If so, let's run a live test against this PR for each of the KV libraries and make sure that our min/max builds run significantly more tests now than in the latest main scheduled builds - if we didn't improve maybe we don't need to bother?

/**
* The latest supported KeyVault service API version
*/
export const LATEST_API_VERSION = "7.3-preview";
Copy link
Member

Choose a reason for hiding this comment

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

Can we infer this from https://github.com/Azure/azure-sdk-for-js/pull/19959/files#diff-8182aee8eae78191aaa9301924729aafe2786e1f58fd5bd5bc31af8c28405d23R43 instead of redefining it? I just worry about having yet another place to change you know?

import { BeginRestoreKeyBackupOptions } from "../../public/utils/lro/restore/operation";
import TestClient from "../../public/utils/testClient";

export default class InternalTestClient extends TestClient {
Copy link
Member

Choose a reason for hiding this comment

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

Where is this used? If only like a one or two places can we just remove this class and inline this logic in the test or make a helper function in the test file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I like the idea of inlining this!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We talked over teams. Here’s what I’ll do:

This class is intended to help us do some common functionality on many tests. This specific extension is only used in one test, so we can grab the internals of this extra function and move it to the test directly, then remove this class.

I’ll do that!

export async function authenticate(
that: Context,
version: string,
testClientMaker?: (client: KeyClient) => TestClientInterface
Copy link
Member

Choose a reason for hiding this comment

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

This feels a little odd to me - what is this used for? Sorry, I forgot 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it’s to allow for the replacement of the TestClient with the InternalTestClient. The TestClient at the moment has some private references.

purgeKey: (keyName: string) => Promise<void>;
flushKey: (keyName: string) => Promise<void>;
}
export default class TestClient implements TestClientInterface {
Copy link
Member

Choose a reason for hiding this comment

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

I have a proposal! instead of formatName let's just use recorder.getUniqueName. And then let's just get rid of calls to flushKey and purgeKey - I've been doing that to make our tests faster since the KV gets created and deleted anyway. Then we won't need the testClient at all. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I love that idea! Thank you 🙏 I’ll take it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait, the main point of this test is to restore a key backup, so the unique name won’t help 🤔 I do the purge to then recover the backup. Let’s sync over teams!

/**
* The latest supported KeyVault service API version
*/
export const LATEST_API_VERSION = "7.3-preview";
Copy link
Member

Choose a reason for hiding this comment

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

We can infer this from https://github.com/Azure/azure-sdk-for-js/pull/19959/files#diff-c3564ec34ef1be7b6ff757d6352c4dc035b76e9fea338b9dad4298414d2a8b03L27 as well - sorry for repeating myself I just wanted to make sure it doesn't get missed

@sadasant
Copy link
Contributor Author

@maorleger the min-max tests at the moment only includes the public tests it can run (meaning, that don’t have any internal reference). This PR does increase the number of min-max tests that the Key Vault projects run.

The min-max test tooling is rather simple, which should help with maintenance, but I agree that it would be interesting to do a re-engeneering of it, to behave more like our samples tooling.

@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

@sadasant sadasant requested a review from maorleger January 27, 2022 22:09
Copy link
Member

@maorleger maorleger left a comment

Choose a reason for hiding this comment

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

🚀 thank you for taking this on!

import { testPollerProperties } from "./recorderUtils";
import { KeyClient } from "../../../src";

export interface TestClientInterface {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think this interface is no longer necessary

@maorleger
Copy link
Member

/azp run js - keyvault-keys - tests

@maorleger
Copy link
Member

/azp run js - keyvault-certificates - tests

@sadasant
Copy link
Contributor Author

/azp run js - keyvault-keys - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sadasant
Copy link
Contributor Author

CI Passed! I’ll merge this.

@sadasant sadasant merged commit cba4a9b into Azure:main Jan 29, 2022
@sadasant sadasant deleted the fix14955 branch January 29, 2022 02:07
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-js that referenced this pull request Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Key Vault] Move the public test utilities into the public folder