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

Update search to enable live testing in sovereign clouds for multiple services #17443

Merged
merged 4 commits into from
Sep 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -53,6 +53,15 @@ export const environmentSetup: RecorderEnvironmentSetup = {
};

export function createClients<IndexModel>(indexName: string): Clients<IndexModel> {
switch (testEnv.AZURE_AUTHORITY_HOST) {
Copy link
Member

Choose a reason for hiding this comment

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

The authority host is not a reliable way to infer the correct scope/endpoint. You can use an Azure Cloud authority host to authenticate into a sovereign cloud resource.

Copy link
Contributor Author

@zzhxiaofeng zzhxiaofeng Sep 18, 2021

Choose a reason for hiding this comment

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

Yeah. Do you mean that using audience option here instead of the authority host to infer the correct endpoint?

Copy link
Member

Choose a reason for hiding this comment

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

@benbp Do you have any ideas about deyaaeldeen's suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

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

@deyaaeldeen and I discussed this offline. We found that the authority host for the public cloud could be used for other clouds for some cognitive services, but that might be a bug and definitely not guaranteed to work with other services. So, you can ignore this comment thread.

For tests, the authority host env variable is set during the ARM template deployment. So, we are good here.

case "https://login.microsoftonline.us":
process.env.ENDPOINT = process.env.ENDPOINT!.toString().replace(".windows.net", ".azure.us");
break;
case "https://login.chinacloudapi.cn":
process.env.ENDPOINT = process.env.ENDPOINT!.toString().replace(".windows.net", ".azure.cn");
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not very sure about this solution. The tests should not be in the business of changing endpoints. If the input to the tests is going to use a different authority host in order to target other clouds, then the endpoint that gets passed in should be different too.

In #17424, we discuss about updating the cognitiveServicesEndpointSuffix such that the output from the template is using the right endpoint. Can we not do the same for search?

cc @benbp

Copy link
Member

Choose a reason for hiding this comment

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

@ramya-rao-a I know I just linked to this, but I agree for test code it should contain as little knowledge as possible about endpoints. They should either be set by the credential builder code, or by the test environment.

Copy link
Member

Choose a reason for hiding this comment

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

@ramya-rao-a Do you want me to revert, or will you take this as a follow-on?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you can log an issue for search, then @sarangan12 can follow up on that

Copy link
Member

Choose a reason for hiding this comment

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

}

const credential = new AzureKeyCredential(testEnv.SEARCH_API_ADMIN_KEY);
const searchClient = new SearchClient<IndexModel>(testEnv.ENDPOINT, indexName, credential);
const indexClient = new SearchIndexClient(testEnv.ENDPOINT, credential);
1 change: 1 addition & 0 deletions sdk/search/search-documents/tests.yml
Original file line number Diff line number Diff line change
@@ -5,3 +5,4 @@ stages:
parameters:
PackageName: "@azure/search-documents"
ServiceDirectory: search
SupportedClouds: 'Public,UsGov,China'
4 changes: 2 additions & 2 deletions sdk/search/test-resources.json
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@
},
"searchSku": {
"type": "string",
"defaultValue": "free",
"defaultValue": "basic",
"metadata": {
"description": "SKU for search resource. The default is 'free'"
"description": "SKU for search resource. The default is 'basic'"
}
}
},