forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounter_integration_test.go
54 lines (39 loc) · 1.32 KB
/
counter_integration_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
// +build integration
// +build cloudfoundry
package counter
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/elastic/beats/v7/libbeat/logp"
mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing"
"github.com/elastic/beats/v7/x-pack/metricbeat/module/cloudfoundry/mtest"
)
func TestFetch(t *testing.T) {
logp.TestingSetup(logp.WithSelectors("cloudfoundry"))
t.Run("v1", func(t *testing.T) {
testFetch(t, "v1")
})
t.Run("v2", func(t *testing.T) {
testFetch(t, "v2")
})
}
func testFetch(t *testing.T, version string) {
config := mtest.GetConfig(t, "counter")
config["version"] = version
ms := mbtest.NewPushMetricSetV2(t, config)
events := mbtest.RunPushMetricSetV2(10*time.Second, 1, ms)
require.NotEmpty(t, events)
}
func TestData(t *testing.T) {
config := mtest.GetConfig(t, "counter")
ms := mbtest.NewPushMetricSetV2(t, config)
events := mbtest.RunPushMetricSetV2(10*time.Second, 1, ms)
require.NotEmpty(t, events)
beatEvent := mbtest.StandardizeEvent(ms, events[0])
mtest.CleanFields(beatEvent)
mbtest.WriteEventToDataJSON(t, beatEvent, "")
}