Skip to content

Commit c7bd4b8

Browse files
authored
fix(playwrighttesting): use runsetting defaults in GetConnectOptionsAsync (#47124)
* fix(playwrighttesting): use runsetting defaults in GetConnectOptionsAsync * fix(): set environment variable defaults in class members * chore(): add tests for multiple initialization scenario --------- Co-authored-by: Siddharth Singha Roy <[email protected]>
1 parent 1f65c15 commit c7bd4b8

File tree

14 files changed

+328
-60
lines changed

14 files changed

+328
-60
lines changed

sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.NUnit/src/PlaywrightServiceNUnit.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ public void Teardown()
6767
{
6868
return null;
6969
}
70-
else if (os!.Equals("Windows", System.StringComparison.OrdinalIgnoreCase))
70+
else if (os!.Equals("Windows", StringComparison.OrdinalIgnoreCase))
7171
{
7272
return OSPlatform.Windows;
7373
}
74-
else if (os.Equals("Linux", System.StringComparison.OrdinalIgnoreCase))
74+
else if (os.Equals("Linux", StringComparison.OrdinalIgnoreCase))
7575
{
7676
return OSPlatform.Linux;
7777
}

sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/api/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.netstandard2.0.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ public partial class PlaywrightService
1010
{
1111
public PlaywrightService(Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.PlaywrightServiceOptions playwrightServiceOptions, Azure.Core.TokenCredential? credential = null) { }
1212
public PlaywrightService(System.Runtime.InteropServices.OSPlatform? os = default(System.Runtime.InteropServices.OSPlatform?), string? runId = null, string? exposeNetwork = null, string? serviceAuth = null, bool? useCloudHostedBrowsers = default(bool?), Azure.Core.TokenCredential? credential = null) { }
13+
public string? ExposeNetwork { get { throw null; } set { } }
14+
public System.Runtime.InteropServices.OSPlatform? Os { get { throw null; } set { } }
1315
public System.Threading.Timer? RotationTimer { get { throw null; } set { } }
16+
public string? RunId { get { throw null; } set { } }
1417
public string ServiceAuth { get { throw null; } set { } }
1518
public static string? ServiceEndpoint { get { throw null; } }
1619
public bool UseCloudHostedBrowsers { get { throw null; } set { } }

sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Constants.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Utility;
54
using System.Collections.Generic;
65
using System.Text.RegularExpressions;
76

@@ -212,9 +211,10 @@ internal class Constants
212211
internal static readonly string s_workspace_mismatch_error = "The provided access token does not match the specified workspace URL. Please verify that both values are correct.";
213212
internal static readonly string s_invalid_service_endpoint_error_message = "The service endpoint provided is invalid. Please verify the endpoint URL and try again.";
214213

215-
internal static readonly string s_playwright_service_disable_scalable_execution_environment_variable = "PLAYWRIGHT_SERVICE_DISABLE_SCALABLE_EXECUTION";
216-
internal static readonly string s_playwright_service_reporting_url_environment_variable = "PLAYWRIGHT_SERVICE_REPORTING_URL";
217-
internal static readonly string s_playwright_service_workspace_id_environment_variable = "PLAYWRIGHT_SERVICE_WORKSPACE_ID";
214+
internal static readonly string s_playwright_service_disable_scalable_execution_environment_variable = "_MPT_DISABLE_SCALABLE_EXECUTION";
215+
internal static readonly string s_playwright_service_reporting_url_environment_variable = "_MPT_REPORTING_URL";
216+
internal static readonly string s_playwright_service_workspace_id_environment_variable = "_MPT_WORKSPACE_ID";
217+
internal static readonly string s_playwright_service_auth_type_environment_variable = "_MPT_AUTH_TYPE";
218218
}
219219

220220
internal class OSConstants
@@ -234,8 +234,8 @@ internal class ReporterConstants
234234
internal static readonly string s_reportingRoute = "/runs/";
235235
internal static readonly string s_reportingAPIVersion_2024_04_30_preview = "2024-04-30-preview";
236236
internal static readonly string s_reportingAPIVersion_2024_05_20_preview = "2024-05-20-preview";
237-
internal static readonly string s_pLAYWRIGHT_SERVICE_REPORTING_URL = "PLAYWRIGHT_SERVICE_REPORTING_URL";
238-
internal static readonly string s_pLAYWRIGHT_SERVICE_WORKSPACE_ID = "PLAYWRIGHT_SERVICE_WORKSPACE_ID";
237+
internal static readonly string s_pLAYWRIGHT_SERVICE_REPORTING_URL = "_MPT_REPORTING_URL";
238+
internal static readonly string s_pLAYWRIGHT_SERVICE_WORKSPACE_ID = "_MPT_WORKSPACE_ID";
239239
internal static readonly string s_aPPLICATION_JSON = "application/json";
240240
internal static readonly string s_cONFLICT_409_ERROR_MESSAGE = "Test run with id {runId} already exists. Provide a unique run id.";
241241
internal static readonly string s_cONFLICT_409_ERROR_MESSAGE_KEY = "DuplicateRunId";

sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Implementation/BlobService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
using System;
5-
using System.Collections.Generic;
65
using System.Text;
76
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Interface;
87
using Azure.Storage.Blobs;

sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Implementation/ServiceClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
3+
34
using System;
45
using Azure.Core.Serialization;
56
using Azure.Core;

sdk/playwrighttesting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/PlaywrightReporter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
77
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
88
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
9-
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
109
using System;
1110
using System.Collections.Generic;
1211
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Interface;
1312
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Implementation;
1413
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Processor;
1514
using Microsoft.IdentityModel.JsonWebTokens;
16-
using Microsoft.IdentityModel.Tokens;
1715

1816
namespace Azure.Developer.MicrosoftPlaywrightTesting.TestLogger;
1917

@@ -100,6 +98,8 @@ internal void InitializePlaywrightReporter(string xmlSettings)
10098
runParameters.TryGetValue(RunSettingKey.ManagedIdentityClientId, out var managedIdentityClientId);
10199
runParameters.TryGetValue(RunSettingKey.EnableGitHubSummary, out var enableGithubSummary);
102100
runParameters.TryGetValue(RunSettingKey.EnableResultPublish, out var enableResultPublish);
101+
runParameters.TryGetValue(RunSettingKey.Os, out var osType);
102+
runParameters.TryGetValue(RunSettingKey.ExposeNetwork, out var exposeNetwork);
103103
nunitParameters.TryGetValue(RunSettingKey.NumberOfTestWorkers, out var numberOfTestWorkers);
104104
string? enableGithubSummaryString = enableGithubSummary?.ToString();
105105
string? enableResultPublishString = enableResultPublish?.ToString();
@@ -110,7 +110,7 @@ internal void InitializePlaywrightReporter(string xmlSettings)
110110
PlaywrightServiceOptions? playwrightServiceSettings;
111111
try
112112
{
113-
playwrightServiceSettings = new(runId: runId?.ToString(), serviceAuth: serviceAuth?.ToString(), azureTokenCredentialType: azureTokenCredential?.ToString(), managedIdentityClientId: managedIdentityClientId?.ToString());
113+
playwrightServiceSettings = new(runId: runId?.ToString(), serviceAuth: serviceAuth?.ToString(), azureTokenCredentialType: azureTokenCredential?.ToString(), managedIdentityClientId: managedIdentityClientId?.ToString(), os: PlaywrightService.GetOSPlatform(osType?.ToString()), exposeNetwork: exposeNetwork?.ToString());
114114
}
115115
catch (Exception ex)
116116
{

0 commit comments

Comments
 (0)