@@ -28,6 +28,7 @@ import (
2828
2929 "github.com/spf13/cobra"
3030 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3132 "k8s.io/apimachinery/pkg/runtime"
3233 "k8s.io/apimachinery/pkg/runtime/schema"
3334 "k8s.io/apimachinery/pkg/version"
@@ -164,7 +165,34 @@ var _ = Describe("create cluster by cluster type", func() {
164165 Expect (o .Complete (shardCmd )).Should (Succeed ())
165166 Expect (o .Name ).ShouldNot (BeEmpty ())
166167 Expect (o .Values ).ShouldNot (BeNil ())
167- Expect (o .ChartInfo .ComponentDef [0 ]).Should (Equal (redisComponent ))
168+ Expect (o .ChartInfo .ClusterDef ).Should (Equal (redisCluster ))
169+ hasRedisComponentDef := false
170+ for _ , componentDef := range o .ChartInfo .ComponentDef {
171+ if componentDef == redisComponent {
172+ hasRedisComponentDef = true
173+ break
174+ }
175+ }
176+ objs , err := o .getObjectsInfo ()
177+ Expect (err ).ShouldNot (HaveOccurred ())
178+ clusterObj , err := o .getClusterObj (objs )
179+ Expect (err ).ShouldNot (HaveOccurred ())
180+ hasShardingDef := false
181+ shardings , ok , err := unstructured .NestedSlice (clusterObj .Object , "spec" , "shardings" )
182+ Expect (err ).ShouldNot (HaveOccurred ())
183+ if ok {
184+ for _ , item := range shardings {
185+ shardingSpec , ok := item .(map [string ]interface {})
186+ if ! ok {
187+ continue
188+ }
189+ if shardingDef , ok := shardingSpec ["shardingDef" ].(string ); ok && shardingDef != "" {
190+ hasShardingDef = true
191+ break
192+ }
193+ }
194+ }
195+ Expect (hasShardingDef || hasRedisComponentDef ).Should (BeTrue (), "redis sharding chart should set either shardingDef or componentDef" )
168196
169197 By ("validate" )
170198 o .Dynamic = testing .FakeDynamicClient ()
0 commit comments