Skip to content

Commit

Permalink
Adding integration test for beat Metricbeat module, xpack code path (#…
Browse files Browse the repository at this point in the history
…15967)

* Adding integration test for beat Metricbeat module, xpack code path

* Update test Beat's version to latest

* Set cluster UUID in test beat config and look for it in test

* Replace assert.* with require.*
  • Loading branch information
ycombinator authored Mar 4, 2020
1 parent f686982 commit 1fc1cb9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions metricbeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ services:

# Used by base tests
metricbeat:
image: docker.elastic.co/integrations-ci/beats-metricbeat:${BEAT_VERSION:-7.3.0}-1
image: docker.elastic.co/integrations-ci/beats-metricbeat:${BEAT_VERSION:-7.5.2}-1
build:
context: ./module/beat/_meta
args:
BEAT_VERSION: ${BEAT_VERSION:-7.3.0}
BEAT_VERSION: ${BEAT_VERSION:-7.5.2}
command: '-e'
ports:
- 5066
2 changes: 1 addition & 1 deletion metricbeat/module/beat/_meta/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ FROM docker.elastic.co/beats/metricbeat:${BEAT_VERSION}
COPY healthcheck.sh /
HEALTHCHECK --interval=1s --retries=300 CMD sh /healthcheck.sh

ENTRYPOINT [ "metricbeat", "-E", "http.enabled=true", "-E", "http.host=0.0.0.0" ]
ENTRYPOINT [ "metricbeat", "-E", "http.enabled=true", "-E", "http.host=0.0.0.0", "-E", "monitoring.cluster_uuid=foobar" ]
27 changes: 27 additions & 0 deletions metricbeat/module/beat/beat_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,30 @@ func TestData(t *testing.T) {
require.NoError(t, err)
}
}

func TestXPackEnabled(t *testing.T) {
service := compose.EnsureUpWithTimeout(t, 300, "metricbeat")

config := getXPackConfig(service.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, "beats_"+metricSet.Name(), event.RootFields["type"])
require.Equal(t, event.RootFields["cluster_uuid"], "foobar")
require.Regexp(t, `^.monitoring-beats-\d-mb`, event.Index)
}
}

func getXPackConfig(host string) map[string]interface{} {
return map[string]interface{}{
"module": beat.ModuleName,
"metricsets": metricSets,
"hosts": []string{host},
"xpack.enabled": true,
}
}

0 comments on commit 1fc1cb9

Please sign in to comment.