@@ -25,6 +25,7 @@ import (
25
25
26
26
v1 "k8s.io/api/core/v1"
27
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
28
29
"k8s.io/apimachinery/pkg/runtime"
29
30
"k8s.io/apimachinery/pkg/types"
30
31
"k8s.io/utils/ptr"
@@ -62,6 +63,34 @@ func TestDataConsistencyChecker(t *testing.T) {
62
63
},
63
64
},
64
65
66
+ {
67
+ name : "data consistency check works with unstructured data (dynamic client)" ,
68
+ lastSyncedResourceVersion : "2" ,
69
+ listResponse : & unstructured.UnstructuredList {
70
+ Object : map [string ]interface {}{
71
+ "apiVersion" : "vTest" ,
72
+ "kind" : "rTestList" ,
73
+ },
74
+ Items : []unstructured.Unstructured {
75
+ * makeUnstructuredObject ("vTest" , "rTest" , "item1" ),
76
+ * makeUnstructuredObject ("vTest" , "rTest" , "item2" ),
77
+ },
78
+ },
79
+ requestOptions : metav1.ListOptions {TimeoutSeconds : ptr .To (int64 (39 ))},
80
+ retrievedItems : []runtime.Object {
81
+ makeUnstructuredObject ("vTest" , "rTest" , "item1" ),
82
+ makeUnstructuredObject ("vTest" , "rTest" , "item2" ),
83
+ },
84
+ expectedListRequests : 1 ,
85
+ expectedRequestOptions : []metav1.ListOptions {
86
+ {
87
+ ResourceVersion : "2" ,
88
+ ResourceVersionMatch : metav1 .ResourceVersionMatchExact ,
89
+ TimeoutSeconds : ptr .To (int64 (39 )),
90
+ },
91
+ },
92
+ },
93
+
65
94
{
66
95
name : "legacy, the limit is removed from the list options when it wasn't honored by the watch cache" ,
67
96
lastSyncedResourceVersion : "2" ,
@@ -238,3 +267,15 @@ func (lw *listWrapper) List(_ context.Context, opts metav1.ListOptions) (runtime
238
267
func makePod (name , rv string ) * v1.Pod {
239
268
return & v1.Pod {ObjectMeta : metav1.ObjectMeta {Name : name , ResourceVersion : rv , UID : types .UID (name )}}
240
269
}
270
+
271
+ func makeUnstructuredObject (version , kind , name string ) * unstructured.Unstructured {
272
+ return & unstructured.Unstructured {
273
+ Object : map [string ]interface {}{
274
+ "apiVersion" : version ,
275
+ "kind" : kind ,
276
+ "metadata" : map [string ]interface {}{
277
+ "name" : name ,
278
+ },
279
+ },
280
+ }
281
+ }
0 commit comments