Skip to content

Commit fc841a0

Browse files
Adds back additional information when running our tests (#5303) (#5351)
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. Co-authored-by: Martijn Laarman <[email protected]>
1 parent 84771ce commit fc841a0

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
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 & 9 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,16 +29,13 @@ 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

4341
private static void DumpClusterTotals(Dictionary<string, Stopwatch> clusterTotals)
@@ -60,7 +58,18 @@ private static void DumpSeenDeprecations()
6058

6159
private static void DumpFailedCollections(ConcurrentBag<Tuple<string, string>> failedCollections)
6260
{
63-
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+
};
6473

6574
Console.ForegroundColor = ConsoleColor.Red;
6675
Console.WriteLine("Failed collections:");
@@ -97,7 +106,7 @@ private static string ReproduceCommandLine(ConcurrentBag<Tuple<string, string>>
97106
bool runningIntegrations
98107
)
99108
{
100-
var sb = new StringBuilder(".\\build.bat ")
109+
var sb = new StringBuilder(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".\\build.bat " : "./build.sh ")
101110
.Append("seed:").Append(config.Seed).Append(" ");
102111

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

0 commit comments

Comments
 (0)