@@ -131,6 +131,34 @@ var _ = Describe("builder", func() {
131131 Expect (* its .Spec .MemberUpdateStrategy ).Should (BeEquivalentTo (workloads .BestEffortParallelUpdateStrategy ))
132132 })
133133
134+ It ("propagates sharding labels to InstanceSet metadata" , func () {
135+ shardingName := "shard"
136+ compLabels := constant .GetClusterLabels (clusterName , map [string ]string {
137+ constant .KBAppShardingNameLabelKey : shardingName ,
138+ })
139+ synthesizedComp := & component.SynthesizedComponent {
140+ Namespace : testCtx .DefaultNamespace ,
141+ ClusterName : clusterName ,
142+ Name : "shard-a" ,
143+ CompDefName : "mongodb" ,
144+ Generation : "1" ,
145+ Labels : compLabels ,
146+ DynamicLabels : map [string ]string {"dynamic-label" : "true" },
147+ Replicas : 1 ,
148+ PodSpec : & corev1.PodSpec {
149+ Containers : []corev1.Container {{Name : "mongodb" }},
150+ },
151+ }
152+
153+ its , err := BuildInstanceSet (synthesizedComp , nil )
154+
155+ Expect (err ).Should (Succeed ())
156+ Expect (its .Labels ).Should (HaveKeyWithValue (constant .KBAppShardingNameLabelKey , shardingName ))
157+ Expect (its .Labels ).Should (HaveKeyWithValue ("dynamic-label" , "true" ))
158+ Expect (its .Spec .Selector .MatchLabels ).Should (HaveKeyWithValue (constant .KBAppShardingNameLabelKey , shardingName ))
159+ Expect (its .Spec .Template .Labels ).Should (HaveKeyWithValue (constant .KBAppShardingNameLabelKey , shardingName ))
160+ })
161+
134162 It ("builds ConfigMap with template correctly" , func () {
135163 config := map [string ]string {}
136164 _ , cluster , synthesizedComponent := newClusterObjs (nil )
0 commit comments