mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
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:
commit
273f02c8b2
@ -123,7 +123,7 @@ func TestContainerStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the container.
|
// Create the container.
|
||||||
fClock.SetTime(time.Now())
|
fClock.SetTime(time.Now().Add(-1 * time.Hour))
|
||||||
*expected.CreatedAt = fClock.Now().Unix()
|
*expected.CreatedAt = fClock.Now().Unix()
|
||||||
id, err := ds.CreateContainer("sandboxid", config, sConfig)
|
id, err := ds.CreateContainer("sandboxid", config, sConfig)
|
||||||
// Set the id manually since we don't know the id until it's created.
|
// 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)
|
assert.Equal(t, expected, status)
|
||||||
|
|
||||||
// Advance the clock and stop the container.
|
// 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.FinishedAt = fClock.Now().Unix()
|
||||||
*expected.State = runtimeApi.ContainerState_EXITED
|
*expected.State = runtimeApi.ContainerState_EXITED
|
||||||
*expected.Reason = "Completed"
|
*expected.Reason = "Completed"
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func newTestDockerSevice() (*dockerService, *dockertools.FakeDockerClient, *clock.FakeClock) {
|
func newTestDockerSevice() (*dockerService, *dockertools.FakeDockerClient, *clock.FakeClock) {
|
||||||
c := dockertools.NewFakeDockerClient()
|
|
||||||
fakeClock := clock.NewFakeClock(time.Time{})
|
fakeClock := clock.NewFakeClock(time.Time{})
|
||||||
|
c := dockertools.NewFakeDockerClientWithClock(fakeClock)
|
||||||
return &dockerService{client: c}, c, fakeClock
|
return &dockerService{client: c}, c, fakeClock
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user