From f2de49332c4e0a59cf86c526a8aef4b68db32e41 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Mon, 26 Oct 2020 19:19:45 -0700 Subject: [PATCH 1/3] TestHarness should check --version before choosing an old binary. This allows joshua to run on binaries older than the most recent version, because restarting/upgrade tests won't start with a newer version than what is under test. --- contrib/TestHarness/Program.cs.cmake | 31 ++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/contrib/TestHarness/Program.cs.cmake b/contrib/TestHarness/Program.cs.cmake index 81324d5d61..46693d4ede 100644 --- a/contrib/TestHarness/Program.cs.cmake +++ b/contrib/TestHarness/Program.cs.cmake @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using System.Xml.Linq; using System.IO; @@ -148,7 +149,7 @@ namespace SummarizeTest { var xout = new XElement("TestHarnessError", new XAttribute("Severity", (int)Magnesium.Severity.SevError), - new XAttribute("ErrorMessage", e.Message)); + new XAttribute("ErrorMessage", e.ToString())); AppendXmlMessageToSummary("summary.xml", xout, true); throw; @@ -214,6 +215,30 @@ namespace SummarizeTest return ((System.Collections.IStructuralComparable)version1).CompareTo(version2, System.Collections.Generic.Comparer.Default) >= 0; } + static bool versionLessThan(string ver1, string ver2) { + return !versionGreaterThanOrEqual(ver1, ver2); + } + + static string getFdbserverVersion(string fdbserverName) { + using (var process = new System.Diagnostics.Process()) + { + process.StartInfo.UseShellExecute = false; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.FileName = fdbserverName; + process.StartInfo.Arguments = "--version"; + process.StartInfo.RedirectStandardError = true; + + process.Start(); + var output = process.StandardOutput.ReadToEnd(); + // If the process finished successfully, we call the parameterless WaitForExit to ensure that output buffers get flushed + process.WaitForExit(); + + var match = Regex.Match(output, @"v(\d\.\d\.\d)"); + if (match.Groups.Count < 1) return ""; + return match.Groups[1].Value; + } + } + static int Run(string fdbserverName, string tlsPluginFile, string testFolder, string summaryFileName, string errorFileName, string runDir, string oldBinaryFolder, bool useValgrind, int maxTries, bool traceToStdout = false, string tlsPluginFile_5_1 = "") { int seed = random.Next(1000000000); @@ -270,10 +295,12 @@ namespace SummarizeTest { oldBinaryVersionLowerBound = lastFolderName.Split('_').Last(); } + string oldBinaryVersionUpperBound = getFdbserverVersion(fdbserverName); string[] currentBinary = { fdbserverName }; IEnumerable oldBinaries = Array.FindAll( Directory.GetFiles(oldBinaryFolder), - x => versionGreaterThanOrEqual(Path.GetFileName(x).Split('-').Last(), oldBinaryVersionLowerBound)); + x => versionGreaterThanOrEqual(Path.GetFileName(x).Split('-').Last(), oldBinaryVersionLowerBound) + && versionLessThan(Path.GetFileName(x).Split('-').Last(), oldBinaryVersionUpperBound)); oldBinaries = oldBinaries.Concat(currentBinary); oldServerName = random.Choice(oldBinaries.ToList()); } From 89a1559910fd877b0cd9fc222cfefd99401f1d6e Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 27 Oct 2020 13:12:42 -0700 Subject: [PATCH 2/3] Handle versions being >1 digits. --- contrib/TestHarness/Program.cs.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/TestHarness/Program.cs.cmake b/contrib/TestHarness/Program.cs.cmake index 46693d4ede..d8e2eb920f 100644 --- a/contrib/TestHarness/Program.cs.cmake +++ b/contrib/TestHarness/Program.cs.cmake @@ -233,7 +233,7 @@ namespace SummarizeTest // If the process finished successfully, we call the parameterless WaitForExit to ensure that output buffers get flushed process.WaitForExit(); - var match = Regex.Match(output, @"v(\d\.\d\.\d)"); + var match = Regex.Match(output, @"v(\d+\.\d+\.\d+)"); if (match.Groups.Count < 1) return ""; return match.Groups[1].Value; } From 362bd757c6cf814cd46c9ac6dc44eae306b02c61 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Thu, 29 Oct 2020 02:19:55 -0700 Subject: [PATCH 3/3] Make FDB >=4.x ignore old binaries before FDB 4.x The motivation for this is so that Snowflake can add use TestHarness to run FDB3 in Joshua, and be able to load FDB3 binaries into the image for restarting tests. --- contrib/TestHarness/Program.cs.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/TestHarness/Program.cs.cmake b/contrib/TestHarness/Program.cs.cmake index d8e2eb920f..f9040f69fd 100644 --- a/contrib/TestHarness/Program.cs.cmake +++ b/contrib/TestHarness/Program.cs.cmake @@ -289,13 +289,18 @@ namespace SummarizeTest } uniqueFiles = uniqueFileSet.ToArray(); testFile = random.Choice(uniqueFiles); - string oldBinaryVersionLowerBound = "0.0.0"; + // The on-disk format changed in 4.0.0, and 5.x can't load files from 3.x. + string oldBinaryVersionLowerBound = "4.0.0"; string lastFolderName = Path.GetFileName(Path.GetDirectoryName(testFile)); if (lastFolderName.Contains("from_") || lastFolderName.Contains("to_")) // Only perform upgrade/downgrade tests from certain versions { oldBinaryVersionLowerBound = lastFolderName.Split('_').Last(); } string oldBinaryVersionUpperBound = getFdbserverVersion(fdbserverName); + if (versionGreaterThanOrEqual("4.0.0", oldBinaryVersionUpperBound)) { + // If the binary under test is from 3.x, then allow upgrade tests from 3.x binaries. + oldBinaryVersionLowerBound = "0.0.0"; + } string[] currentBinary = { fdbserverName }; IEnumerable oldBinaries = Array.FindAll( Directory.GetFiles(oldBinaryFolder),