From 8545cde7f73a5e209917be32f12be5baa432f388 Mon Sep 17 00:00:00 2001 From: Daniel Ortega <96089426+danielortega-msft@users.noreply.github.com> Date: Fri, 18 Feb 2022 14:37:15 -0800 Subject: [PATCH] [Communication] - PhoneNumbers - Require phone number pool in livetests (#27093) * Require phone number pool in livetests * Fix conditional statement with the correct value * Fix formatting --- .../tests/CommunicationTestEnvironment.cs | 12 +++--------- .../phone-numbers-livetest-matrix.json | 11 ++++------- .../Infrastructure/PhoneNumbersClientLiveTestBase.cs | 10 +++++++--- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/sdk/communication/Azure.Communication.Common/tests/CommunicationTestEnvironment.cs b/sdk/communication/Azure.Communication.Common/tests/CommunicationTestEnvironment.cs index 6bf1cae15d05..1ffa07ee7231 100644 --- a/sdk/communication/Azure.Communication.Common/tests/CommunicationTestEnvironment.cs +++ b/sdk/communication/Azure.Communication.Common/tests/CommunicationTestEnvironment.cs @@ -31,7 +31,7 @@ public class CommunicationTestEnvironment : TestEnvironment public string LiveTestStaticAccessKey => Core.ConnectionString.Parse(LiveTestStaticConnectionString).GetRequired("accesskey"); - public string CommunicationTestPhoneNumber => GetPhoneNumberByTestAgent() ?? GetRecordedVariable(AzurePhoneNumber, options => options.IsSecret("+14255550123")); + public string DefaultTestPhoneNumber => GetRecordedVariable(AzurePhoneNumber, options => options.IsSecret("+14255550123")); public string SkipSmsTest => GetOptionalVariable(SkipIntSmsTestEnvironmentVariableName) ?? "False"; @@ -41,14 +41,8 @@ public class CommunicationTestEnvironment : TestEnvironment public bool ShouldIgnorePhoneNumbersTests => bool.Parse(SkipPhoneNumbersTest); - public string AzureTestAgent => GetOptionalVariable(AzureTestAgentVariableName); + public string TestAgentPhoneNumber => GetRecordedVariable($"{AzurePhoneNumber}_{AzureTestAgent}", options => options.IsSecret("+14255550123")); - private string? GetPhoneNumberByTestAgent() - { - if (AzureTestAgent == null) - return null; - - return GetRecordedOptionalVariable($"{AzurePhoneNumber}_{AzureTestAgent}", options => options.IsSecret("+14255550123")); - } + private string AzureTestAgent => GetVariable(AzureTestAgentVariableName); } } diff --git a/sdk/communication/Azure.Communication.PhoneNumbers/phone-numbers-livetest-matrix.json b/sdk/communication/Azure.Communication.PhoneNumbers/phone-numbers-livetest-matrix.json index 17e5ffb130a5..e69e140cfc57 100644 --- a/sdk/communication/Azure.Communication.PhoneNumbers/phone-numbers-livetest-matrix.json +++ b/sdk/communication/Azure.Communication.PhoneNumbers/phone-numbers-livetest-matrix.json @@ -36,24 +36,21 @@ "OSVmImage": "macOS-10.15", "Pool": "Azure Pipelines", "TestTargetFramework": "netcoreapp3.1", - "AZURE_PHONE_NUMBER_ID": "2", - "SKIP_UPDATE_CAPABILITIES_LIVE_TESTS": "FALSE" + "SKIP_UPDATE_CAPABILITIES_LIVE_TESTS": "TRUE" }, "macOS-10.15_NET6.0": { "OSVmImage": "macOS-10.15", "Pool": "Azure Pipelines", "TestTargetFramework": "net6.0", - "AZURE_TEST_AGENT": "macos_1015_net60" + "AZURE_TEST_AGENT": "macos_1015_net60", + "SKIP_UPDATE_CAPABILITIES_LIVE_TESTS": "FALSE" } }, "AdditionalTestArguments": [ "/p:UseProjectReferenceToAzureClients=false", "/p:UseProjectReferenceToAzureClients=true" ], - "BuildConfiguration": [ - "Debug", - "Release" - ] + "BuildConfiguration": ["Debug", "Release"] }, "include": [ { diff --git a/sdk/communication/Azure.Communication.PhoneNumbers/tests/Infrastructure/PhoneNumbersClientLiveTestBase.cs b/sdk/communication/Azure.Communication.PhoneNumbers/tests/Infrastructure/PhoneNumbersClientLiveTestBase.cs index 0855cd53dfe1..1413e46072d7 100644 --- a/sdk/communication/Azure.Communication.PhoneNumbers/tests/Infrastructure/PhoneNumbersClientLiveTestBase.cs +++ b/sdk/communication/Azure.Communication.PhoneNumbers/tests/Infrastructure/PhoneNumbersClientLiveTestBase.cs @@ -86,9 +86,13 @@ protected PhoneNumbersClient CreateClient(AuthMethod authMethod = AuthMethod.Con protected string GetTestPhoneNumber() { - return TestEnvironment.Mode == RecordedTestMode.Playback - ? RecordedTestSanitizer.SanitizeValue - : TestEnvironment.CommunicationTestPhoneNumber; + if (TestEnvironment.Mode == RecordedTestMode.Playback) + return RecordedTestSanitizer.SanitizeValue; + + if (!SkipUpdateCapabilitiesLiveTest) + return TestEnvironment.TestAgentPhoneNumber; + + return TestEnvironment.DefaultTestPhoneNumber; } protected void SleepIfNotInPlaybackMode()