Skip to content

Commit

Permalink
x-pack/filebeat/input/httpjson: skip flakey test on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
efd6 committed May 22, 2024
1 parent 18a7e54 commit b2113ae
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 24 additions & 0 deletions x-pack/filebeat/input/httpjson/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"fmt"
"net/http"
"net/http/httptest"
"runtime"
"slices"
"strings"
"testing"
"time"

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 ""
}

0 comments on commit b2113ae

Please sign in to comment.