Skip to content
Merged
Show file tree
Hide file tree
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
40 changes: 30 additions & 10 deletions eng/pipelines/templates/jobs/live.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ parameters:
- name: ServiceDirectory
type: string
default: ''
- name: TestResourceDirectories
type: object
default:
- name: PreSteps
type: object
default: []
Expand Down Expand Up @@ -99,12 +102,21 @@ jobs:
SubscriptionConfiguration: ${{ parameters.CloudConfig.SubscriptionConfiguration }}
SubscriptionConfigurations: ${{ parameters.CloudConfig.SubscriptionConfigurations }}

- template: /eng/common/TestResources/deploy-test-resources.yml
parameters:
Location: ${{ coalesce(parameters.Location, parameters.CloudConfig.Location) }}
ServiceDirectory: '${{ parameters.ServiceDirectory }}'
SubscriptionConfiguration: $(SubscriptionConfiguration)
ArmTemplateParameters: $(ArmTemplateParameters)
- ${{ if parameters.TestResourceDirectories }}:
- ${{ each directory in parameters.TestResourceDirectories }}:
- template: /eng/common/TestResources/deploy-test-resources.yml
parameters:
Location: ${{ coalesce(parameters.Location, parameters.CloudConfig.Location) }}
ServiceDirectory: '${{ directory }}'
SubscriptionConfiguration: $(SubscriptionConfiguration)
ArmTemplateParameters: $(ArmTemplateParameters)
- ${{ if not(parameters.TestResourceDirectories) }}:
- template: /eng/common/TestResources/deploy-test-resources.yml
parameters:
Location: ${{ coalesce(parameters.Location, parameters.CloudConfig.Location) }}
ServiceDirectory: '${{ parameters.ServiceDirectory }}'
SubscriptionConfiguration: $(SubscriptionConfiguration)
ArmTemplateParameters: $(ArmTemplateParameters)

- template: ../steps/build-test.yml
parameters:
Expand All @@ -125,7 +137,15 @@ jobs:
BuildDocs: ${{ parameters.BuildDocs }}
TestProxy: ${{ parameters.TestProxy }}

- template: /eng/common/TestResources/remove-test-resources.yml
parameters:
ServiceDirectory: '${{ parameters.ServiceDirectory }}'
SubscriptionConfiguration: $(SubscriptionConfiguration)

- ${{ if parameters.TestResourceDirectories }}:
- ${{ each directory in parameters.TestResourceDirectories }}:
- template: /eng/common/TestResources/remove-test-resources.yml
parameters:
ServiceDirectory: '${{ directory }}'
SubscriptionConfiguration: $(SubscriptionConfiguration)
- ${{ if not(parameters.TestResourceDirectories) }}:
- template: /eng/common/TestResources/remove-test-resources.yml
parameters:
ServiceDirectory: '${{ parameters.ServiceDirectory }}'
SubscriptionConfiguration: $(SubscriptionConfiguration)
4 changes: 4 additions & 0 deletions eng/pipelines/templates/stages/archetype-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ parameters:
- name: ServiceDirectory
type: string
default: ''
- name: TestResourceDirectories
type: object
default:
- name: PreSteps
type: object
default: []
Expand Down Expand Up @@ -105,6 +108,7 @@ stages:
JobTemplatePath: /eng/pipelines/templates/jobs/live.tests.yml
AdditionalParameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
TestResourceDirectories: ${{ parameters.TestResourceDirectories }}
PreSteps:
- ${{ parameters.PlatformPreSteps }}
- ${{ parameters.PreSteps }}
Expand Down
6 changes: 5 additions & 1 deletion sdk/communication/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ If the tests are successful, we can proceed to run the tests in LIVE mode.

Because in LIVE mode we are hitting an actual resource, we must set the appropriate environment variable to make sure the code tests against the resource we want. Set up an env variable called `COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING` (just needed for SMS and Phone Numbers SDKs) and set it to the connection string of the resource you want to test against.

Depending on which package you are testing, it may need special environment variables to test succesfully. The names of these variables can be found inside each test file in the `setUp()` function. Make sure to set these variables before running the tests themselves. You may need to restart your development environment after creating or updating these environment variables.
Depending on which package you are testing, it may need special environment variables to test successfully. The names of these variables can be found inside each test file in the `setUp()` function. Make sure to set these variables before running the tests themselves. You may need to restart your development environment after creating or updating these environment variables.

You can run the `pytest .` command after setting the `AZURE_TEST_RUN_LIVE` variable to `true`.

Expand All @@ -50,6 +50,10 @@ If you are testing against a personal resource, you can check the [Managed Ident

For a more in-depth look on how to authenticate using managed identity, refer to the [Azure Identity client library for Python](https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python) documentation. This document also has more ways for you to authenticate using the DefaultAzureCredential object besides the ones we discussed in this contributing file.

### Running the New-TestResources and Remove-TestResources Scripts

You may want to run the `New-TestResources.ps1` or `Remove-TestResources.ps1` scripts to test resource deployments in the SDK Live Test pipelines locally. You will need to add the additional `-TestResourceDirectories` parameter when running these scripts. If you are using the shared `test-resources.json` you can point to `communication/test-resources/`. If you are using a custom `test-resources.json`, you can point to `communication/<package-name>/test-resources.json`.

## Submitting a Pull Request

The easiest way for you to test and not worry about any breaking changes you may cause is to create a fork from the [Python Azure SDK repo](https://github.com/Azure/azure-sdk-for-python). After downloading your repo, make sure to add the original repo as an upstream. To do this, use the `git remote add upstream` command followed by the repo's URL.
Expand Down
2 changes: 2 additions & 0 deletions sdk/communication/azure-communication-chat/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ stages:
- $(sub-config-communication-int-test-resources-common)
- $(sub-config-communication-int-test-resources-python)
Clouds: Public,Int
TestResourceDirectories:
- communication/test-resources/
12 changes: 11 additions & 1 deletion sdk/communication/azure-communication-email/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ stages:
- $(sub-config-azure-cloud-test-resources)
- $(sub-config-communication-services-cloud-test-resources-common)
- $(sub-config-communication-services-cloud-test-resources-python)
Int:
SubscriptionConfigurations:
- $(sub-config-communication-int-test-resources-common)
- $(sub-config-communication-int-test-resources-python)
PPE:
SubscriptionConfigurations:
- $(sub-config-communication-ppe-test-resources-common)
- $(sub-config-communication-ppe-test-resources-python)
MatrixReplace:
- TestSamples=.*/true
Clouds: Public
Clouds: 'Public,PPE,Int'
EnvVars:
AZURE_SKIP_LIVE_RECORDING: 'True'
AZURE_TEST_RUN_LIVE: 'true'
TestResourceDirectories:
- communication/azure-communication-email/
2 changes: 2 additions & 0 deletions sdk/communication/azure-communication-identity/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ stages:
EnvVars:
AZURE_SKIP_LIVE_RECORDING: 'True'
AZURE_TEST_RUN_LIVE: 'true'
TestResourceDirectories:
- communication/test-resources/
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ stages:
- $(sub-config-communication-int-test-resources-common)
- $(sub-config-communication-int-test-resources-python)
Clouds: Public
TestResourceDirectories:
- communication/test-resources/
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ stages:
Path: sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json
Selection: sparse
GenerateVMJobs: true
TestResourceDirectories:
- communication/test-resources/
2 changes: 2 additions & 0 deletions sdk/communication/azure-communication-rooms/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ stages:
- $(sub-config-communication-int-test-resources-common)
- $(sub-config-communication-int-test-resources-python)
Clouds: Public,Int
TestResourceDirectories:
- communication/test-resources/

2 changes: 2 additions & 0 deletions sdk/communication/azure-communication-sms/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ stages:
EnvVars:
AZURE_SKIP_LIVE_RECORDING: 'True'
AZURE_TEST_RUN_LIVE: 'True'
TestResourceDirectories:
- communication/test-resources/
100 changes: 100 additions & 0 deletions sdk/communication/test-resources/test-resources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"baseName": {
"type": "string",
"defaultValue": "[resourceGroup().name]",
"metadata": {
"description": "The base resource name."
}
},
"endpointPrefix": {
"defaultValue": "communication",
"type": "string"
},
"communicationServicesEndpointSuffix": {
"defaultValue": ".communication.azure.com",
"type": "string"
},
"testApplicationOid": {
"type": "string",
"metadata": {
"description": "The client OID to grant access to test resources."
}
},
"tenantId": {
"type": "String",
"metadata": {
"description": "The tenant id to which the application and resources belong."
}
},
"testApplicationId": {
"type": "String",
"metadata": {
"description": "The application client id used to run tests."
}
},
"testApplicationSecret": {
"type": "String",
"metadata": {
"description": "The application client secret used to run tests."
}
}
},
"variables": {
"uniqueSubDomainName": "[format('{0}-{1}', parameters('baseName'), parameters('endpointPrefix'))]",
"contributorRoleId": "b24988ac-6180-42a0-ab88-20f7382dd24c"
},
"resources": [
{
"type": "Microsoft.Communication/CommunicationServices",
"apiVersion": "2020-08-20-preview",
"name": "[variables('uniqueSubDomainName')]",
"location": "global",
"properties": {
"dataLocation": "UnitedStates"
}
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2019-04-01-preview",
"name": "[guid(resourceGroup().id, deployment().name, parameters('baseName'), variables('contributorRoleId'))]",
"properties": {
"roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('contributorRoleId'))]",
"principalId": "[parameters('testApplicationOid')]",
"scope": "[resourceGroup().id]"
}
}
],
"outputs": {
"AZURE_TENANT_ID": {
"type": "String",
"value": "[parameters('tenantId')]"
},
"AZURE_CLIENT_ID": {
"type": "String",
"value": "[parameters('testApplicationId')]"
},
"AZURE_CLIENT_SECRET": {
"type": "String",
"value": "[parameters('testApplicationSecret')]"
},
"COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.Communication/CommunicationServices',variables('uniqueSubDomainName')), '2021-10-01-preview').primaryConnectionString]"
},
"COMMUNICATION_SERVICE_ENDPOINT": {
"type": "string",
"value": "[concat('https://', parameters('baseName'), '-', parameters('endpointPrefix'), parameters('communicationServicesEndpointSuffix'))]"
},
"COMMUNICATION_SERVICE_ACCESS_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.Communication/CommunicationServices',variables('uniqueSubDomainName')), '2021-10-01-preview').primaryKey]"
},
"RESOURCE_GROUP_NAME": {
"type": "string",
"value": "[resourceGroup().Name]"
}
}
}
5 changes: 5 additions & 0 deletions sdk/communication/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ parameters:
- azure-communication-sms
- azure-communication-jobrouter
- azure-communication-callautomation
- name: TestResourceDirectories
type: object
default:
- communication/test-resources/

stages:
- ${{ each service in parameters.Services }}:
Expand All @@ -23,6 +27,7 @@ stages:
# All 5 service stages run in parallel, and with no parallel limits the tests may get throttled.
MaxParallel: 2
ServiceDirectory: communication
TestResourceDirectories: ${{ parameters.TestResourceDirectories }}

${{ if contains(service, 'phonenumbers') }}:
CloudConfig:
Expand Down