Skip to content

Commit

Permalink
fix(playwrighttesting): use runsetting defaults in GetConnectOptionsA…
Browse files Browse the repository at this point in the history
…sync (#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 <ssingharoy@microsoft.com>
  • Loading branch information
Sid200026 and Siddharth Singha Roy authored Nov 13, 2024
1 parent 1f65c15 commit c7bd4b8
Show file tree
Hide file tree
Showing 14 changed files with 328 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public void Teardown()
{
return null;
}
else if (os!.Equals("Windows", System.StringComparison.OrdinalIgnoreCase))
else if (os!.Equals("Windows", StringComparison.OrdinalIgnoreCase))
{
return OSPlatform.Windows;
}
else if (os.Equals("Linux", System.StringComparison.OrdinalIgnoreCase))
else if (os.Equals("Linux", StringComparison.OrdinalIgnoreCase))
{
return OSPlatform.Linux;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ public partial class PlaywrightService
{
public PlaywrightService(Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.PlaywrightServiceOptions playwrightServiceOptions, Azure.Core.TokenCredential? credential = null) { }
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) { }
public string? ExposeNetwork { get { throw null; } set { } }
public System.Runtime.InteropServices.OSPlatform? Os { get { throw null; } set { } }
public System.Threading.Timer? RotationTimer { get { throw null; } set { } }
public string? RunId { get { throw null; } set { } }
public string ServiceAuth { get { throw null; } set { } }
public static string? ServiceEndpoint { get { throw null; } }
public bool UseCloudHostedBrowsers { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Utility;
using System.Collections.Generic;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -212,9 +211,10 @@ internal class Constants
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.";
internal static readonly string s_invalid_service_endpoint_error_message = "The service endpoint provided is invalid. Please verify the endpoint URL and try again.";

internal static readonly string s_playwright_service_disable_scalable_execution_environment_variable = "PLAYWRIGHT_SERVICE_DISABLE_SCALABLE_EXECUTION";
internal static readonly string s_playwright_service_reporting_url_environment_variable = "PLAYWRIGHT_SERVICE_REPORTING_URL";
internal static readonly string s_playwright_service_workspace_id_environment_variable = "PLAYWRIGHT_SERVICE_WORKSPACE_ID";
internal static readonly string s_playwright_service_disable_scalable_execution_environment_variable = "_MPT_DISABLE_SCALABLE_EXECUTION";
internal static readonly string s_playwright_service_reporting_url_environment_variable = "_MPT_REPORTING_URL";
internal static readonly string s_playwright_service_workspace_id_environment_variable = "_MPT_WORKSPACE_ID";
internal static readonly string s_playwright_service_auth_type_environment_variable = "_MPT_AUTH_TYPE";
}

internal class OSConstants
Expand All @@ -234,8 +234,8 @@ internal class ReporterConstants
internal static readonly string s_reportingRoute = "/runs/";
internal static readonly string s_reportingAPIVersion_2024_04_30_preview = "2024-04-30-preview";
internal static readonly string s_reportingAPIVersion_2024_05_20_preview = "2024-05-20-preview";
internal static readonly string s_pLAYWRIGHT_SERVICE_REPORTING_URL = "PLAYWRIGHT_SERVICE_REPORTING_URL";
internal static readonly string s_pLAYWRIGHT_SERVICE_WORKSPACE_ID = "PLAYWRIGHT_SERVICE_WORKSPACE_ID";
internal static readonly string s_pLAYWRIGHT_SERVICE_REPORTING_URL = "_MPT_REPORTING_URL";
internal static readonly string s_pLAYWRIGHT_SERVICE_WORKSPACE_ID = "_MPT_WORKSPACE_ID";
internal static readonly string s_aPPLICATION_JSON = "application/json";
internal static readonly string s_cONFLICT_409_ERROR_MESSAGE = "Test run with id {runId} already exists. Provide a unique run id.";
internal static readonly string s_cONFLICT_409_ERROR_MESSAGE_KEY = "DuplicateRunId";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Text;
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Interface;
using Azure.Storage.Blobs;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Azure.Core.Serialization;
using Azure.Core;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
using System;
using System.Collections.Generic;
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Interface;
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Implementation;
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Processor;
using Microsoft.IdentityModel.JsonWebTokens;
using Microsoft.IdentityModel.Tokens;

namespace Azure.Developer.MicrosoftPlaywrightTesting.TestLogger;

Expand Down Expand Up @@ -100,6 +98,8 @@ internal void InitializePlaywrightReporter(string xmlSettings)
runParameters.TryGetValue(RunSettingKey.ManagedIdentityClientId, out var managedIdentityClientId);
runParameters.TryGetValue(RunSettingKey.EnableGitHubSummary, out var enableGithubSummary);
runParameters.TryGetValue(RunSettingKey.EnableResultPublish, out var enableResultPublish);
runParameters.TryGetValue(RunSettingKey.Os, out var osType);
runParameters.TryGetValue(RunSettingKey.ExposeNetwork, out var exposeNetwork);
nunitParameters.TryGetValue(RunSettingKey.NumberOfTestWorkers, out var numberOfTestWorkers);
string? enableGithubSummaryString = enableGithubSummary?.ToString();
string? enableResultPublishString = enableResultPublish?.ToString();
Expand All @@ -110,7 +110,7 @@ internal void InitializePlaywrightReporter(string xmlSettings)
PlaywrightServiceOptions? playwrightServiceSettings;
try
{
playwrightServiceSettings = new(runId: runId?.ToString(), serviceAuth: serviceAuth?.ToString(), azureTokenCredentialType: azureTokenCredential?.ToString(), managedIdentityClientId: managedIdentityClientId?.ToString());
playwrightServiceSettings = new(runId: runId?.ToString(), serviceAuth: serviceAuth?.ToString(), azureTokenCredentialType: azureTokenCredential?.ToString(), managedIdentityClientId: managedIdentityClientId?.ToString(), os: PlaywrightService.GetOSPlatform(osType?.ToString()), exposeNetwork: exposeNetwork?.ToString());
}
catch (Exception ex)
{
Expand Down
Loading

0 comments on commit c7bd4b8

Please sign in to comment.