Skip to content

Commit 47663e0

Browse files
authored
Adds back additional information when running our tests (#5303)
Dumps all the configuration bits at the beginning of the run including test mode and random seed information. At the end of the run this now again produces an overview of how long testing each cluster took. And produce a reproduce command line that you can use to only rerun failed collections/tests using the exact same configuration.
1 parent 0c9e10d commit 47663e0

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

tests/Tests.Core/Client/Settings/TestConnectionSettings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ private void ApplyTestSettings() =>
5555
.ConnectionLimit(ConnectionLimitDefault)
5656
.OnRequestCompleted(r =>
5757
{
58+
//r.HttpMethod;
59+
60+
5861
if (!r.DeprecationWarnings.Any()) return;
5962

6063
var q = r.Uri.Query;

tests/Tests.Core/Xunit/NestXunitRunOptions.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.Generic;
88
using System.Diagnostics;
99
using System.Linq;
10+
using System.Runtime.InteropServices;
1011
using System.Text;
1112
using Elastic.Elasticsearch.Xunit;
1213
using Tests.Configuration;
@@ -28,19 +29,15 @@ public NestXunitRunOptions()
2829
Generators.Initialize();
2930
}
3031

31-
public override void OnBeforeTestsRun()
32-
{
33-
//TestConfiguration.Instance.DumpConfiguration();
34-
}
32+
public override void OnBeforeTestsRun() => TestConfiguration.Instance.DumpConfiguration();
3533

3634
public override void OnTestsFinished(Dictionary<string, Stopwatch> clusterTotals, ConcurrentBag<Tuple<string, string>> failedCollections)
3735
{
38-
// DumpClusterTotals(clusterTotals);
39-
// DumpSeenDeprecations();
40-
// DumpFailedCollections(failedCollections);
36+
DumpClusterTotals(clusterTotals);
37+
DumpSeenDeprecations();
38+
DumpFailedCollections(failedCollections);
4139
}
4240

43-
// ReSharper disable once UnusedMember.Local
4441
private static void DumpClusterTotals(Dictionary<string, Stopwatch> clusterTotals)
4542
{
4643
Console.WriteLine("--------");
@@ -49,7 +46,6 @@ private static void DumpClusterTotals(Dictionary<string, Stopwatch> clusterTotal
4946
Console.WriteLine("--------");
5047
}
5148

52-
// ReSharper disable once UnusedMember.Local
5349
private static void DumpSeenDeprecations()
5450
{
5551
if (XunitRunState.SeenDeprecations.Count == 0) return;
@@ -60,10 +56,20 @@ private static void DumpSeenDeprecations()
6056
Console.WriteLine("--------");
6157
}
6258

63-
// ReSharper disable once UnusedMember.Local
6459
private static void DumpFailedCollections(ConcurrentBag<Tuple<string, string>> failedCollections)
6560
{
66-
if (failedCollections.Count <= 0) return;
61+
if (failedCollections.Count <= 0)
62+
{
63+
var config = TestConfiguration.Instance;
64+
var runningIntegrations = config.RunIntegrationTests;
65+
Console.ForegroundColor = ConsoleColor.Yellow;
66+
Console.WriteLine("---Reproduce: -----");
67+
var reproduceLine = ReproduceCommandLine(failedCollections, config, runningIntegrations);
68+
Console.WriteLine(reproduceLine);
69+
Console.WriteLine("---------------");
70+
Console.ResetColor();
71+
return;
72+
};
6773

6874
Console.ForegroundColor = ConsoleColor.Red;
6975
Console.WriteLine("Failed collections:");
@@ -100,7 +106,7 @@ private static string ReproduceCommandLine(ConcurrentBag<Tuple<string, string>>
100106
bool runningIntegrations
101107
)
102108
{
103-
var sb = new StringBuilder(".\\build.bat ")
109+
var sb = new StringBuilder(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".\\build.bat " : "./build.sh ")
104110
.Append("seed:").Append(config.Seed).Append(" ");
105111

106112
AppendConfig(nameof(RandomConfiguration.SourceSerializer), config.Random.SourceSerializer, sb);

0 commit comments

Comments
 (0)