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

View File

@ -77,6 +77,11 @@ func TestMultiIndexKeys(t *testing.T) {
if len(erniePods) != 2 {
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")
if err != nil {
@ -85,6 +90,11 @@ func TestMultiIndexKeys(t *testing.T) {
if len(bertPods) != 2 {
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")
if err != nil {
@ -93,6 +103,11 @@ func TestMultiIndexKeys(t *testing.T) {
if len(oscarPods) != 1 {
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)
if err != nil {
@ -101,6 +116,11 @@ func TestMultiIndexKeys(t *testing.T) {
if len(ernieAndBertKeys) != 3 {
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)
erniePods, err = index.ByIndex("byUser", "ernie")
@ -110,6 +130,12 @@ func TestMultiIndexKeys(t *testing.T) {
if len(erniePods) != 1 {
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")
if err != nil {
t.Errorf("unexpected error: %v", err)
@ -128,5 +154,10 @@ func TestMultiIndexKeys(t *testing.T) {
if len(bertPods) != 1 {
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)
}
}
}