mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
integ-cli: fix clock skew against remote test daemon
This fixes the `docker events`-related tests as they have been failing due to clock skew between CI machine and test daemon on some other machine (even 1-2 seconds of diff causes races as we pass local time to --since/--until). If we're running in same host, we keep using time.Now(), otherwise we read the system time of the daemon from `/info` endpoint. Fixes pretty much all events-related tests on windows CI. Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
This commit is contained in:
parent
d010bf0d99
commit
e424c54d9c
4 changed files with 47 additions and 26 deletions
|
@ -9,7 +9,6 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/kr/pty"
|
||||
|
@ -17,11 +16,8 @@ import (
|
|||
|
||||
// #5979
|
||||
func TestEventsRedirectStdout(t *testing.T) {
|
||||
|
||||
since := time.Now().Unix()
|
||||
|
||||
since := daemonTime(t).Unix()
|
||||
dockerCmd(t, "run", "busybox", "true")
|
||||
|
||||
defer deleteAllContainers()
|
||||
|
||||
file, err := ioutil.TempFile("", "")
|
||||
|
@ -30,7 +26,7 @@ func TestEventsRedirectStdout(t *testing.T) {
|
|||
}
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
command := fmt.Sprintf("%s events --since=%d --until=%d > %s", dockerBinary, since, time.Now().Unix(), file.Name())
|
||||
command := fmt.Sprintf("%s events --since=%d --until=%d > %s", dockerBinary, since, daemonTime(t).Unix(), file.Name())
|
||||
_, tty, err := pty.Open()
|
||||
if err != nil {
|
||||
t.Fatalf("Could not open pty: %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue