From eb3b63f2762fffbe3540336fc80e3ccf508837be Mon Sep 17 00:00:00 2001 From: Daniel Ortega <96089426+danielortega-msft@users.noreply.github.com> Date: Fri, 18 Feb 2022 10:54:20 -0800 Subject: [PATCH] [Communication] - phone-numbers - Implement a phone number pool for update capabilities live tests (#23116) * Use phone number pool in update capabilities tests * Fix env variable name in pipeline config file --- .../phonenumbers-livetest-matrix.json | 58 +++++++++++++++++++ ...test_phone_number_administration_client.py | 11 +++- ...hone_number_administration_client_async.py | 11 +++- .../tests.yml | 17 ++++-- 4 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json diff --git a/sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json b/sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json new file mode 100644 index 000000000000..8d5f16069bdb --- /dev/null +++ b/sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json @@ -0,0 +1,58 @@ +{ + "displayNames": { + "--disablecov": "", + "false": "", + "true": "" + }, + "matrix": { + "Agent": { + "ubuntu-20.04": { + "OSVmImage": "MMSUbuntu20.04", + "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST": "true" + }, + "windows-2019": { + "OSVmImage": "MMS2019", + "Pool": "azsdk-pool-mms-win-2019-general", + "AZURE_TEST_AGENT": "windows_2019_python36", + "COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST": "false" + }, + "macOS-10.15": { + "OSVmImage": "macOS-10.15", + "Pool": "Azure Pipelines", + "AZURE_TEST_AGENT": "macos_1015_python37", + "COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST": "false" + } + }, + "PythonVersion": ["pypy3.7", "3.6", "3.7", "3.8"], + "CoverageArg": "--disablecov", + "TestSamples": "false" + }, + "include": [ + { + "CoverageConfig": { + "ubuntu2004_39_coverage": { + "OSVmImage": "MMSUbuntu20.04", + "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "PythonVersion": "3.9", + "CoverageArg": "", + "TestSamples": "false", + "AZURE_TEST_AGENT": "ubuntu_2004_python39", + "COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST": "false" + } + } + }, + { + "Config": { + "Ubuntu2004_310": { + "OSVmImage": "MMSUbuntu20.04", + "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "PythonVersion": "3.10.0", + "CoverageArg": "--disablecov", + "TestSamples": "false", + "COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST": "true" + } + } + } + ] +} diff --git a/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client.py b/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client.py index 9fbab939eabc..482511acb5b4 100644 --- a/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client.py +++ b/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client.py @@ -23,7 +23,14 @@ INT_PHONE_NUMBER_TEST_SKIP_REASON = "Phone numbers setting SMS capability does not support in INT. Skip these tests in INT." SKIP_UPDATE_CAPABILITIES_TESTS = os.getenv("COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST", "false") == "true" -SKIP_UPDATE_CAPABILITIES_TESTS_REASON = "Phone number capabilities update does not currently support parallel execution. Skip these tests from live test pipeline." +SKIP_UPDATE_CAPABILITIES_TESTS_REASON = "Phone number capabilities are skipped." + +def get_test_phone_number(): + if SKIP_UPDATE_CAPABILITIES_TESTS: + return os.getenv("AZURE_PHONE_NUMBER") + + test_agent = os.getenv("AZURE_TEST_AGENT") + return os.getenv("AZURE_PHONE_NUMBER_" + test_agent) class PhoneNumbersClientTest(CommunicationTestCase): def setUp(self): @@ -32,7 +39,7 @@ def setUp(self): self.phone_number = "sanitized" self.country_code = "US" else: - self.phone_number = os.getenv("AZURE_PHONE_NUMBER") + self.phone_number = get_test_phone_number() self.country_code = os.getenv("AZURE_COMMUNICATION_SERVICE_COUNTRY_CODE", "US") self.phone_number_client = PhoneNumbersClient.from_connection_string( self.connection_str, diff --git a/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client_async.py b/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client_async.py index 61e4f6826c70..f61d16938c97 100644 --- a/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client_async.py +++ b/sdk/communication/azure-communication-phonenumbers/test/test_phone_number_administration_client_async.py @@ -24,7 +24,14 @@ INT_PHONE_NUMBER_TEST_SKIP_REASON = "Phone numbers setting SMS capability does not support in INT. Skip these tests in INT." SKIP_UPDATE_CAPABILITIES_TESTS = os.getenv("COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST", "false") == "true" -SKIP_UPDATE_CAPABILITIES_TESTS_REASON = "Phone number capabilities update does not currently support parallel execution. Skip these tests from live test pipeline." +SKIP_UPDATE_CAPABILITIES_TESTS_REASON = "Phone number capabilities are skipped." + +def get_test_phone_number(): + if SKIP_UPDATE_CAPABILITIES_TESTS: + return os.getenv("AZURE_PHONE_NUMBER") + + test_agent = os.getenv("AZURE_TEST_AGENT") + return os.getenv("AZURE_PHONE_NUMBER_" + test_agent) class PhoneNumbersClientTestAsync(AsyncCommunicationTestCase): def setUp(self): @@ -33,7 +40,7 @@ def setUp(self): self.phone_number = "sanitized" self.country_code = "US" else: - self.phone_number = os.getenv("AZURE_PHONE_NUMBER") + self.phone_number = get_test_phone_number() self.country_code = os.getenv("AZURE_COMMUNICATION_SERVICE_COUNTRY_CODE", "US") self.phone_number_client = PhoneNumbersClient.from_connection_string( self.connection_str, diff --git a/sdk/communication/azure-communication-phonenumbers/tests.yml b/sdk/communication/azure-communication-phonenumbers/tests.yml index c96477c6a2ea..d72b16973918 100644 --- a/sdk/communication/azure-communication-phonenumbers/tests.yml +++ b/sdk/communication/azure-communication-phonenumbers/tests.yml @@ -3,7 +3,7 @@ trigger: none stages: - template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml parameters: - BuildTargetingString: 'azure-communication-phonenumbers' + BuildTargetingString: "azure-communication-phonenumbers" JobName: phonenumbers ServiceDirectory: communication CloudConfig: @@ -15,9 +15,14 @@ stages: MatrixReplace: - TestSamples=.*/true Int: - SubscriptionConfigurations: - - $(sub-config-communication-int-test-resources-common) - - $(sub-config-communication-int-test-resources-python) + SubscriptionConfigurations: + - $(sub-config-communication-int-test-resources-common) + - $(sub-config-communication-int-test-resources-python) + MatrixReplace: + - COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST=false/true Clouds: Public,Int - EnvVars: - COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST: true + MatrixConfigs: + - Name: PhoneNumbers_python_livetest_matrix + Path: sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json + Selection: sparse + GenerateVMJobs: true