From 22d10be601255ff109584843623e6fe00ab7739c Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Thu, 25 Feb 2021 11:22:53 +0100 Subject: [PATCH] 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. --- .../Client/Settings/TestConnectionSettings.cs | 3 +++ tests/Tests.Core/Xunit/NestXunitRunOptions.cs | 27 ++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/Tests.Core/Client/Settings/TestConnectionSettings.cs b/tests/Tests.Core/Client/Settings/TestConnectionSettings.cs index 9b3c6f6bc83..3dec23a364e 100644 --- a/tests/Tests.Core/Client/Settings/TestConnectionSettings.cs +++ b/tests/Tests.Core/Client/Settings/TestConnectionSettings.cs @@ -55,6 +55,9 @@ private void ApplyTestSettings() => .ConnectionLimit(ConnectionLimitDefault) .OnRequestCompleted(r => { + //r.HttpMethod; + + if (!r.DeprecationWarnings.Any()) return; var q = r.Uri.Query; diff --git a/tests/Tests.Core/Xunit/NestXunitRunOptions.cs b/tests/Tests.Core/Xunit/NestXunitRunOptions.cs index a71c52bdbf0..b637a11417c 100644 --- a/tests/Tests.Core/Xunit/NestXunitRunOptions.cs +++ b/tests/Tests.Core/Xunit/NestXunitRunOptions.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using Elastic.Elasticsearch.Xunit; using Tests.Configuration; @@ -28,16 +29,13 @@ public NestXunitRunOptions() Generators.Initialize(); } - public override void OnBeforeTestsRun() - { - //TestConfiguration.Instance.DumpConfiguration(); - } + public override void OnBeforeTestsRun() => TestConfiguration.Instance.DumpConfiguration(); public override void OnTestsFinished(Dictionary clusterTotals, ConcurrentBag> failedCollections) { - // DumpClusterTotals(clusterTotals); - // DumpSeenDeprecations(); - // DumpFailedCollections(failedCollections); + DumpClusterTotals(clusterTotals); + DumpSeenDeprecations(); + DumpFailedCollections(failedCollections); } private static void DumpClusterTotals(Dictionary clusterTotals) @@ -60,7 +58,18 @@ private static void DumpSeenDeprecations() private static void DumpFailedCollections(ConcurrentBag> failedCollections) { - if (failedCollections.Count <= 0) return; + if (failedCollections.Count <= 0) + { + var config = TestConfiguration.Instance; + var runningIntegrations = config.RunIntegrationTests; + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("---Reproduce: -----"); + var reproduceLine = ReproduceCommandLine(failedCollections, config, runningIntegrations); + Console.WriteLine(reproduceLine); + Console.WriteLine("---------------"); + Console.ResetColor(); + return; + }; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed collections:"); @@ -97,7 +106,7 @@ private static string ReproduceCommandLine(ConcurrentBag> bool runningIntegrations ) { - var sb = new StringBuilder(".\\build.bat ") + var sb = new StringBuilder(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".\\build.bat " : "./build.sh ") .Append("seed:").Append(config.Seed).Append(" "); AppendConfig(nameof(RandomConfiguration.SourceSerializer), config.Random.SourceSerializer, sb);