@@ -75,7 +75,7 @@ func TestReconcileAPIExports(t *testing.T) {
75
75
ts .Fatalf ("failed to convert unstructured to APIExport: %v" , err )
76
76
}
77
77
78
- expectedApiExport := newAPIExport ("foo" )
78
+ expectedApiExport := newAPIExportWithShardAnnotation ("foo" )
79
79
if ! equality .Semantic .DeepEqual (cacheApiExportFromUnstructured , expectedApiExport ) {
80
80
ts .Errorf ("unexpected ApiExport was creaetd:\n %s" , cmp .Diff (cacheApiExportFromUnstructured , expectedApiExport ))
81
81
}
@@ -99,7 +99,7 @@ func TestReconcileAPIExports(t *testing.T) {
99
99
return apiExport
100
100
}(),
101
101
},
102
- initialCacheApiExports : []runtime.Object {newAPIExport ("foo" )},
102
+ initialCacheApiExports : []runtime.Object {newAPIExportWithShardAnnotation ("foo" )},
103
103
initCacheFakeClientWithInitialApiExports : true ,
104
104
reconcileKey : "root|foo" ,
105
105
validateFunc : func (ts * testing.T , cacheClientActions []clientgotesting.Action , localClientActions []clientgotesting.Action , targetClusterCacheClient , targetClusterLocalClient logicalcluster.Name ) {
@@ -127,7 +127,7 @@ func TestReconcileAPIExports(t *testing.T) {
127
127
},
128
128
{
129
129
name : "case 2: cached object is removed when local object was not found" ,
130
- initialCacheApiExports : []runtime.Object {newAPIExport ("foo" )},
130
+ initialCacheApiExports : []runtime.Object {newAPIExportWithShardAnnotation ("foo" )},
131
131
initCacheFakeClientWithInitialApiExports : true ,
132
132
reconcileKey : "root|foo" ,
133
133
validateFunc : func (ts * testing.T , cacheClientActions []clientgotesting.Action , localClientActions []clientgotesting.Action , targetClusterCacheClient , targetClusterLocalClient logicalcluster.Name ) {
@@ -176,7 +176,7 @@ func TestReconcileAPIExports(t *testing.T) {
176
176
return apiExport
177
177
}(),
178
178
},
179
- initialCacheApiExports : []runtime.Object {newAPIExport ("foo" )},
179
+ initialCacheApiExports : []runtime.Object {newAPIExportWithShardAnnotation ("foo" )},
180
180
initCacheFakeClientWithInitialApiExports : true ,
181
181
reconcileKey : "root|foo" ,
182
182
validateFunc : func (ts * testing.T , cacheClientActions []clientgotesting.Action , localClientActions []clientgotesting.Action , targetClusterCacheClient , targetClusterLocalClient logicalcluster.Name ) {
@@ -196,7 +196,7 @@ func TestReconcileAPIExports(t *testing.T) {
196
196
ts .Fatalf ("failed to convert unstructured to APIExport: %v" , err )
197
197
}
198
198
199
- expectedApiExport := newAPIExport ("foo" )
199
+ expectedApiExport := newAPIExportWithShardAnnotation ("foo" )
200
200
expectedApiExport .Labels ["fooLabel" ] = "fooLabelVal"
201
201
if ! equality .Semantic .DeepEqual (cacheApiExportFromUnstructured , expectedApiExport ) {
202
202
ts .Errorf ("unexpected update to the ApiExport:\n %s" , cmp .Diff (cacheApiExportFromUnstructured , expectedApiExport ))
@@ -219,7 +219,7 @@ func TestReconcileAPIExports(t *testing.T) {
219
219
return apiExport
220
220
}(),
221
221
},
222
- initialCacheApiExports : []runtime.Object {newAPIExport ("foo" )},
222
+ initialCacheApiExports : []runtime.Object {newAPIExportWithShardAnnotation ("foo" )},
223
223
initCacheFakeClientWithInitialApiExports : true ,
224
224
reconcileKey : "root|foo" ,
225
225
validateFunc : func (ts * testing.T , cacheClientActions []clientgotesting.Action , localClientActions []clientgotesting.Action , targetClusterCacheClient , targetClusterLocalClient logicalcluster.Name ) {
@@ -239,7 +239,7 @@ func TestReconcileAPIExports(t *testing.T) {
239
239
ts .Fatalf ("failed to convert unstructured to APIExport: %v" , err )
240
240
}
241
241
242
- expectedApiExport := newAPIExport ("foo" )
242
+ expectedApiExport := newAPIExportWithShardAnnotation ("foo" )
243
243
expectedApiExport .Spec .PermissionClaims = []apisv1alpha1.PermissionClaim {{GroupResource : apisv1alpha1.GroupResource {}, IdentityHash : "abc" }}
244
244
if ! equality .Semantic .DeepEqual (cacheApiExportFromUnstructured , expectedApiExport ) {
245
245
ts .Errorf ("unexpected update to the ApiExport:\n %s" , cmp .Diff (cacheApiExportFromUnstructured , expectedApiExport ))
@@ -262,7 +262,7 @@ func TestReconcileAPIExports(t *testing.T) {
262
262
return apiExport
263
263
}(),
264
264
},
265
- initialCacheApiExports : []runtime.Object {newAPIExport ("foo" )},
265
+ initialCacheApiExports : []runtime.Object {newAPIExportWithShardAnnotation ("foo" )},
266
266
initCacheFakeClientWithInitialApiExports : true ,
267
267
reconcileKey : "root|foo" ,
268
268
validateFunc : func (ts * testing.T , cacheClientActions []clientgotesting.Action , localClientActions []clientgotesting.Action , targetClusterCacheClient , targetClusterLocalClient logicalcluster.Name ) {
@@ -282,7 +282,7 @@ func TestReconcileAPIExports(t *testing.T) {
282
282
ts .Fatalf ("failed to convert unstructured to APIExport: %v" , err )
283
283
}
284
284
285
- expectedApiExport := newAPIExport ("foo" )
285
+ expectedApiExport := newAPIExportWithShardAnnotation ("foo" )
286
286
expectedApiExport .Status .VirtualWorkspaces = []apisv1alpha1.VirtualWorkspace {{URL : "https://acme.dev" }}
287
287
if ! equality .Semantic .DeepEqual (cacheApiExportFromUnstructured , expectedApiExport ) {
288
288
ts .Errorf ("unexpected update to the ApiExport:\n %s" , cmp .Diff (cacheApiExportFromUnstructured , expectedApiExport ))
@@ -342,7 +342,6 @@ func newAPIExport(name string) *apisv1alpha1.APIExport {
342
342
Labels : map [string ]string {},
343
343
Annotations : map [string ]string {
344
344
logicalcluster .AnnotationKey : "root" ,
345
- "kcp.dev/shard" : "amber" ,
346
345
},
347
346
Name : name ,
348
347
},
@@ -355,6 +354,12 @@ func newAPIExport(name string) *apisv1alpha1.APIExport {
355
354
}
356
355
}
357
356
357
+ func newAPIExportWithShardAnnotation (name string ) * apisv1alpha1.APIExport {
358
+ apiExport := newAPIExport (name )
359
+ apiExport .Annotations ["kcp.dev/shard" ] = "amber"
360
+ return apiExport
361
+ }
362
+
358
363
func newFakeKcpClusterClient (ds * dynamicfake.FakeDynamicClient ) * fakeKcpClusterClient {
359
364
return & fakeKcpClusterClient {fakeDs : ds }
360
365
}
0 commit comments