Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update TestProcessor.cs
  • Loading branch information
kashish2508 authored Oct 17, 2024
commit cf885696d767e145ec6735facd3faecbc2130ca9
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Implementation;
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Interface;
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Model;
using Azure.Developer.MicrosoftPlaywrightTesting.TestLogger.Utility;
using Azure.Storage.Blobs;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
Expand Down Expand Up @@ -152,21 +153,29 @@ public void TestRunCompleteHandler(object? sender, TestRunCompleteEventArgs e)
{
if (RawTestResultsMap.TryGetValue(testResult.TestExecutionId!, out RawTestResult? rawResult) && rawResult != null)
{
// Renew the SAS URI if needed
var reporterUtils = new ReporterUtils();
if (sasUri == null || !reporterUtils.IsTimeGreaterThanCurrentPlus10Minutes(sasUri.Uri))
{
sasUri = _serviceClient.GetTestRunResultsUri(); // Create new SAS URI
_logger.Info($"Fetched SAS URI with validity: {sasUri?.ExpiresAt} and access: {sasUri?.AccessLevel}.");
}

// Upload rawResult to blob storage using sasUri
var rawTestResultJson = JsonSerializer.Serialize(rawResult);
var filePath = $"{testResult.TestExecutionId}/rawTestResult.json";
UploadBuffer(sasUri!.Uri!, rawTestResultJson, filePath);
}
else
{
_logger.Info("Couldnt find rawResult for Id: " + testResult.TestExecutionId);
_logger.Info("Couldn't find rawResult for Id: " + testResult.TestExecutionId);
}
}
_logger.Info("Successfully uploaded raw test results");
}
else
{
_logger.Error("Sas Uri is empty");
_logger.Error("SAS URI is empty");
}
}
catch (Exception ex)
Expand All @@ -177,7 +186,7 @@ public void TestRunCompleteHandler(object? sender, TestRunCompleteEventArgs e)
EndTestRun(e);
}

#region Test Processor Helper Methods
#region Test Processor Helper Methods
private void EndTestRun(TestRunCompleteEventArgs e)
{
if (_cloudRunMetadata.EnableResultPublish && !FatalTestExecution)
Expand Down