Skip to content

Commit a596137

Browse files
authored
Update Search to enable live testing in sovereign clouds for multiple… (Azure#23005)
* Update Search to enable live testing in sovereign clouds for multiple services * resolve ci error * update * update * update
1 parent 6c19fbd commit a596137

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

sdk/search/azure-search-documents/tests/search_service_preparer.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
from azure.core.credentials import AzureKeyCredential
1919
from azure.core.exceptions import ResourceNotFoundError
2020

21-
22-
SERVICE_URL_FMT = "https://{}.search.windows.net/indexes?api-version=2021-04-30-Preview"
21+
SERVICE_URL_FMT = "https://{}.{}/indexes?api-version=2021-04-30-Preview"
2322
TIME_TO_SLEEP = 3
24-
23+
SEARCH_ENDPOINT_SUFFIX = environ.get("SEARCH_ENDPOINT_SUFFIX", "servicebus.windows.net")
2524

2625
SearchEnvVarPreparer = functools.partial(
2726
EnvironmentVariableLoader,
@@ -82,7 +81,7 @@ def _set_up_index(service_name, endpoint, api_key, schema, index_batch):
8281
if schema:
8382
index_name = json.loads(schema)["name"]
8483
response = requests.post(
85-
SERVICE_URL_FMT.format(service_name),
84+
SERVICE_URL_FMT.format(service_name, SEARCH_ENDPOINT_SUFFIX),
8685
headers={"Content-Type": "application/json", "api-key": api_key},
8786
data=schema,
8887
)
@@ -207,7 +206,7 @@ def create_resource(self, name, **kwargs):
207206
else:
208207
schema = None
209208
self.service_name = self.create_random_name()
210-
self.endpoint = "https://{}.search.windows.net".format(self.service_name)
209+
self.endpoint = "https://{}.{}".format(self.service_name, SEARCH_ENDPOINT_SUFFIX)
211210

212211
if not self.is_live:
213212
return {
@@ -254,7 +253,7 @@ def create_resource(self, name, **kwargs):
254253

255254
if self.schema:
256255
response = requests.post(
257-
SERVICE_URL_FMT.format(self.service_name),
256+
SERVICE_URL_FMT.format(self.service_name, SEARCH_ENDPOINT_SUFFIX),
258257
headers={"Content-Type": "application/json", "api-key": api_key},
259258
data=self.schema,
260259
)
@@ -357,7 +356,7 @@ def create_resource(self, name, **kwargs):
357356
else:
358357
schema = None
359358
self.service_name = self.create_random_name()
360-
self.endpoint = "https://{}.search.windows.net".format(self.service_name)
359+
self.endpoint = "https://{}.{}".format(self.service_name, SEARCH_ENDPOINT_SUFFIX)
361360

362361
if not self.is_live:
363362
return {
@@ -404,7 +403,7 @@ def create_resource(self, name, **kwargs):
404403

405404
if self.schema:
406405
response = requests.post(
407-
SERVICE_URL_FMT.format(self.service_name),
406+
SERVICE_URL_FMT.format(self.service_name, SEARCH_ENDPOINT_SUFFIX),
408407
headers={"Content-Type": "application/json", "api-key": api_key},
409408
data=self.schema,
410409
)
@@ -507,7 +506,7 @@ def create_resource(self, name, **kwargs):
507506
else:
508507
schema = None
509508
self.service_name = self.create_random_name()
510-
self.endpoint = "https://{}.search.windows.net".format(self.service_name)
509+
self.endpoint = "https://{}.{}".format(self.service_name, SEARCH_ENDPOINT_SUFFIX)
511510

512511
if not self.is_live:
513512
return {
@@ -554,7 +553,7 @@ def create_resource(self, name, **kwargs):
554553

555554
if self.schema:
556555
response = requests.post(
557-
SERVICE_URL_FMT.format(self.service_name),
556+
SERVICE_URL_FMT.format(self.service_name, SEARCH_ENDPOINT_SUFFIX),
558557
headers={"Content-Type": "application/json", "api-key": api_key},
559558
data=self.schema,
560559
)
@@ -657,7 +656,7 @@ def create_resource(self, name, **kwargs):
657656
else:
658657
schema = None
659658
self.service_name = self.create_random_name()
660-
self.endpoint = "https://{}.search.windows.net".format(self.service_name)
659+
self.endpoint = "https://{}.{}".format(self.service_name, SEARCH_ENDPOINT_SUFFIX)
661660

662661
if not self.is_live:
663662
return {
@@ -704,7 +703,7 @@ def create_resource(self, name, **kwargs):
704703

705704
if self.schema:
706705
response = requests.post(
707-
SERVICE_URL_FMT.format(self.service_name),
706+
SERVICE_URL_FMT.format(self.service_name, SEARCH_ENDPOINT_SUFFIX),
708707
headers={"Content-Type": "application/json", "api-key": api_key},
709708
data=self.schema,
710709
)

sdk/search/test-resources.bicep

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
param isPublicCloud bool = environment().name == 'AzureCloud'
12
param searchEndpointSuffix string = 'search.windows.net'
23
param storageEndpointSuffix string = 'core.windows.net'
34
param location string = '${resourceGroup().location}'
@@ -8,15 +9,16 @@ param storageAccountName string = 'storage${uniqueString(resourceGroup().id)}'
89
param storageContainerName string = 'storage-container-${resourceGroup().name}'
910
param storageApiVersion string = '2021-06-01'
1011

12+
1113
resource searchService 'Microsoft.Search/searchServices@2021-04-01-Preview' = {
1214
name: searchServiceName
13-
location: 'eastus2' // semantic search is available here
15+
location: location // semantic search is available here
1416
sku: {
1517
name: searchSku
1618
}
17-
properties: {
19+
properties: isPublicCloud ? {
1820
semanticSearch: 'standard'
19-
}
21+
} : {}
2022
}
2123

2224
resource storageService 'Microsoft.Storage/storageAccounts@2021-06-01' = {
@@ -46,3 +48,4 @@ output search_query_api_key string = searchService.listQueryKeys(searchApiVersio
4648
output search_service_name string = searchServiceName
4749
output search_storage_connection_string string = 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};AccountKey=${storageService.listKeys(storageApiVersion).keys[0].value};EndpointSuffix=${storageEndpointSuffix}'
4850
output search_storage_container_name string = storageContainerName
51+
output search_endpoint_suffix string = searchEndpointSuffix

sdk/search/tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ stages:
66
BuildTargetingString: azure-search-documents
77
# TODO: change/remove location back to default westus2 after search RP fixes deletion metadata issue
88
# https://github.com/Azure/azure-sdk-tools/issues/2216
9-
Location: 'eastus2'
9+
SupportedClouds: 'Public,UsGov,China'
10+
CloudConfig:
11+
Public:
12+
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
13+
Location: 'eastus2'
14+
UsGov:
15+
SubscriptionConfiguration: $(sub-config-gov-test-resources)
16+
China:
17+
SubscriptionConfiguration: $(sub-config-cn-test-resources)
1018
ServiceDirectory: search
1119
EnvVars:
1220
AZURE_CLIENT_ID: $(SEARCH_CLIENT_ID)

0 commit comments

Comments
 (0)