-
Notifications
You must be signed in to change notification settings - Fork 106
/
inputdockerstats_test.go
47 lines (40 loc) · 1.01 KB
/
inputdockerstats_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
package inputdockerstats
import (
"context"
"strings"
"testing"
"time"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tsaikd/gogstash/config"
"github.com/tsaikd/gogstash/config/goglog"
)
func init() {
goglog.Logger.SetLevel(logrus.DebugLevel)
config.RegistInputHandler(ModuleName, InitHandler)
}
func Test_input_dockerstats_module(t *testing.T) {
assert := assert.New(t)
assert.NotNil(assert)
require := require.New(t)
require.NotNil(require)
ctx := context.Background()
conf, err := config.LoadFromYAML([]byte(strings.TrimSpace(`
debugch: true
input:
- type: dockerstats
dockerurl: "unix:///var/run/docker.sock"
stat_interval: 3
`)))
require.NoError(err)
err = conf.Start(ctx)
if err != nil {
require.True(ErrorPingFailed.In(err))
t.Skip("skip test input dockerstats module")
}
time.Sleep(500 * time.Millisecond)
if event, err := conf.TestGetOutputEvent(100 * time.Millisecond); assert.NoError(err) {
t.Log(event)
}
}