Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: d-kuro <[email protected]>
  • Loading branch information
d-kuro committed Oct 25, 2023
1 parent 2450ca4 commit 22ca4f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/kubectl-moco/cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func stopClustering(ctx context.Context, name string) error {

orig := cluster.DeepCopy()

if cluster.Annotations == nil {
cluster.Annotations = make(map[string]string)
}
cluster.Annotations[constants.AnnClusteringStopped] = "true"

if equality.Semantic.DeepEqual(orig, cluster) {
Expand Down Expand Up @@ -79,6 +82,9 @@ func stopReconciliation(ctx context.Context, name string) error {

orig := cluster.DeepCopy()

if cluster.Annotations == nil {
cluster.Annotations = make(map[string]string)
}
cluster.Annotations[constants.AnnReconciliationStopped] = "true"

if equality.Semantic.DeepEqual(orig, cluster) {
Expand Down
8 changes: 7 additions & 1 deletion controllers/mysqlcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,9 @@ var _ = Describe("MySQLCluster reconciler", func() {
Expect(err).NotTo(HaveOccurred())

By("setting reconcile stop annotation")
if cluster.Annotations == nil {
cluster.Annotations = map[string]string{}
}
cluster.Annotations[constants.AnnReconciliationStopped] = "true"
err = k8sClient.Update(ctx, cluster)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -1956,6 +1959,9 @@ var _ = Describe("MySQLCluster reconciler", func() {
Expect(err).NotTo(HaveOccurred())

By("setting clustering stop annotation")
if cluster.Annotations == nil {
cluster.Annotations = map[string]string{}
}
cluster.Annotations[constants.AnnClusteringStopped] = "true"
err = k8sClient.Update(ctx, cluster)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -1966,7 +1972,7 @@ var _ = Describe("MySQLCluster reconciler", func() {
if err = k8sClient.Get(ctx, client.ObjectKey{Namespace: "test", Name: "test"}, cluster); err != nil {
return err
}
cond := meta.FindStatusCondition(cluster.Status.Conditions, mocov1beta2.ConditionReconciliationActive)
cond := meta.FindStatusCondition(cluster.Status.Conditions, mocov1beta2.ConditionClusteringActive)
if cond == nil {
return fmt.Errorf("condition does not exists")
}
Expand Down

0 comments on commit 22ca4f7

Please sign in to comment.