mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 06:32:32 +00:00
kubelet_test: Add verifyUnorderedCalls().
This fixes TestSyncPodsDeletesWithNoPodInfraContainer. Since we need to sync two pods in parallel, we should not verify the docker calls in strict order.
This commit is contained in:
@@ -19,6 +19,7 @@ package dockertools
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -66,6 +67,23 @@ func (f *FakeDockerClient) AssertCalls(calls []string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (f *FakeDockerClient) AssertUnorderedCalls(calls []string) (err error) {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
var actual, expected []string
|
||||
copy(actual, calls)
|
||||
copy(expected, f.called)
|
||||
|
||||
sort.StringSlice(actual).Sort()
|
||||
sort.StringSlice(expected).Sort()
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
err = fmt.Errorf("expected(sorted) %#v, got(sorted) %#v", expected, actual)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListContainers is a test-spy implementation of DockerInterface.ListContainers.
|
||||
// It adds an entry "list" to the internal method call record.
|
||||
func (f *FakeDockerClient) ListContainers(options docker.ListContainersOptions) ([]docker.APIContainers, error) {
|
||||
|
Reference in New Issue
Block a user