From 447563e967d80835b1af021769eac46a19074437 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Thu, 23 May 2024 10:22:26 +0930 Subject: [PATCH] x-pack/filebeat/input/httpjson: skip flakey test on windows (#39678) --- 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 f74e4a72782..9e6f49351bb 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}39678[39678] ==== Added diff --git a/x-pack/filebeat/input/httpjson/metrics_test.go b/x-pack/filebeat/input/httpjson/metrics_test.go index 653523ec5a2..aed9b23c3f8 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 - see https://github.com/elastic/beats/issues/39676", + 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 "" +}