mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-05 21:21:42 +00:00
Add system time to /info
This change adds daemon's system time as RFC3339Nano to the `/info` endpoint and shows in a more readable format (UnixDate) in `docker -D info` output. I will be using this to fix the clock skew between the remote test host and the CI machines running `docker events`-related tests as they're using `--since` and `--until` and the timestamps are not matching when daemon is not on the same machine. Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/testutils"
|
||||
)
|
||||
@@ -94,6 +95,27 @@ func TestSetenvBool(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetenvTime(t *testing.T) {
|
||||
job := mkJob(t, "dummy")
|
||||
|
||||
now := time.Now()
|
||||
job.SetenvTime("foo", now)
|
||||
if val, err := job.GetenvTime("foo"); err != nil {
|
||||
t.Fatalf("GetenvTime failed to parse: %v", err)
|
||||
} else {
|
||||
nowStr := now.Format(time.RFC3339)
|
||||
valStr := val.Format(time.RFC3339)
|
||||
if nowStr != valStr {
|
||||
t.Fatalf("GetenvTime returns incorrect value: %s, Expected: %s", valStr, nowStr)
|
||||
}
|
||||
}
|
||||
|
||||
job.Setenv("bar", "Obviously I'm not a date")
|
||||
if val, err := job.GetenvTime("bar"); err == nil {
|
||||
t.Fatalf("GetenvTime was supposed to fail, instead returned: %s", val)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetenvInt(t *testing.T) {
|
||||
job := mkJob(t, "dummy")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user