Merge pull request #51759 from wackxu/addtestcase

Automatic merge from submit-queue (batch tested with PRs 51759, 53001, 52806). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>..

add verify case in index_test.go

**What this PR does / why we need it**:

There only verify the length of the result in the index_test and we should  also verify the content of the result.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```

Kubernetes-commit: c3b443b41c56de0ea012726a581b917e1665416d
This commit is contained in:
Kubernetes Publisher 2017-09-25 15:50:50 -07:00
commit 350fc9ed99
2 changed files with 80 additions and 49 deletions

98
Godeps/Godeps.json generated
View File

@ -476,199 +476,199 @@
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/equality", "ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/errors", "ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/meta", "ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/resource", "ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion", "ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured", "ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/fields", "ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/labels", "ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime", "ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/selection", "ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/types", "ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/cache", "ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/clock", "ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/diff", "ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/errors", "ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/framer", "ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr", "ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/json", "ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/net", "ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand", "ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime", "ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/sets", "ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation", "ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/wait", "ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml", "ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/version", "ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/watch", "ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "90cdcb76c44bf1fcf0aa82aeea7f614c034cbd4b" "Rev": "9496c30d9f9382f60f820cb392433abcabd2f47a"
}, },
{ {
"ImportPath": "k8s.io/kube-openapi/pkg/common", "ImportPath": "k8s.io/kube-openapi/pkg/common",

View File

@ -77,6 +77,11 @@ func TestMultiIndexKeys(t *testing.T) {
if len(erniePods) != 2 { if len(erniePods) != 2 {
t.Errorf("Expected 2 pods but got %v", len(erniePods)) t.Errorf("Expected 2 pods but got %v", len(erniePods))
} }
for _, erniePod := range erniePods {
if erniePod.(*v1.Pod).Name != "one" && erniePod.(*v1.Pod).Name != "tre" {
t.Errorf("Expected only 'one' or 'tre' but got %s", erniePod.(*v1.Pod).Name)
}
}
bertPods, err := index.ByIndex("byUser", "bert") bertPods, err := index.ByIndex("byUser", "bert")
if err != nil { if err != nil {
@ -85,6 +90,11 @@ func TestMultiIndexKeys(t *testing.T) {
if len(bertPods) != 2 { if len(bertPods) != 2 {
t.Errorf("Expected 2 pods but got %v", len(bertPods)) t.Errorf("Expected 2 pods but got %v", len(bertPods))
} }
for _, bertPod := range bertPods {
if bertPod.(*v1.Pod).Name != "one" && bertPod.(*v1.Pod).Name != "two" {
t.Errorf("Expected only 'one' or 'two' but got %s", bertPod.(*v1.Pod).Name)
}
}
oscarPods, err := index.ByIndex("byUser", "oscar") oscarPods, err := index.ByIndex("byUser", "oscar")
if err != nil { if err != nil {
@ -93,6 +103,11 @@ func TestMultiIndexKeys(t *testing.T) {
if len(oscarPods) != 1 { if len(oscarPods) != 1 {
t.Errorf("Expected 1 pods but got %v", len(erniePods)) t.Errorf("Expected 1 pods but got %v", len(erniePods))
} }
for _, oscarPod := range oscarPods {
if oscarPod.(*v1.Pod).Name != "two" {
t.Errorf("Expected only 'two' but got %s", oscarPod.(*v1.Pod).Name)
}
}
ernieAndBertKeys, err := index.Index("byUser", pod1) ernieAndBertKeys, err := index.Index("byUser", pod1)
if err != nil { if err != nil {
@ -101,6 +116,11 @@ func TestMultiIndexKeys(t *testing.T) {
if len(ernieAndBertKeys) != 3 { if len(ernieAndBertKeys) != 3 {
t.Errorf("Expected 3 pods but got %v", len(ernieAndBertKeys)) t.Errorf("Expected 3 pods but got %v", len(ernieAndBertKeys))
} }
for _, ernieAndBertKey := range ernieAndBertKeys {
if ernieAndBertKey.(*v1.Pod).Name != "one" && ernieAndBertKey.(*v1.Pod).Name != "two" && ernieAndBertKey.(*v1.Pod).Name != "tre" {
t.Errorf("Expected only 'one', 'two' or 'tre' but got %s", ernieAndBertKey.(*v1.Pod).Name)
}
}
index.Delete(pod3) index.Delete(pod3)
erniePods, err = index.ByIndex("byUser", "ernie") erniePods, err = index.ByIndex("byUser", "ernie")
@ -110,6 +130,12 @@ func TestMultiIndexKeys(t *testing.T) {
if len(erniePods) != 1 { if len(erniePods) != 1 {
t.Errorf("Expected 1 pods but got %v", len(erniePods)) t.Errorf("Expected 1 pods but got %v", len(erniePods))
} }
for _, erniePod := range erniePods {
if erniePod.(*v1.Pod).Name != "one" {
t.Errorf("Expected only 'one' but got %s", erniePod.(*v1.Pod).Name)
}
}
elmoPods, err := index.ByIndex("byUser", "elmo") elmoPods, err := index.ByIndex("byUser", "elmo")
if err != nil { if err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
@ -128,5 +154,10 @@ func TestMultiIndexKeys(t *testing.T) {
if len(bertPods) != 1 { if len(bertPods) != 1 {
t.Errorf("Expected 1 pods but got %v", len(bertPods)) t.Errorf("Expected 1 pods but got %v", len(bertPods))
} }
for _, bertPod := range bertPods {
if bertPod.(*v1.Pod).Name != "one" {
t.Errorf("Expected only 'one' but got %s", bertPod.(*v1.Pod).Name)
}
}
} }