Skip to content

Commit 1720692

Browse files
committed
Test update propagation
Test the upgrade path through controllers.
1 parent fe136d3 commit 1720692

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

pkg/controller/controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func New(client cache.ListerWatcher,
7373
excluded []string,
7474
) *Controller {
7575

76-
selector := metav1.ListOptions{LabelSelector: filter}
76+
selector := metav1.ListOptions{LabelSelector: filter, ResourceVersion: "0"}
7777
lw := &cache.ListWatch{
7878
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
7979
return client.List(selector)

pkg/controller/controller_test.go

+40-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,39 @@ var (
6767
"metadata": map[string]interface{}{
6868
"name": "Bar3",
6969
"namespace": "ns3",
70-
"resourceVersion": 1,
70+
"resourceVersion": "1",
71+
"uid": "00000000-0000-0000-0000-000000000042",
72+
"selfLink": "shouldnotbethere",
73+
},
74+
"status": "shouldnotbethere",
75+
},
76+
}
77+
78+
obj4 = &unstructured.Unstructured{
79+
Object: map[string]interface{}{
80+
"apiVersion": "v1",
81+
"kind": "Foo2",
82+
"metadata": map[string]interface{}{
83+
"name": "Bar4",
84+
"namespace": "ns4",
85+
"resourceVersion": "2",
86+
"foo": "canary-bar4",
87+
"uid": "00000000-0000-0000-0000-000000000042",
88+
"selfLink": "shouldnotbethere",
89+
},
90+
"status": "shouldnotbethere",
91+
},
92+
}
93+
94+
obj5 = &unstructured.Unstructured{
95+
Object: map[string]interface{}{
96+
"apiVersion": "v1",
97+
"kind": "Foo2",
98+
"metadata": map[string]interface{}{
99+
"name": "Bar4",
100+
"namespace": "ns4",
101+
"ResourceVersion": "4",
102+
"foo": "canary-bar5",
71103
"uid": "00000000-0000-0000-0000-000000000042",
72104
"selfLink": "shouldnotbethere",
73105
},
@@ -95,6 +127,8 @@ func TestController(t *testing.T) {
95127

96128
client.Add(obj2)
97129
client.Add(obj3)
130+
client.Add(obj4)
131+
client.Modify(obj5)
98132

99133
ctrl.Start()
100134
// wait until queue is drained
@@ -123,6 +157,11 @@ func TestController(t *testing.T) {
123157
if strings.Compare(ev.Key, "ns3/Bar3") == 0 {
124158
t.Error("execludedobject filter failed")
125159
}
160+
161+
// ensure updates propagate
162+
if strings.Contains(string(ev.Object), "canary-bar4") {
163+
t.Error("update didn't propagate")
164+
}
126165
}
127166

128167
if !gotFoo2 {

0 commit comments

Comments
 (0)