From 7984595a9c19c6901aa1624f04764d400b60b95c Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Thu, 4 Feb 2021 10:10:10 +0100 Subject: [PATCH] Adds back additional information when running our tests 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 | 30 +++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/Tests.Core/Client/Settings/TestConnectionSettings.cs b/tests/Tests.Core/Client/Settings/TestConnectionSettings.cs index 8612179d05c..75c3e381393 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 eb7b57d3297..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,19 +29,15 @@ 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); } - // ReSharper disable once UnusedMember.Local private static void DumpClusterTotals(Dictionary clusterTotals) { Console.WriteLine("--------"); @@ -49,7 +46,6 @@ private static void DumpClusterTotals(Dictionary clusterTotal Console.WriteLine("--------"); } - // ReSharper disable once UnusedMember.Local private static void DumpSeenDeprecations() { if (XunitRunState.SeenDeprecations.Count == 0) return; @@ -60,10 +56,20 @@ private static void DumpSeenDeprecations() Console.WriteLine("--------"); } - // ReSharper disable once UnusedMember.Local 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:"); @@ -100,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);