From b27c78a8bd7685c4500b74693bc716d0199a9042 Mon Sep 17 00:00:00 2001 From: wangyelei Date: Mon, 2 Dec 2024 14:24:52 +0800 Subject: [PATCH] fix make test bug --- controllers/apps/transformer_cluster_component.go | 2 +- controllers/apps/transformer_cluster_component_test.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/controllers/apps/transformer_cluster_component.go b/controllers/apps/transformer_cluster_component.go index 4e8801be8c8..ee8e624427e 100644 --- a/controllers/apps/transformer_cluster_component.go +++ b/controllers/apps/transformer_cluster_component.go @@ -835,10 +835,10 @@ func (h *clusterShardingHandler) protoComps(transCtx *clusterTransformContext, n annotations = transCtx.annotations[spec.Name] } obj, err := buildComponentWrapper(transCtx, spec, labels, annotations, running) - setShardingNameLabel(obj, sharding.Name) if err != nil { return nil, err } + setShardingNameLabel(obj, sharding.Name) objs = append(objs, obj) } return objs, nil diff --git a/controllers/apps/transformer_cluster_component_test.go b/controllers/apps/transformer_cluster_component_test.go index e643f813f74..8bd16328bba 100644 --- a/controllers/apps/transformer_cluster_component_test.go +++ b/controllers/apps/transformer_cluster_component_test.go @@ -525,6 +525,12 @@ var _ = Describe("cluster component transformer test", func() { setters = append(setters, func(comp *appsv1.Component) { comp.Labels[constant.KBAppShardingNameLabelKey] = shardingName }) + setters = append(setters, func(comp *appsv1.Component) { + if comp.Spec.Labels == nil { + comp.Spec.Labels = map[string]string{} + } + comp.Spec.Labels[constant.KBAppShardingNameLabelKey] = shardingName + }) return newCompObj(transCtx, specs[0], setters...) } @@ -1262,7 +1268,6 @@ var _ = Describe("cluster component transformer test", func() { } transCtx.Client = model.NewGraphClient(reader) transCtx.OrigCluster.Generation += 1 // mock cluster spec update - err := transformer.Transform(transCtx, dag) Expect(err).Should(BeNil())