Skip to content

Commit

Permalink
x-pack/filebeat/input/httpjson: re-enable previously flakey first_eve…
Browse files Browse the repository at this point in the history
…nt test

With the change from concurrent to sequential processing this test is
no longer flakey. This is confirmed by re-applying a delay to the
publication of the first event in a set of events. This change causes
the concurrent code to fail consistently, but the current sequential
code passes.

The test change used to test the flake is

diff --git a/x-pack/filebeat/input/httpjson/request.go b/x-pack/filebeat/input/httpjson/request.go
index 6a1d926ab4..3ed904f16d 100644
--- a/x-pack/filebeat/input/httpjson/request.go
+++ b/x-pack/filebeat/input/httpjson/request.go
@@ -16,6 +16,7 @@ import (
        "reflect"
        "strconv"
        "strings"
+       "time"

        "github.com/PaesslerAG/jsonpath"

@@ -741,6 +742,10 @@ func newPublisher(trCtx *transformContext, pub inputcursor.Publisher, publish bo
 }

 func (p *publisher) event(_ context.Context, msg mapstr.M) {
+       if p.n == 0 {
+               time.Sleep(10 * time.Millisecond)
+       }
+
        if p.pub != nil {
                event, err := makeEvent(msg)
                if err != nil {
  • Loading branch information
efd6 committed Sep 6, 2023
1 parent 2b0076b commit 9b42b47
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
- Fix ingest pipeline for panw module to parse url scheme correctly {pull}35757[35757]
- Renamed an httpjson input metric to follow naming conventions. `httpjson_interval_pages_total` was renamed to `httpjson_interval_pages` because the `_total` suffix is reserved for counters. {issue}35933[35933] {pull}36169[36169]
- Fixed some race conditions in tests {pull}36185[36185]
- Re-enable HTTPJSON fixed flakey test. {issue}34929[34929] {pull}36525[36525]

==== Added

Expand Down
2 changes: 0 additions & 2 deletions x-pack/filebeat/input/httpjson/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,6 @@ var testCases = []struct {
},
},
{
skipReason: "flakey test - see https://github.com/elastic/beats/issues/34929",

name: "first_event",
setupServer: func(t testing.TB, h http.HandlerFunc, config map[string]interface{}) {
server := httptest.NewServer(h)
Expand Down

0 comments on commit 9b42b47

Please sign in to comment.