Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei committed Dec 2, 2024
1 parent 0b587d2 commit d814efa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions controllers/apps/cluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ var _ = Describe("Cluster Controller", func() {
constant.KBAppShardingNameLabelKey: compName,
}
Eventually(testapps.List(&testCtx, generics.ComponentSignature, ml, client.InNamespace(clusterKey.Namespace))).Should(HaveLen(shards))

By("checking the sharding name label")
compList := &appsv1.ComponentList{}
Expect(k8sClient.List(ctx, compList, ml)).Should(Succeed())
Expect(compList.Items[0].Spec.Labels[constant.KBAppShardingNameLabelKey]).Should(Equal(compName))
}

testClusterComponentScaleIn := func(compName, compDefName string) {
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/factory/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var _ = Describe("builder", func() {
const compDefName = "test-compdef"
const clusterName = "test-cluster"
const mysqlCompName = "mysql"
const dynamicLabel = "dynamic"

allFieldsCompDefObj := func(needCreate bool) *appsv1.ComponentDefinition {
By("By assure an componentDefinition obj")
Expand Down Expand Up @@ -78,6 +79,9 @@ var _ = Describe("builder", func() {
newAllFieldsSynthesizedComponent := func(compDef *appsv1.ComponentDefinition, cluster *appsv1.Cluster) *component.SynthesizedComponent {
By("assign every available fields")
comp, err := component.BuildComponent(cluster, &cluster.Spec.ComponentSpecs[0], nil, nil)
comp.Spec.Labels = map[string]string{
dynamicLabel: dynamicLabel,
}
Expect(err).Should(Succeed())
synthesizeComp, err := component.BuildSynthesizedComponent(testCtx.Ctx, testCtx.Cli, compDef, comp, cluster)
Expect(err).Should(Succeed())
Expand All @@ -101,6 +105,7 @@ var _ = Describe("builder", func() {
compDef, cluster, synthesizedComponent := newClusterObjs(nil)

its, err := BuildInstanceSet(synthesizedComponent, nil)
Expect(its.Labels).Should(HaveKey(dynamicLabel))
Expect(err).Should(BeNil())
Expect(its).ShouldNot(BeNil())

Expand Down

0 comments on commit d814efa

Please sign in to comment.