From b2113aecb33d650203c4ed2588bb036d3f73f2c9 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Thu, 23 May 2024 06:58:12 +0930 Subject: [PATCH] x-pack/filebeat/input/httpjson: skip flakey test on windows --- CHANGELOG-developer.next.asciidoc | 1 + .../filebeat/input/httpjson/metrics_test.go | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CHANGELOG-developer.next.asciidoc b/CHANGELOG-developer.next.asciidoc index f74e4a72782d..82bd944c07c3 100644 --- a/CHANGELOG-developer.next.asciidoc +++ b/CHANGELOG-developer.next.asciidoc @@ -96,6 +96,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only. - Cleaned up documentation errors & fixed a minor bug in Filebeat Azure blob storage input. {pull}36714[36714] - Fix copy arguments for strict aligned architectures. {pull}36976[36976] - Fix panic when more than 32767 pipeline clients are active. {issue}38197[38197] {pull}38556[38556] +- Skip flakey metrics test on windows in filebeat httpjson input. {issue}39676[39676] {pull}[] ==== Added diff --git a/x-pack/filebeat/input/httpjson/metrics_test.go b/x-pack/filebeat/input/httpjson/metrics_test.go index 653523ec5a2c..51e65ba2b102 100644 --- a/x-pack/filebeat/input/httpjson/metrics_test.go +++ b/x-pack/filebeat/input/httpjson/metrics_test.go @@ -8,6 +8,9 @@ import ( "fmt" "net/http" "net/http/httptest" + "runtime" + "slices" + "strings" "testing" "time" @@ -28,8 +31,12 @@ func TestMetrics(t *testing.T) { handler http.HandlerFunc expectedEvents []string assertMetrics func(reg *monitoring.Registry) error + + skipReason string // GOOS:reason or GOOS,GOOS,...:reason. }{ { + skipReason: "windows:flakey test on windows", + name: "Test pagination metrics", setupServer: func(t *testing.T, h http.HandlerFunc, config map[string]interface{}) { server := httptest.NewServer(h) @@ -102,6 +109,9 @@ func TestMetrics(t *testing.T) { for _, testCase := range testCases { tc := testCase t.Run(tc.name, func(t *testing.T) { + if reason := skipReason(tc.skipReason); reason != "" { + t.Skipf("skipping %s", reason) + } tc.setupServer(t, tc.handler, tc.baseConfig) cfg := conf.MustNewConfigFrom(tc.baseConfig) @@ -163,3 +173,17 @@ func TestMetrics(t *testing.T) { }) } } + +func skipReason(s string) string { + if s == "" { + return "" + } + goos, reason, ok := strings.Cut(s, ":") + if !ok { + return s + } + if slices.Contains(strings.Split(goos, ","), runtime.GOOS) { + return reason + } + return "" +}