Skip to content

Commit

Permalink
Add more info to logstash TestXPackEnabled test (elastic#24823)
Browse files Browse the repository at this point in the history
This test seems to be flaky, but is difficult to reproduce locally.
Reduce the use of requirements and separate metricsets in different
tests so more assertions are executed. Print also the problematic event
to have more information next time it happens.
  • Loading branch information
jsoriano authored Mar 30, 2021
1 parent 3d39f2d commit b1083f8
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions metricbeat/module/logstash/logstash_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"net/http"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/beats/v7/libbeat/tests/compose"
Expand Down Expand Up @@ -84,14 +85,20 @@ func TestXPackEnabled(t *testing.T) {
config := getXPackConfig(lsService.Host())
metricSets := mbtest.NewReportingMetricSetV2Errors(t, config)
for _, metricSet := range metricSets {
events, errs := mbtest.ReportingFetchV2Error(metricSet)
require.Empty(t, errs)
require.NotEmpty(t, events)

event := events[0]
require.Equal(t, metricSetToTypeMap[metricSet.Name()], event.RootFields["type"])
require.Equal(t, clusterUUID, event.RootFields["cluster_uuid"])
require.Regexp(t, `^.monitoring-logstash-\d-mb`, event.Index)
t.Run(metricSet.Name(), func(t *testing.T) {
events, errs := mbtest.ReportingFetchV2Error(metricSet)
require.Empty(t, errs)
require.NotEmpty(t, events)

event := events[0]
assert.Equal(t, metricSetToTypeMap[metricSet.Name()], event.RootFields["type"])
assert.Equal(t, clusterUUID, event.RootFields["cluster_uuid"])
assert.Regexp(t, `^.monitoring-logstash-\d-mb`, event.Index)

if t.Failed() {
t.Logf("event: %+v", event)
}
})
}
}

Expand Down

0 comments on commit b1083f8

Please sign in to comment.