-
Notifications
You must be signed in to change notification settings - Fork 5.1k
feat(playwrighttesting): separate api, test data processing and utility layers #46681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Sid200026
merged 19 commits into
Azure:main
from
Sid200026:users/ssingharoy/reporter-refactor-on-par-js
Oct 21, 2024
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7345746
feat(playwrighttesting): separate api, data processing and utility la…
Sid200026 1d5a12f
chore(): additional scalable run failure handling
Sid200026 f64347a
chore(): api retries and logging
Sid200026 ea1a3f1
chore(): reporting api failure error handling
Sid200026 4eff9d8
fix(): no access token error message logged with error level
Sid200026 ca57afc
chore(): remove null check condition in console writer
Sid200026 00e6f59
chore(): add different logging levels
Sid200026 3a92c39
refactor(): rename logger to microsoft-playwright-testing
Sid200026 cf88569
Update TestProcessor.cs
kashish2508 9bb7771
Update ReporterUtils.cs
kashish2508 094014d
Create ReporterUtilsTests.cs
kashish2508 51fe587
fix(): uri escape data string for workspace and run id
Sid200026 6cdba5a
fix(): ad hoc fixes
Sid200026 cc202fa
fix(): handle null sas uri post refresh
Sid200026 8a40eb6
chore(): change reporting api version 2024-09-01-preview
Sid200026 dde053b
chore(): add tests for reporter
Sid200026 b462813
chore(): add new api info
Sid200026 e96d865
fix(): remove parallelization from entra tests
Sid200026 8e548fd
Merge branch 'main' of https://github.com/Sid200026/azure-sdk-for-net…
Sid200026 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...Developer.MicrosoftPlaywrightTesting.TestLogger/src/Implementation/CloudRunErrorParser.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Collections.Generic; | ||
| using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Interface; | ||
|
|
||
| namespace Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Implementation | ||
| { | ||
| internal class CloudRunErrorParser : ICloudRunErrorParser | ||
| { | ||
| private List<string> InformationalMessages { get; set; } = new(); | ||
| private List<string> ProcessedErrorMessageKeys { get; set; } = new(); | ||
| private readonly ILogger _logger; | ||
| private readonly IConsoleWriter _consoleWriter; | ||
| public CloudRunErrorParser(ILogger? logger = null, IConsoleWriter? consoleWriter = null) | ||
| { | ||
| _logger = logger ?? new Logger(); | ||
| _consoleWriter = consoleWriter ?? new ConsoleWriter(); | ||
| } | ||
|
|
||
| public bool TryPushMessageAndKey(string? message, string? key) | ||
| { | ||
| if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(message)) | ||
| { | ||
| return false; | ||
| } | ||
| if (ProcessedErrorMessageKeys.Contains(key!)) | ||
| { | ||
| return false; | ||
| } | ||
| _logger.Info($"Adding message with key: {key}"); | ||
|
|
||
| ProcessedErrorMessageKeys.Add(key!); | ||
| InformationalMessages.Add(message!); | ||
| return true; | ||
| } | ||
|
|
||
| public void PushMessage(string message) | ||
| { | ||
| InformationalMessages.Add(message); | ||
| } | ||
|
|
||
| public void DisplayMessages() | ||
| { | ||
| if (InformationalMessages.Count > 0) | ||
| _consoleWriter.WriteLine(); | ||
| int index = 1; | ||
| foreach (string message in InformationalMessages) | ||
| { | ||
| _consoleWriter.WriteLine($"{index++}) {message}"); | ||
| } | ||
| } | ||
|
|
||
| public void PrintErrorToConsole(string message) | ||
| { | ||
| _consoleWriter.WriteError(message); | ||
| } | ||
|
|
||
| public void HandleScalableRunErrorMessage(string? message) | ||
| { | ||
| if (string.IsNullOrEmpty(message)) | ||
| { | ||
| return; | ||
| } | ||
| foreach (TestResultError testResultErrorObj in TestResultErrorConstants.ErrorConstants) | ||
| { | ||
| if (testResultErrorObj.Pattern.IsMatch(message)) | ||
| { | ||
| TryPushMessageAndKey(testResultErrorObj.Message, testResultErrorObj.Key); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
...Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Implementation/ConsoleWriter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Interface; | ||
|
|
||
| namespace Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Implementation | ||
| { | ||
| internal class ConsoleWriter : IConsoleWriter | ||
| { | ||
| public void WriteLine(string? message = null) | ||
| { | ||
| if (message == null) | ||
| { | ||
| Console.WriteLine(); | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine(message); | ||
| } | ||
| } | ||
|
|
||
| public void WriteError(string? message = null) | ||
| { | ||
| if (message == null) | ||
| { | ||
| Console.Error.WriteLine(); | ||
| } | ||
| else | ||
| { | ||
| Console.Error.WriteLine(message); | ||
| } | ||
| } | ||
| } | ||
| } | ||
50 changes: 50 additions & 0 deletions
50
...esting/Azure.Developer.MicrosoftPlaywrightTesting.TestLogger/src/Implementation/Logger.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Interface; | ||
|
|
||
| namespace Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Implementation; | ||
|
|
||
| internal enum LogLevel | ||
| { | ||
| Debug, | ||
| Info, | ||
| Warning, | ||
| Error | ||
| } | ||
|
|
||
| internal class Logger : ILogger | ||
| { | ||
| internal static bool EnableDebug { get { return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(Constants.s_pLAYWRIGHT_SERVICE_DEBUG)); } set { } } | ||
|
|
||
| #pragma warning disable CA1822 // Mark members as static | ||
| private void Log(LogLevel level, string message) | ||
| #pragma warning restore CA1822 // Mark members as static | ||
| { | ||
| if (EnableDebug) | ||
Sid200026 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| Console.WriteLine($"{DateTime.Now} [{level}]: {message}"); | ||
| } | ||
| } | ||
|
|
||
| public void Debug(string message) | ||
| { | ||
| Log(LogLevel.Debug, message); | ||
| } | ||
|
|
||
| public void Error(string message) | ||
| { | ||
| Log(LogLevel.Error, message); | ||
| } | ||
|
|
||
| public void Info(string message) | ||
| { | ||
| Log(LogLevel.Info, message); | ||
| } | ||
|
|
||
| public void Warning(string message) | ||
| { | ||
| Log(LogLevel.Warning, message); | ||
| } | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.