From 95be640b467e5a9bc5f1c7f614643d4208698770 Mon Sep 17 00:00:00 2001 From: Du-z <16366766+Du-z@users.noreply.github.com> Date: Mon, 26 Sep 2022 21:30:40 +1000 Subject: [PATCH 1/2] Fixed tests on windows not finding the TCP connection --- tests/Shared/SurrealInstance.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/Shared/SurrealInstance.cs b/tests/Shared/SurrealInstance.cs index ef0e4861..5f22f22d 100644 --- a/tests/Shared/SurrealInstance.cs +++ b/tests/Shared/SurrealInstance.cs @@ -3,7 +3,7 @@ namespace SurrealDB.Shared.Tests; public static class SurrealInstance { public static Process Create() { // Wait until port is closed - TcpHelper.SpinUntilClosed($"0.0.0.0:{TestHelper.Port}"); + TcpHelper.SpinUntilClosed($"{TestHelper.Loopback}:{TestHelper.Port}"); // We have a race condition between when the SurrealDB socket opens (or closes), and when it accepts connections. // 50ms should be enough to run the tests on most devices. // Thread.Sleep(50); @@ -14,7 +14,7 @@ public static Process Create() { // Start new instances var p = Instantiate(path!); Debug.Assert(p is not null); - TcpHelper.SpinUntilListening($"0.0.0.0:{TestHelper.Port}"); + TcpHelper.SpinUntilListening($"{TestHelper.Loopback}:{TestHelper.Port}"); // Thread.Sleep(50); Debug.Assert(!p.HasExited); return p; @@ -22,9 +22,10 @@ public static Process Create() { private static Process? Instantiate(string path) { ProcessStartInfo pi = new() { - UseShellExecute = true, + CreateNoWindow = true, + UseShellExecute = false, FileName = path, - Arguments = $"start memory -b 0.0.0.0:{TestHelper.Port} -u {TestHelper.User} -p {TestHelper.Pass} --log debug", + Arguments = $"start memory -b {TestHelper.Loopback}:{TestHelper.Port} -u {TestHelper.User} -p {TestHelper.Pass} --log debug", WorkingDirectory = Environment.CurrentDirectory }; return Process.Start(pi); From c016ca3a686e9a2e1a591af8b8faf4766f4466f8 Mon Sep 17 00:00:00 2001 From: Du-z <16366766+Du-z@users.noreply.github.com> Date: Mon, 26 Sep 2022 21:35:42 +1000 Subject: [PATCH 2/2] Commented out some changes until a fix is found --- tests/Shared/SurrealInstance.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Shared/SurrealInstance.cs b/tests/Shared/SurrealInstance.cs index 5f22f22d..7f98f2f5 100644 --- a/tests/Shared/SurrealInstance.cs +++ b/tests/Shared/SurrealInstance.cs @@ -22,8 +22,10 @@ public static Process Create() { private static Process? Instantiate(string path) { ProcessStartInfo pi = new() { - CreateNoWindow = true, - UseShellExecute = false, + // These two settings can make the tests run twice as fast, but makes it harder to kill rouge DB instances + //CreateNoWindow = true, + //UseShellExecute = false, + UseShellExecute = true, FileName = path, Arguments = $"start memory -b {TestHelper.Loopback}:{TestHelper.Port} -u {TestHelper.User} -p {TestHelper.Pass} --log debug", WorkingDirectory = Environment.CurrentDirectory