From c951bbb5002b51dfe3e423d4d7212ee421305e08 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sat, 3 Feb 2024 13:36:58 -0500 Subject: [PATCH] Make test more flexible (but brittle) --- system_test/single_node_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/system_test/single_node_test.go b/system_test/single_node_test.go index 4d2c20f0..8717d363 100644 --- a/system_test/single_node_test.go +++ b/system_test/single_node_test.go @@ -10,6 +10,7 @@ import ( "os" "path/filepath" "regexp" + "strings" "sync" "testing" "time" @@ -540,7 +541,7 @@ func Test_SingleNodeQueryTimeout(t *testing.T) { } // Bulk insert rows (for speed and to avoid snapshotting) - sqls := make([]string, 5000) + sqls := make([]string, 1000) for i := 0; i < cap(sqls); i++ { args := []any{ random.String(), @@ -577,8 +578,11 @@ func Test_SingleNodeQueryTimeout(t *testing.T) { if err != nil { t.Fatalf("failed to query with timeout: %s", err.Error()) } - if exp, got := `{"results":[{"error":"query timeout"}]}`, r; exp != got { - t.Fatalf("test received wrong result\nexp: %s\ngot: %s\n", exp, got) + if !strings.Contains(r, `"error":"query timeout"`) { + // This test is brittle, but it's the best we can do, as we can't be sure + // how much of the query will actually be executed. We just know it should + // time out at some point. + t.Fatalf("query ran to completion, but should have timed out") } }