Add min/max response time on linux/darwin to ping (#2908)
This commit is contained in:
committed by
Daniel Nelson
parent
26e526df67
commit
075066f452
@@ -48,25 +48,29 @@ ping: -i interval too short: Operation not permitted
|
||||
|
||||
// Test that ping command output is processed properly
|
||||
func TestProcessPingOutput(t *testing.T) {
|
||||
trans, rec, avg, stddev, err := processPingOutput(bsdPingOutput)
|
||||
trans, rec, min, avg, max, stddev, err := processPingOutput(bsdPingOutput)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 5, trans, "5 packets were transmitted")
|
||||
assert.Equal(t, 5, rec, "5 packets were transmitted")
|
||||
assert.InDelta(t, 15.087, min, 0.001)
|
||||
assert.InDelta(t, 20.224, avg, 0.001)
|
||||
assert.InDelta(t, 27.263, max, 0.001)
|
||||
assert.InDelta(t, 4.076, stddev, 0.001)
|
||||
|
||||
trans, rec, avg, stddev, err = processPingOutput(linuxPingOutput)
|
||||
trans, rec, min, avg, max, stddev, err = processPingOutput(linuxPingOutput)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 5, trans, "5 packets were transmitted")
|
||||
assert.Equal(t, 5, rec, "5 packets were transmitted")
|
||||
assert.InDelta(t, 35.225, min, 0.001)
|
||||
assert.InDelta(t, 43.628, avg, 0.001)
|
||||
assert.InDelta(t, 51.806, max, 0.001)
|
||||
assert.InDelta(t, 5.325, stddev, 0.001)
|
||||
}
|
||||
|
||||
// Test that processPingOutput returns an error when 'ping' fails to run, such
|
||||
// as when an invalid argument is provided
|
||||
func TestErrorProcessPingOutput(t *testing.T) {
|
||||
_, _, _, _, err := processPingOutput(fatalPingOutput)
|
||||
_, _, _, _, _, _, err := processPingOutput(fatalPingOutput)
|
||||
assert.Error(t, err, "Error was expected from processPingOutput")
|
||||
}
|
||||
|
||||
@@ -150,7 +154,9 @@ func TestPingGather(t *testing.T) {
|
||||
"packets_transmitted": 5,
|
||||
"packets_received": 5,
|
||||
"percent_packet_loss": 0.0,
|
||||
"minimum_response_ms": 35.225,
|
||||
"average_response_ms": 43.628,
|
||||
"maximum_response_ms": 51.806,
|
||||
"standard_deviation_ms": 5.325,
|
||||
}
|
||||
acc.AssertContainsTaggedFields(t, "ping", fields, tags)
|
||||
@@ -188,7 +194,9 @@ func TestLossyPingGather(t *testing.T) {
|
||||
"packets_transmitted": 5,
|
||||
"packets_received": 3,
|
||||
"percent_packet_loss": 40.0,
|
||||
"minimum_response_ms": 35.225,
|
||||
"average_response_ms": 44.033,
|
||||
"maximum_response_ms": 51.806,
|
||||
"standard_deviation_ms": 5.325,
|
||||
}
|
||||
acc.AssertContainsTaggedFields(t, "ping", fields, tags)
|
||||
@@ -244,6 +252,10 @@ func TestFatalPingGather(t *testing.T) {
|
||||
"Fatal ping should not have packet measurements")
|
||||
assert.False(t, acc.HasMeasurement("percent_packet_loss"),
|
||||
"Fatal ping should not have packet measurements")
|
||||
assert.False(t, acc.HasMeasurement("minimum_response_ms"),
|
||||
"Fatal ping should not have packet measurements")
|
||||
assert.False(t, acc.HasMeasurement("average_response_ms"),
|
||||
"Fatal ping should not have packet measurements")
|
||||
assert.False(t, acc.HasMeasurement("maximum_response_ms"),
|
||||
"Fatal ping should not have packet measurements")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user