@@ -43,13 +43,22 @@ import (
43
43
testhelper "github.com/karmada-io/karmada/test/helper"
44
44
)
45
45
46
- var _ = ginkgo .Describe ("[BasicClusterPropagation] propagation testing" , func () {
46
+ var _ = ginkgo .Describe ("[BasicCase] ClusterPropagationPolicy testing" , func () {
47
+ var policyName string
48
+ var policy * policyv1alpha1.ClusterPropagationPolicy
49
+
50
+ ginkgo .JustBeforeEach (func () {
51
+ framework .CreateClusterPropagationPolicy (karmadaClient , policy )
52
+ ginkgo .DeferCleanup (func () {
53
+ framework .RemoveClusterPropagationPolicy (karmadaClient , policy .Name )
54
+ })
55
+ })
56
+
47
57
ginkgo .Context ("CustomResourceDefinition propagation testing" , func () {
48
58
var crdGroup string
49
59
var randStr string
50
60
var crdSpecNames apiextensionsv1.CustomResourceDefinitionNames
51
61
var crd * apiextensionsv1.CustomResourceDefinition
52
- var crdPolicy * policyv1alpha1.ClusterPropagationPolicy
53
62
54
63
ginkgo .BeforeEach (func () {
55
64
crdGroup = fmt .Sprintf ("example-%s.karmada.io" , rand .String (RandomStrLength ))
@@ -61,7 +70,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
61
70
Singular : fmt .Sprintf ("foo%s" , randStr ),
62
71
}
63
72
crd = testhelper .NewCustomResourceDefinition (crdGroup , crdSpecNames , apiextensionsv1 .NamespaceScoped )
64
- crdPolicy = testhelper .NewClusterPropagationPolicy (crd .Name , []policyv1alpha1.ResourceSelector {
73
+ policyName = crd .Name
74
+ policy = testhelper .NewClusterPropagationPolicy (policyName , []policyv1alpha1.ResourceSelector {
65
75
{
66
76
APIVersion : crd .APIVersion ,
67
77
Kind : crd .Kind ,
@@ -75,10 +85,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
75
85
})
76
86
77
87
ginkgo .BeforeEach (func () {
78
- framework .CreateClusterPropagationPolicy (karmadaClient , crdPolicy )
79
88
framework .CreateCRD (dynamicClient , crd )
80
89
ginkgo .DeferCleanup (func () {
81
- framework .RemoveClusterPropagationPolicy (karmadaClient , crdPolicy .Name )
82
90
framework .RemoveCRD (dynamicClient , crd .Name )
83
91
framework .WaitCRDDisappearedOnClusters (framework .ClusterNames (), crd .Name )
84
92
})
@@ -94,8 +102,6 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
94
102
ginkgo .Context ("ClusterRole propagation testing" , func () {
95
103
var (
96
104
clusterRoleName string
97
- policyName string
98
- policy * policyv1alpha1.ClusterPropagationPolicy
99
105
clusterRole * rbacv1.ClusterRole
100
106
)
101
107
@@ -118,10 +124,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
118
124
})
119
125
120
126
ginkgo .BeforeEach (func () {
121
- framework .CreateClusterPropagationPolicy (karmadaClient , policy )
122
127
framework .CreateClusterRole (kubeClient , clusterRole )
123
128
ginkgo .DeferCleanup (func () {
124
- framework .RemoveClusterPropagationPolicy (karmadaClient , policy .Name )
125
129
framework .RemoveClusterRole (kubeClient , clusterRole .Name )
126
130
framework .WaitClusterRoleDisappearOnClusters (framework .ClusterNames (), clusterRole .Name )
127
131
})
@@ -138,8 +142,6 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
138
142
ginkgo .Context ("ClusterRoleBinding propagation testing" , func () {
139
143
var (
140
144
clusterRoleBindingName string
141
- policyName string
142
- policy * policyv1alpha1.ClusterPropagationPolicy
143
145
clusterRoleBinding * rbacv1.ClusterRoleBinding
144
146
)
145
147
@@ -162,10 +164,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
162
164
})
163
165
164
166
ginkgo .BeforeEach (func () {
165
- framework .CreateClusterPropagationPolicy (karmadaClient , policy )
166
167
framework .CreateClusterRoleBinding (kubeClient , clusterRoleBinding )
167
168
ginkgo .DeferCleanup (func () {
168
- framework .RemoveClusterPropagationPolicy (karmadaClient , policy .Name )
169
169
framework .RemoveClusterRoleBinding (kubeClient , clusterRoleBinding .Name )
170
170
framework .WaitClusterRoleBindingDisappearOnClusters (framework .ClusterNames (), clusterRoleBinding .Name )
171
171
})
@@ -180,13 +180,12 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
180
180
})
181
181
182
182
ginkgo .Context ("Deployment propagation testing" , func () {
183
- var policy * policyv1alpha1.ClusterPropagationPolicy
184
183
var deployment * appsv1.Deployment
185
184
var targetMember string
186
185
187
186
ginkgo .BeforeEach (func () {
188
187
targetMember = framework .ClusterNames ()[0 ]
189
- policyName : = cppNamePrefix + rand .String (RandomStrLength )
188
+ policyName = cppNamePrefix + rand .String (RandomStrLength )
190
189
deploymentName := deploymentNamePrefix + rand .String (RandomStrLength )
191
190
192
191
deployment = testhelper .NewDeployment (testNamespace , deploymentName )
@@ -204,10 +203,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
204
203
})
205
204
206
205
ginkgo .BeforeEach (func () {
207
- framework .CreateClusterPropagationPolicy (karmadaClient , policy )
208
206
framework .CreateDeployment (kubeClient , deployment )
209
207
ginkgo .DeferCleanup (func () {
210
- framework .RemoveClusterPropagationPolicy (karmadaClient , policy .Name )
211
208
framework .RemoveDeployment (kubeClient , deployment .Namespace , deployment .Name )
212
209
})
213
210
})
@@ -227,7 +224,62 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
227
224
})
228
225
})
229
226
230
- var _ = ginkgo .Describe ("[AdvancedClusterPropagation] propagation testing" , func () {
227
+ var _ = ginkgo .Describe ("[CornerCase] ClusterPropagationPolicy testing" , func () {
228
+ var policyName string
229
+ var policy * policyv1alpha1.ClusterPropagationPolicy
230
+
231
+ ginkgo .JustBeforeEach (func () {
232
+ framework .CreateClusterPropagationPolicy (karmadaClient , policy )
233
+ ginkgo .DeferCleanup (func () {
234
+ framework .RemoveClusterPropagationPolicy (karmadaClient , policy .Name )
235
+ })
236
+ })
237
+
238
+ ginkgo .Context ("Deployment propagation testing" , func () {
239
+ var deployment * appsv1.Deployment
240
+ var targetMember string
241
+
242
+ ginkgo .BeforeEach (func () {
243
+ targetMember = framework .ClusterNames ()[0 ]
244
+ policyName = cppNamePrefix + rand .String (RandomStrLength )
245
+ deploymentName := deploymentNamePrefix + rand .String (RandomStrLength )
246
+
247
+ deployment = testhelper .NewDeployment (testNamespace , deploymentName )
248
+ policy = testhelper .NewClusterPropagationPolicy (policyName , []policyv1alpha1.ResourceSelector {
249
+ {
250
+ APIVersion : deployment .APIVersion ,
251
+ Kind : deployment .Kind ,
252
+ Name : deployment .Name ,
253
+ }}, policyv1alpha1.Placement {
254
+ ClusterAffinity : & policyv1alpha1.ClusterAffinity {
255
+ ClusterNames : []string {targetMember },
256
+ },
257
+ })
258
+ })
259
+
260
+ ginkgo .BeforeEach (func () {
261
+ framework .CreateDeployment (kubeClient , deployment )
262
+ ginkgo .DeferCleanup (func () {
263
+ framework .RemoveDeployment (kubeClient , deployment .Namespace , deployment .Name )
264
+ })
265
+ })
266
+
267
+ ginkgo .It ("deployment propagation testing" , func () {
268
+ framework .WaitDeploymentPresentOnClusterFitWith (targetMember , deployment .Namespace , deployment .Name ,
269
+ func (d * appsv1.Deployment ) bool {
270
+ return * d .Spec .Replicas == * deployment .Spec .Replicas
271
+ })
272
+
273
+ framework .UpdateDeploymentReplicas (kubeClient , deployment , updateDeploymentReplicas )
274
+ framework .WaitDeploymentPresentOnClusterFitWith (targetMember , deployment .Namespace , deployment .Name ,
275
+ func (deployment * appsv1.Deployment ) bool {
276
+ return * deployment .Spec .Replicas == updateDeploymentReplicas
277
+ })
278
+ })
279
+ })
280
+ })
281
+
282
+ var _ = ginkgo .Describe ("[AdvancedCase] ClusterPropagationPolicy testing" , func () {
231
283
ginkgo .Context ("Edit ClusterPropagationPolicy ResourceSelectors" , func () {
232
284
ginkgo .When ("propagate namespace scope resource" , func () {
233
285
var policy * policyv1alpha1.ClusterPropagationPolicy
@@ -552,7 +604,7 @@ var _ = ginkgo.Describe("[AdvancedClusterPropagation] propagation testing", func
552
604
553
605
// ImplicitPriority more than one PP matches the object, we should choose the most suitable one.
554
606
// Set it to run sequentially to avoid affecting other test cases.
555
- var _ = framework .SerialDescribe ("[ImplicitPriority] propagation testing" , func () {
607
+ var _ = framework .SerialDescribe ("[ImplicitPriority] ClusterPropagationPolicy testing" , func () {
556
608
ginkgo .Context ("priorityMatchName/priorityMatchLabel/priorityMatchAll propagation testing" , func () {
557
609
var priorityMatchName , priorityMatchLabelSelector , priorityMatchAll string
558
610
var deploymentNamespace , deploymentName string
@@ -652,7 +704,7 @@ var _ = framework.SerialDescribe("[ImplicitPriority] propagation testing", func(
652
704
653
705
// ExplicitPriority more than one CPP matches the object, we should select the one with the highest explicit priority, if the
654
706
// explicit priority is same, select the one with the highest implicit priority.
655
- var _ = ginkgo .Describe ("[ExplicitPriority] propagation testing" , func () {
707
+ var _ = ginkgo .Describe ("[ExplicitPriority] ClusterPropagationPolicy testing" , func () {
656
708
ginkgo .Context ("high explicit/low priority/implicit priority ClusterPropagationPolicy propagation testing" , func () {
657
709
var higherPriorityLabelSelector , lowerPriorityMatchName , implicitPriorityMatchName string
658
710
var deploymentNamespace , deploymentName string
@@ -809,7 +861,7 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() {
809
861
810
862
// Delete when delete a clusterPropagationPolicy, and no more clusterPropagationPolicy matches the object, something like
811
863
// labels should be cleaned.
812
- var _ = ginkgo .Describe ("[Delete] clusterPropagation testing" , func () {
864
+ var _ = ginkgo .Describe ("[DeleteCase] ClusterPropagationPolicy testing" , func () {
813
865
ginkgo .Context ("delete clusterPropagation and remove the labels and annotations from the resource template and reference binding" , func () {
814
866
var policy * policyv1alpha1.ClusterPropagationPolicy
815
867
var deployment * appsv1.Deployment
0 commit comments