Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Commit

Permalink
> fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
kebe7jun committed Apr 24, 2022
1 parent 53266f2 commit ec125a9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func serverPrint(items []interface{}) interface{} {
indexMap := map[string]int{}
for i, item := range items {
if oo, ok := item.(v1.Object); ok {
indexesStr := oo.GetAnnotations()["anno.dsm.daocloud.io/indexes"]
indexesStr := oo.GetAnnotations()[constants.IndexAnno]
if len(indexesStr) == 0 {
continue
}
Expand Down
2 changes: 2 additions & 0 deletions common/constants/ckube.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
SearchPartsSep = ';'
DSMClusterAnno = "ckube.doacloud.io/cluster"
ClusterPrefix = "dsm-cluster-"
IndexAnno = "ckube.daocloud.io/indexes"
)

var (
Expand All @@ -24,4 +25,5 @@ var (
_ = SearchPartsSep
_ = DSMClusterAnno
_ = ClusterPrefix
_ = IndexAnno
)
2 changes: 1 addition & 1 deletion store/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (m *memoryStore) buildResourceWithIndex(gvr store.GroupVersionResource, clu
}
anno := oo.GetAnnotations()
index, _ := json.Marshal(s.Index)
anno["anno.dsm.daocloud.io/indexes"] = string(index) // todo constants
anno[constants.IndexAnno] = string(index) // todo constants
oo.SetAnnotations(anno)
s.Obj = oo
}
Expand Down
22 changes: 22 additions & 0 deletions store/memory/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "test",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test1\",\"namespace\":\"test\",\"uid\":\"test\"}",
},
},
}),
Expand Down Expand Up @@ -117,6 +118,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "test",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test2\",\"namespace\":\"test\",\"uid\":\"test\"}",
},
},
}),
Expand Down Expand Up @@ -160,6 +162,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "test",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"hello\",\"namespace\":\"test\",\"uid\":\"test\"}",
},
},
}, &v1.Pod{
Expand All @@ -169,6 +172,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "test",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"llo\",\"namespace\":\"test\",\"uid\":\"test\"}",
},
},
}),
Expand Down Expand Up @@ -212,6 +216,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "test",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"llo\",\"namespace\":\"test\",\"uid\":\"test\"}",
},
},
}),
Expand Down Expand Up @@ -288,6 +293,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "test",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"hello\",\"namespace\":\"test\",\"uid\":\"test\"}",
},
},
}, &v1.Pod{
Expand All @@ -297,6 +303,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "test",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"l1lo\",\"namespace\":\"test\",\"uid\":\"test\"}",
},
},
}),
Expand Down Expand Up @@ -394,6 +401,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "1",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test5\",\"namespace\":\"test\",\"uid\":\"1\"}",
},
},
}, &v1.Pod{
Expand All @@ -403,6 +411,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "2",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test1\",\"namespace\":\"test\",\"uid\":\"2\"}",
},
},
}, &v1.Pod{
Expand All @@ -412,6 +421,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "3",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test3\",\"namespace\":\"test\",\"uid\":\"3\"}",
},
},
}),
Expand Down Expand Up @@ -455,6 +465,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "3",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test3\",\"namespace\":\"test\",\"uid\":\"3\"}",
},
},
}, &v1.Pod{
Expand All @@ -464,6 +475,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "2",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test1\",\"namespace\":\"test\",\"uid\":\"2\"}",
},
},
}, &v1.Pod{
Expand All @@ -473,6 +485,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "1",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test5\",\"namespace\":\"test\",\"uid\":\"1\"}",
},
},
}),
Expand Down Expand Up @@ -543,6 +556,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "3",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test3\",\"namespace\":\"test\",\"uid\":\"3\"}",
},
},
}, &v1.Pod{
Expand All @@ -552,6 +566,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "2",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test1\",\"namespace\":\"test\",\"uid\":\"2\"}",
},
},
}, &v1.Pod{
Expand All @@ -561,6 +576,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "1",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test5\",\"namespace\":\"test1\",\"uid\":\"1\"}",
},
},
}),
Expand Down Expand Up @@ -604,6 +620,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "2",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test5\",\"namespace\":\"test\",\"uid\":\"2\"}",
},
},
}, &v1.Pod{
Expand All @@ -613,6 +630,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "3",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test3\",\"namespace\":\"test\",\"uid\":\"3\"}",
},
},
}, &v1.Pod{
Expand All @@ -622,6 +640,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "11",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test1\",\"namespace\":\"test\",\"uid\":\"11\"}",
},
},
}),
Expand Down Expand Up @@ -692,6 +711,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "3",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test3\",\"namespace\":\"test\",\"uid\":\"3\"}",
},
},
}, &v1.Pod{
Expand All @@ -701,6 +721,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "11",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test1\",\"namespace\":\"test\",\"uid\":\"11\"}",
},
},
}, &v1.Pod{
Expand All @@ -710,6 +731,7 @@ func TestMemoryStore_Query(t *testing.T) {
UID: "20",
Annotations: map[string]string{
constants.DSMClusterAnno: "",
constants.IndexAnno: "{\"cluster\":\"\",\"is_deleted\":\"false\",\"name\":\"test13\",\"namespace\":\"test1\",\"uid\":\"20\"}",
},
},
}),
Expand Down

0 comments on commit ec125a9

Please sign in to comment.