Merge pull request #33448 from Random-Liu/fix-dockershim-unit-test-flake

Automatic merge from submit-queue

Use fakeclock correctly in dockershim unit test.

Fixes https://github.com/kubernetes/kubernetes/issues/33428.

/cc @feiskyer @yujuhong
This commit is contained in:
Kubernetes Submit Queue 2016-09-26 11:59:11 -07:00 committed by GitHub
commit 273f02c8b2
2 changed files with 3 additions and 3 deletions

View File

@ -123,7 +123,7 @@ func TestContainerStatus(t *testing.T) {
}
// Create the container.
fClock.SetTime(time.Now())
fClock.SetTime(time.Now().Add(-1 * time.Hour))
*expected.CreatedAt = fClock.Now().Unix()
id, err := ds.CreateContainer("sandboxid", config, sConfig)
// Set the id manually since we don't know the id until it's created.
@ -144,7 +144,7 @@ func TestContainerStatus(t *testing.T) {
assert.Equal(t, expected, status)
// Advance the clock and stop the container.
fClock.SetTime(time.Now())
fClock.SetTime(time.Now().Add(1 * time.Hour))
*expected.FinishedAt = fClock.Now().Unix()
*expected.State = runtimeApi.ContainerState_EXITED
*expected.Reason = "Completed"

View File

@ -24,7 +24,7 @@ import (
)
func newTestDockerSevice() (*dockerService, *dockertools.FakeDockerClient, *clock.FakeClock) {
c := dockertools.NewFakeDockerClient()
fakeClock := clock.NewFakeClock(time.Time{})
c := dockertools.NewFakeDockerClientWithClock(fakeClock)
return &dockerService{client: c}, c, fakeClock
}