Fix docker input unit tests
This commit is contained in:
parent
791d154ec1
commit
f405bca034
|
@ -543,12 +543,13 @@ func TestContainerStatus(t *testing.T) {
|
||||||
// tags
|
// tags
|
||||||
Status string
|
Status string
|
||||||
// fields
|
// fields
|
||||||
OOMKilled bool
|
ContainerID string
|
||||||
Pid int
|
OOMKilled bool
|
||||||
ExitCode int
|
Pid int
|
||||||
StartedAt time.Time
|
ExitCode int
|
||||||
FinishedAt time.Time
|
StartedAt time.Time
|
||||||
UptimeNs int64
|
FinishedAt time.Time
|
||||||
|
UptimeNs int64
|
||||||
}
|
}
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
|
@ -564,12 +565,13 @@ func TestContainerStatus(t *testing.T) {
|
||||||
},
|
},
|
||||||
inspect: containerInspect(),
|
inspect: containerInspect(),
|
||||||
expect: expectation{
|
expect: expectation{
|
||||||
Status: "running",
|
ContainerID: "e2173b9478a6ae55e237d4d74f8bbb753f0817192b5081334dc78476296b7dfb",
|
||||||
OOMKilled: false,
|
Status: "running",
|
||||||
Pid: 1234,
|
OOMKilled: false,
|
||||||
ExitCode: 0,
|
Pid: 1234,
|
||||||
StartedAt: time.Date(2018, 6, 14, 5, 48, 53, 266176036, time.UTC),
|
ExitCode: 0,
|
||||||
UptimeNs: int64(3 * time.Minute),
|
StartedAt: time.Date(2018, 6, 14, 5, 48, 53, 266176036, time.UTC),
|
||||||
|
UptimeNs: int64(3 * time.Minute),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -580,13 +582,14 @@ func TestContainerStatus(t *testing.T) {
|
||||||
return i
|
return i
|
||||||
}(),
|
}(),
|
||||||
expect: expectation{
|
expect: expectation{
|
||||||
Status: "running",
|
ContainerID: "e2173b9478a6ae55e237d4d74f8bbb753f0817192b5081334dc78476296b7dfb",
|
||||||
OOMKilled: false,
|
Status: "running",
|
||||||
Pid: 1234,
|
OOMKilled: false,
|
||||||
ExitCode: 0,
|
Pid: 1234,
|
||||||
StartedAt: time.Date(2018, 6, 14, 5, 48, 53, 266176036, time.UTC),
|
ExitCode: 0,
|
||||||
FinishedAt: time.Date(2018, 6, 14, 5, 53, 53, 266176036, time.UTC),
|
StartedAt: time.Date(2018, 6, 14, 5, 48, 53, 266176036, time.UTC),
|
||||||
UptimeNs: int64(5 * time.Minute),
|
FinishedAt: time.Date(2018, 6, 14, 5, 53, 53, 266176036, time.UTC),
|
||||||
|
UptimeNs: int64(5 * time.Minute),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -598,11 +601,12 @@ func TestContainerStatus(t *testing.T) {
|
||||||
return i
|
return i
|
||||||
}(),
|
}(),
|
||||||
expect: expectation{
|
expect: expectation{
|
||||||
Status: "running",
|
ContainerID: "e2173b9478a6ae55e237d4d74f8bbb753f0817192b5081334dc78476296b7dfb",
|
||||||
OOMKilled: false,
|
Status: "running",
|
||||||
Pid: 1234,
|
OOMKilled: false,
|
||||||
ExitCode: 0,
|
Pid: 1234,
|
||||||
FinishedAt: time.Date(2018, 6, 14, 5, 53, 53, 266176036, time.UTC),
|
ExitCode: 0,
|
||||||
|
FinishedAt: time.Date(2018, 6, 14, 5, 53, 53, 266176036, time.UTC),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -636,9 +640,10 @@ func TestContainerStatus(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"oomkilled": tt.expect.OOMKilled,
|
"oomkilled": tt.expect.OOMKilled,
|
||||||
"pid": tt.expect.Pid,
|
"pid": tt.expect.Pid,
|
||||||
"exitcode": tt.expect.ExitCode,
|
"exitcode": tt.expect.ExitCode,
|
||||||
|
"container_id": tt.expect.ContainerID,
|
||||||
}
|
}
|
||||||
|
|
||||||
if started := tt.expect.StartedAt; !started.IsZero() {
|
if started := tt.expect.StartedAt; !started.IsZero() {
|
||||||
|
@ -756,32 +761,6 @@ func TestDockerGatherInfo(t *testing.T) {
|
||||||
"container_status": "running",
|
"container_status": "running",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
acc.AssertContainsTaggedFields(t,
|
|
||||||
"docker_container_status",
|
|
||||||
map[string]interface{}{
|
|
||||||
"container_id": "b7dfbb9478a6ae55e237d4d74f8bbb753f0817192b5081334dc78476296e2173",
|
|
||||||
"exitcode": int(0),
|
|
||||||
"oomkilled": false,
|
|
||||||
"pid": int(1234),
|
|
||||||
"started_at": int64(1528955333266176036),
|
|
||||||
//"finished_at": float64(0),
|
|
||||||
},
|
|
||||||
map[string]string{
|
|
||||||
"engine_host": "absol",
|
|
||||||
"container_name": "etcd2",
|
|
||||||
"container_image": "quay.io:4443/coreos/etcd",
|
|
||||||
"container_version": "v2.2.2",
|
|
||||||
"ENVVAR1": "loremipsum",
|
|
||||||
"ENVVAR2": "dolorsitamet",
|
|
||||||
"ENVVAR3": "=ubuntu:10.04",
|
|
||||||
"ENVVAR7": "ENVVAR8=ENVVAR9",
|
|
||||||
"label1": "test_value_1",
|
|
||||||
"label2": "test_value_2",
|
|
||||||
"server_version": "17.09.0-ce",
|
|
||||||
"container_status": "running",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDockerGatherSwarmInfo(t *testing.T) {
|
func TestDockerGatherSwarmInfo(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue