mirror of https://github.com/docker/docs.git
Merge pull request #22916 from duglin/FixNetTest
Fix flaky TestApiStatsNetworkStats test
This commit is contained in:
commit
004ce6b571
|
@ -107,9 +107,22 @@ func (s *DockerSuite) TestApiStatsNetworkStats(c *check.C) {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
countParam = "-n" // Ping count parameter is -n on Windows
|
countParam = "-n" // Ping count parameter is -n on Windows
|
||||||
}
|
}
|
||||||
pingout, err := exec.Command("ping", contIP, countParam, strconv.Itoa(numPings)).Output()
|
pingout, err := exec.Command("ping", contIP, countParam, strconv.Itoa(numPings)).CombinedOutput()
|
||||||
pingouts := string(pingout[:])
|
if err != nil && runtime.GOOS == "linux" {
|
||||||
|
// If it fails then try a work-around, but just for linux.
|
||||||
|
// If this fails too then go back to the old error for reporting.
|
||||||
|
//
|
||||||
|
// The ping will sometimes fail due to an apparmor issue where it
|
||||||
|
// denies access to the libc.so.6 shared library - running it
|
||||||
|
// via /lib64/ld-linux-x86-64.so.2 seems to work around it.
|
||||||
|
pingout2, err2 := exec.Command("/lib64/ld-linux-x86-64.so.2", "/bin/ping", contIP, "-c", strconv.Itoa(numPings)).CombinedOutput()
|
||||||
|
if err2 == nil {
|
||||||
|
pingout = pingout2
|
||||||
|
err = err2
|
||||||
|
}
|
||||||
|
}
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
pingouts := string(pingout[:])
|
||||||
nwStatsPost := getNetworkStats(c, id)
|
nwStatsPost := getNetworkStats(c, id)
|
||||||
for _, v := range nwStatsPost {
|
for _, v := range nwStatsPost {
|
||||||
postRxPackets += v.RxPackets
|
postRxPackets += v.RxPackets
|
||||||
|
|
Loading…
Reference in New Issue