Skip to content

Commit

Permalink
Enable the built in TRX reporter for proper error reporting in AzDo (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus committed Apr 21, 2022
1 parent 0d1c66b commit ff2d528
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ public string ListenAddress
public bool AppendLogOutput { get; set; } = true;

public string? Platform { get; set; }

public bool UseBuiltInTrxReporter { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Akka.MultiNode.TestAdapter/Configuration/OptionsReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ private static MultiNodeTestRunnerOptions Load(Stream configStream)
case JsonBoolean booleanValue:
if (string.Equals(propertyName, Configuration.AppendLogOutput, StringComparison.OrdinalIgnoreCase))
result.AppendLogOutput = booleanValue.Value;
if (string.Equals(propertyName, Configuration.UseBuiltInTrxReporter, StringComparison.OrdinalIgnoreCase))
result.UseBuiltInTrxReporter = booleanValue.Value;
break;

case JsonString stringValue:
Expand Down Expand Up @@ -87,6 +89,7 @@ static class Configuration
public const string ListenAddress = "listenAddress";
public const string ListenPort = "listenPort";
public const string AppendLogOutput = "appendLogOutput";
public const string UseBuiltInTrxReporter = "useBuiltInTrxReporter";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,15 @@ protected override async Task<RunSummary> RunTestAsync()
");
TestRunSystem = ActorSystem.Create("TestRunnerLogging", config);

var sinks = new List<MessageSink>
{
new DiagnosticMessageSink(_diagnosticSink)
};
if(Options.UseBuiltInTrxReporter)
sinks.Add(new TrxMessageSink(DisplayName, Options));

SinkCoordinator = TestRunSystem.ActorOf(Props.Create(()
=> new SinkCoordinator(new[] { new DiagnosticMessageSink(_diagnosticSink) })), "sinkCoordinator");
=> new SinkCoordinator(sinks)), "sinkCoordinator");

var tcpLogger = TestRunSystem.ActorOf(Props.Create(() => new TcpLoggingServer(SinkCoordinator)), "TcpLogger");
var listenEndpoint = new IPEndPoint(IPAddress.Parse(Options.ListenAddress), Options.ListenPort);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

using System;
using Akka.Actor;
using Akka.MultiNode.TestAdapter.Configuration;
using Akka.MultiNode.TestAdapter.Internal.Sinks;

namespace Akka.MultiNode.TestAdapter.Internal.TrxReporter
{
internal class TrxMessageSink : MessageSink
{
public TrxMessageSink(string suiteName)
: base(Props.Create(() => new TrxSinkActor(suiteName, System.Environment.UserName, System.Environment.MachineName, true)))
public TrxMessageSink(string suiteName, MultiNodeTestRunnerOptions options)
: base(Props.Create(() =>
new TrxSinkActor(suiteName, Environment.UserName, Environment.MachineName, true, options)))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Akka.MultiNode.TestAdapter.Configuration;
using Akka.MultiNode.TestAdapter.Internal.Reporting;
using Akka.MultiNode.TestAdapter.Internal.Sinks;
using Akka.MultiNode.TestAdapter.Internal.TrxReporter.Models;
Expand All @@ -18,19 +19,26 @@ namespace Akka.MultiNode.TestAdapter.Internal.TrxReporter
{
internal class TrxSinkActor : TestCoordinatorEnabledMessageSink
{
public TrxSinkActor(string suiteName, string userName, string computerName, bool useTestCoordinator)
public TrxSinkActor(
string suiteName,
string userName,
string computerName,
bool useTestCoordinator,
MultiNodeTestRunnerOptions options)
: base(useTestCoordinator)
{
_computerName = computerName;
_testRun = new TestRun(suiteName)
{
RunUser = userName
};
_options = options;
}

private readonly string _computerName;
private readonly TestRun _testRun;
private SpecSession _session;
private MultiNodeTestRunnerOptions _options;

protected override void AdditionalReceives()
{
Expand Down Expand Up @@ -99,7 +107,7 @@ protected override void HandleTestRunEnd(EndTestRun endTestRun)
_testRun.Serialize()
);

doc.Save(Path.Combine(Directory.GetCurrentDirectory(), $@"mntr-{DateTime.UtcNow:yyyy'-'MM'-'dd'T'HH'-'mm'-'ss'-'fffffffK}.trx"));
doc.Save(Path.Combine(Path.GetFullPath(_options.OutputDirectory), $@"mntr-{DateTime.UtcNow:yyyy'-'MM'-'dd'T'HH'-'mm'-'ss'-'fffffffK}.trx"));
}

private static void ReportSpec(SpecSession session, TestRun testRun, string computerName, SpecLog log)
Expand Down

0 comments on commit ff2d528

Please sign in to comment.