diff --git a/apis/apps/v2alpha1/emqx_conversion.go b/apis/apps/v2alpha1/emqx_conversion.go index c3f6c718..e81b1a57 100644 --- a/apis/apps/v2alpha1/emqx_conversion.go +++ b/apis/apps/v2alpha1/emqx_conversion.go @@ -38,6 +38,9 @@ func (src *EMQX) ConvertTo(dstRaw conversion.Hub) error { dst.SetGroupVersionKind(v2beta1.GroupVersion.WithKind("EMQX")) dst.Spec.ClusterDomain = "cluster.local" dst.Spec.Config.Data = src.Spec.BootstrapConfig + if src.Spec.ReplicantTemplate.Spec.Replicas == nil { + dst.Spec.ReplicantTemplate = nil + } // +kubebuilder:docs-gen:collapse=rote conversion return nil diff --git a/apis/apps/v2beta1/status.go b/apis/apps/v2beta1/status.go index cf8528dc..25af00ac 100644 --- a/apis/apps/v2beta1/status.go +++ b/apis/apps/v2beta1/status.go @@ -28,11 +28,11 @@ type EMQXStatus struct { // Represents the latest available observations of a EMQX Custom Resource current state. Conditions []metav1.Condition `json:"conditions,omitempty"` - CoreNodes []EMQXNode `json:"coreNodes,omitempty"` - CoreNodesStatus EMQXNodesStatus `json:"coreNodesStatus,omitempty"` + CoreNodes []EMQXNode `json:"coreNodes,omitempty"` + CoreNodesStatus *EMQXNodesStatus `json:"coreNodesStatus,omitempty"` - ReplicantNodes []EMQXNode `json:"replicantNodes,omitempty"` - ReplicantNodesStatus EMQXNodesStatus `json:"replicantNodesStatus,omitempty"` + ReplicantNodes []EMQXNode `json:"replicantNodes,omitempty"` + ReplicantNodesStatus *EMQXNodesStatus `json:"replicantNodesStatus,omitempty"` NodeEvacuationsStatus []NodeEvacuationStatus `json:"nodEvacuationsStatus,omitempty"` } diff --git a/apis/apps/v2beta1/zz_generated.deepcopy.go b/apis/apps/v2beta1/zz_generated.deepcopy.go index 77fed49a..2bfee1a0 100644 --- a/apis/apps/v2beta1/zz_generated.deepcopy.go +++ b/apis/apps/v2beta1/zz_generated.deepcopy.go @@ -412,13 +412,21 @@ func (in *EMQXStatus) DeepCopyInto(out *EMQXStatus) { *out = make([]EMQXNode, len(*in)) copy(*out, *in) } - in.CoreNodesStatus.DeepCopyInto(&out.CoreNodesStatus) + if in.CoreNodesStatus != nil { + in, out := &in.CoreNodesStatus, &out.CoreNodesStatus + *out = new(EMQXNodesStatus) + (*in).DeepCopyInto(*out) + } if in.ReplicantNodes != nil { in, out := &in.ReplicantNodes, &out.ReplicantNodes *out = make([]EMQXNode, len(*in)) copy(*out, *in) } - in.ReplicantNodesStatus.DeepCopyInto(&out.ReplicantNodesStatus) + if in.ReplicantNodesStatus != nil { + in, out := &in.ReplicantNodesStatus, &out.ReplicantNodesStatus + *out = new(EMQXNodesStatus) + (*in).DeepCopyInto(*out) + } if in.NodeEvacuationsStatus != nil { in, out := &in.NodeEvacuationsStatus, &out.NodeEvacuationsStatus *out = make([]NodeEvacuationStatus, len(*in)) diff --git a/config/samples/emqx/v2alpha1/emqx-full.yaml b/config/samples/emqx/v2alpha1/emqx-full.yaml index 88d0812e..81189d36 100644 --- a/config/samples/emqx/v2alpha1/emqx-full.yaml +++ b/config/samples/emqx/v2alpha1/emqx-full.yaml @@ -3,7 +3,7 @@ kind: EMQX metadata: name: emqx spec: - image: "emqx:5" + image: "emqx/emqx-enterprise:latest" imagePullPolicy: IfNotPresent # imagePullSecrets: # - name: fake-secrets diff --git a/config/samples/emqx/v2beta1/emqx-full.yaml b/config/samples/emqx/v2beta1/emqx-full.yaml index eba9b272..a65c85d8 100644 --- a/config/samples/emqx/v2beta1/emqx-full.yaml +++ b/config/samples/emqx/v2beta1/emqx-full.yaml @@ -6,7 +6,7 @@ metadata: apps.emqx.io/instance: emqx apps.emqx.io/managed-by: emqx-operator spec: - image: "emqx:5" + image: "emqx/emqx-enterprise:latest" imagePullPolicy: Always revisionHistoryLimit: 3 config: diff --git a/controllers/apps/v2beta1/add_emqx_core_suite_test.go b/controllers/apps/v2beta1/add_emqx_core_suite_test.go index 47f493b6..32936660 100644 --- a/controllers/apps/v2beta1/add_emqx_core_suite_test.go +++ b/controllers/apps/v2beta1/add_emqx_core_suite_test.go @@ -46,6 +46,7 @@ var _ = Describe("Check add core controller", Ordered, Label("core"), func() { LastTransitionTime: metav1.Time{Time: time.Now().AddDate(0, 0, -1)}, }, } + instance.Status.CoreNodesStatus = &appsv2beta1.EMQXNodesStatus{} }) It("create namespace", func() { diff --git a/controllers/apps/v2beta1/add_emqx_core_test.go b/controllers/apps/v2beta1/add_emqx_core_test.go index 82d42913..46b9c904 100644 --- a/controllers/apps/v2beta1/add_emqx_core_test.go +++ b/controllers/apps/v2beta1/add_emqx_core_test.go @@ -37,7 +37,7 @@ func TestGetNewStatefulSet(t *testing.T) { }, } instance.Spec.CoreTemplate.Spec.Replicas = ptr.To(int32(3)) - instance.Status.CoreNodesStatus = appsv2beta1.EMQXNodesStatus{ + instance.Status.CoreNodesStatus = &appsv2beta1.EMQXNodesStatus{ CollisionCount: ptr.To(int32(0)), } diff --git a/controllers/apps/v2beta1/add_emqx_repl.go b/controllers/apps/v2beta1/add_emqx_repl.go index 8b38dc49..589d2813 100644 --- a/controllers/apps/v2beta1/add_emqx_repl.go +++ b/controllers/apps/v2beta1/add_emqx_repl.go @@ -124,7 +124,10 @@ func getNewReplicaSet(instance *appsv2beta1.EMQX) *appsv1.ReplicaSet { svcPorts, _ := appsv2beta1.GetDashboardServicePort(instance.Spec.Config.Data) preRs := generateReplicaSet(instance) - podTemplateSpecHash := computeHash(preRs.Spec.Template.DeepCopy(), instance.Status.ReplicantNodesStatus.CollisionCount) + podTemplateSpecHash := computeHash(preRs.Spec.Template.DeepCopy(), nil) + if instance.Status.ReplicantNodesStatus != nil { + podTemplateSpecHash = computeHash(preRs.Spec.Template.DeepCopy(), instance.Status.ReplicantNodesStatus.CollisionCount) + } preRs.Name = preRs.Name + "-" + podTemplateSpecHash preRs.Labels = appsv2beta1.CloneAndAddLabel(preRs.Labels, appsv2beta1.LabelsPodTemplateHashKey, podTemplateSpecHash) preRs.Spec.Selector = appsv2beta1.CloneSelectorAndAddLabel(preRs.Spec.Selector, appsv2beta1.LabelsPodTemplateHashKey, podTemplateSpecHash) diff --git a/controllers/apps/v2beta1/add_emqx_repl_suite_test.go b/controllers/apps/v2beta1/add_emqx_repl_suite_test.go index 63eb3b08..05b3d27d 100644 --- a/controllers/apps/v2beta1/add_emqx_repl_suite_test.go +++ b/controllers/apps/v2beta1/add_emqx_repl_suite_test.go @@ -39,7 +39,7 @@ var _ = Describe("Check add repl controller", Ordered, Label("repl"), func() { }, } instance.Status = appsv2beta1.EMQXStatus{ - ReplicantNodesStatus: appsv2beta1.EMQXNodesStatus{ + ReplicantNodesStatus: &appsv2beta1.EMQXNodesStatus{ Replicas: 3, }, Conditions: []metav1.Condition{ diff --git a/controllers/apps/v2beta1/add_emqx_repl_test.go b/controllers/apps/v2beta1/add_emqx_repl_test.go index 2752f674..1e3ce886 100644 --- a/controllers/apps/v2beta1/add_emqx_repl_test.go +++ b/controllers/apps/v2beta1/add_emqx_repl_test.go @@ -40,7 +40,7 @@ func TestGetNewReplicaSet(t *testing.T) { Replicas: ptr.To(int32(3)), }, } - instance.Status.ReplicantNodesStatus = appsv2beta1.EMQXNodesStatus{ + instance.Status.ReplicantNodesStatus = &appsv2beta1.EMQXNodesStatus{ CollisionCount: ptr.To(int32(0)), } diff --git a/controllers/apps/v2beta1/sync_pods_suite_test.go b/controllers/apps/v2beta1/sync_pods_suite_test.go index 32864d33..0843661a 100644 --- a/controllers/apps/v2beta1/sync_pods_suite_test.go +++ b/controllers/apps/v2beta1/sync_pods_suite_test.go @@ -64,7 +64,7 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { LastTransitionTime: metav1.Time{Time: time.Now().AddDate(0, 0, -1)}, }, }, - CoreNodesStatus: appsv2beta1.EMQXNodesStatus{ + CoreNodesStatus: &appsv2beta1.EMQXNodesStatus{ UpdateRevision: "update", UpdateReplicas: 1, CurrentRevision: "current", @@ -72,7 +72,7 @@ var _ = Describe("Check sync pods controller", Ordered, Label("node"), func() { ReadyReplicas: 2, Replicas: 1, }, - ReplicantNodesStatus: appsv2beta1.EMQXNodesStatus{ + ReplicantNodesStatus: &appsv2beta1.EMQXNodesStatus{ UpdateRevision: "update", UpdateReplicas: 1, CurrentRevision: "current", @@ -334,7 +334,7 @@ var _ = Describe("check can be scale down", func() { Replicas: ptr.To(int32(3)), }, } - instance.Status.ReplicantNodesStatus = appsv2beta1.EMQXNodesStatus{ + instance.Status.ReplicantNodesStatus = &appsv2beta1.EMQXNodesStatus{ UpdateRevision: "update", CurrentRevision: "current", } diff --git a/controllers/apps/v2beta1/update_emqx_status.go b/controllers/apps/v2beta1/update_emqx_status.go index 3bff86a9..2fc52c61 100644 --- a/controllers/apps/v2beta1/update_emqx_status.go +++ b/controllers/apps/v2beta1/update_emqx_status.go @@ -21,16 +21,28 @@ type updateStatus struct { } func (u *updateStatus) reconcile(ctx context.Context, logger logr.Logger, instance *appsv2beta1.EMQX, r innerReq.RequesterInterface) subResult { - instance.Status.CoreNodesStatus.Replicas = *instance.Spec.CoreTemplate.Spec.Replicas - if instance.Spec.ReplicantTemplate != nil { - instance.Status.ReplicantNodesStatus.Replicas = *instance.Spec.ReplicantTemplate.Spec.Replicas + if instance.Status.CoreNodesStatus == nil { + instance.Status.CoreNodesStatus = &appsv2beta1.EMQXNodesStatus{} + if err := u.Client.Status().Update(ctx, instance); err != nil { + return subResult{err: emperror.Wrap(err, "failed to update status")} + } } - + instance.Status.CoreNodesStatus.Replicas = *instance.Spec.CoreTemplate.Spec.Replicas if instance.Status.CoreNodesStatus.UpdateRevision != "" && instance.Status.CoreNodesStatus.CurrentRevision == "" { instance.Status.CoreNodesStatus.CurrentRevision = instance.Status.CoreNodesStatus.UpdateRevision } - if instance.Status.ReplicantNodesStatus.UpdateRevision != "" && instance.Status.ReplicantNodesStatus.CurrentRevision == "" { - instance.Status.ReplicantNodesStatus.CurrentRevision = instance.Status.ReplicantNodesStatus.UpdateRevision + + if instance.Spec.ReplicantTemplate != nil { + if instance.Status.ReplicantNodesStatus == nil { + instance.Status.ReplicantNodesStatus = &appsv2beta1.EMQXNodesStatus{} + if err := u.Client.Status().Update(ctx, instance); err != nil { + return subResult{err: emperror.Wrap(err, "failed to update status")} + } + } + instance.Status.ReplicantNodesStatus.Replicas = *instance.Spec.ReplicantTemplate.Spec.Replicas + if instance.Status.ReplicantNodesStatus.UpdateRevision != "" && instance.Status.ReplicantNodesStatus.CurrentRevision == "" { + instance.Status.ReplicantNodesStatus.CurrentRevision = instance.Status.ReplicantNodesStatus.UpdateRevision + } } updateSts, currentSts, oldStsList := getStateFulSetList(ctx, u.Client, instance) @@ -102,18 +114,20 @@ func (u *updateStatus) reconcile(ctx context.Context, logger logr.Logger, instan } instance.Status.ReplicantNodes = replNodes - instance.Status.ReplicantNodesStatus.ReadyReplicas = 0 - instance.Status.ReplicantNodesStatus.CurrentReplicas = 0 - instance.Status.ReplicantNodesStatus.UpdateReplicas = 0 - for _, node := range replNodes { - if node.NodeStatus == "running" { - instance.Status.ReplicantNodesStatus.ReadyReplicas++ - } - if currentRs != nil && node.ControllerUID == currentRs.UID { - instance.Status.ReplicantNodesStatus.CurrentReplicas++ - } - if updateRs != nil && node.ControllerUID == updateRs.UID { - instance.Status.ReplicantNodesStatus.UpdateReplicas++ + if instance.Status.ReplicantNodesStatus != nil { + instance.Status.ReplicantNodesStatus.ReadyReplicas = 0 + instance.Status.ReplicantNodesStatus.CurrentReplicas = 0 + instance.Status.ReplicantNodesStatus.UpdateReplicas = 0 + for _, node := range replNodes { + if node.NodeStatus == "running" { + instance.Status.ReplicantNodesStatus.ReadyReplicas++ + } + if currentRs != nil && node.ControllerUID == currentRs.UID { + instance.Status.ReplicantNodesStatus.CurrentReplicas++ + } + if updateRs != nil && node.ControllerUID == updateRs.UID { + instance.Status.ReplicantNodesStatus.UpdateReplicas++ + } } } diff --git a/controllers/apps/v2beta1/util.go b/controllers/apps/v2beta1/util.go index 0fee0ef3..f7fe78a5 100644 --- a/controllers/apps/v2beta1/util.go +++ b/controllers/apps/v2beta1/util.go @@ -69,13 +69,13 @@ func getStateFulSetList(ctx context.Context, k8sClient client.Client, instance * ) for _, sts := range list.Items { if hash, ok := sts.Labels[appsv2beta1.LabelsPodTemplateHashKey]; ok { - if hash == instance.Status.CoreNodesStatus.UpdateRevision { + if instance.Status.CoreNodesStatus != nil && hash == instance.Status.CoreNodesStatus.UpdateRevision { updateSts = sts.DeepCopy() } - if hash == instance.Status.CoreNodesStatus.CurrentRevision { + if instance.Status.CoreNodesStatus != nil && hash == instance.Status.CoreNodesStatus.CurrentRevision { currentSts = sts.DeepCopy() } - if hash != instance.Status.CoreNodesStatus.UpdateRevision && hash != instance.Status.CoreNodesStatus.CurrentRevision { + if instance.Status.CoreNodesStatus == nil || (hash != instance.Status.CoreNodesStatus.UpdateRevision && hash != instance.Status.CoreNodesStatus.CurrentRevision) { oldStsList = append(oldStsList, sts.DeepCopy()) } } @@ -96,13 +96,13 @@ func getReplicaSetList(ctx context.Context, k8sClient client.Client, instance *a for _, rs := range list.Items { if hash, ok := rs.Labels[appsv2beta1.LabelsPodTemplateHashKey]; ok { - if hash == instance.Status.ReplicantNodesStatus.UpdateRevision { + if instance.Status.ReplicantNodesStatus != nil && hash == instance.Status.ReplicantNodesStatus.UpdateRevision { updateRs = rs.DeepCopy() } - if hash == instance.Status.ReplicantNodesStatus.CurrentRevision { + if instance.Status.ReplicantNodesStatus != nil && hash == instance.Status.ReplicantNodesStatus.CurrentRevision { currentRs = rs.DeepCopy() } - if hash != instance.Status.ReplicantNodesStatus.UpdateRevision && hash != instance.Status.ReplicantNodesStatus.CurrentRevision { + if instance.Status.ReplicantNodesStatus == nil || (hash != instance.Status.ReplicantNodesStatus.UpdateRevision && hash != instance.Status.ReplicantNodesStatus.CurrentRevision) { oldRsList = append(oldRsList, rs.DeepCopy()) } } diff --git a/e2e/v2beta1/e2e_rebalance_test.go b/e2e/v2beta1/e2e_rebalance_test.go index 32ab71e2..4edc8786 100644 --- a/e2e/v2beta1/e2e_rebalance_test.go +++ b/e2e/v2beta1/e2e_rebalance_test.go @@ -45,7 +45,7 @@ var _ = Describe("EMQX 5 Rebalance Test", Label("rebalance"), func() { var r *appsv2beta1.Rebalance BeforeEach(func() { instance = genEMQX().DeepCopy() - instance.Spec.Image = "emqx/emqx-enterprise:5.1" + instance.Spec.Image = "emqx/emqx-enterprise:latest" }) Context("EMQX is not found", func() { diff --git a/e2e/v2beta1/e2e_test.go b/e2e/v2beta1/e2e_test.go index 661b0b61..bf2dd017 100644 --- a/e2e/v2beta1/e2e_test.go +++ b/e2e/v2beta1/e2e_test.go @@ -68,7 +68,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.CoreNodes }, HaveLen(int(*instance.Spec.CoreTemplate.Spec.Replicas))), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.CoreNodesStatus + return *instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -80,16 +80,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.ReplicantNodes }, BeNil()), - WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus - }, And( - HaveField("Replicas", Equal(int32(0))), - HaveField("ReadyReplicas", Equal(int32(0))), - HaveField("CurrentRevision", Equal("")), - HaveField("CurrentReplicas", Equal(int32(0))), - HaveField("UpdateRevision", Equal("")), - HaveField("UpdateReplicas", Equal(int32(0))), - )), + }, BeNil()), ), ) @@ -126,7 +119,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.CoreNodes }, HaveLen(int(*instance.Spec.CoreTemplate.Spec.Replicas))), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.CoreNodesStatus + return *instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -138,16 +131,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.ReplicantNodes }, BeNil()), - WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus - }, And( - HaveField("Replicas", Equal(int32(0))), - HaveField("ReadyReplicas", Equal(int32(0))), - HaveField("CurrentRevision", Equal("")), - HaveField("CurrentReplicas", Equal(int32(0))), - HaveField("UpdateRevision", Equal("")), - HaveField("UpdateReplicas", Equal(int32(0))), - )), + }, BeNil()), ), ) @@ -184,7 +170,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.CoreNodes }, HaveLen(int(*instance.Spec.CoreTemplate.Spec.Replicas))), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.CoreNodesStatus + return *instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -196,16 +182,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { WithTransform(func(instance *appsv2beta1.EMQX) []appsv2beta1.EMQXNode { return instance.Status.ReplicantNodes }, BeNil()), - WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus - }, And( - HaveField("Replicas", Equal(int32(0))), - HaveField("ReadyReplicas", Equal(int32(0))), - HaveField("CurrentRevision", Equal("")), - HaveField("CurrentReplicas", Equal(int32(0))), - HaveField("UpdateRevision", Equal("")), - HaveField("UpdateReplicas", Equal(int32(0))), - )), + }, BeNil()), ), ) @@ -239,7 +218,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.CoreNodesStatus + return *instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -248,16 +227,9 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { HaveField("UpdateRevision", Not(Equal(storage.Status.CoreNodesStatus.CurrentRevision))), HaveField("UpdateReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), )), - WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { + WithTransform(func(instance *appsv2beta1.EMQX) *appsv2beta1.EMQXNodesStatus { return instance.Status.ReplicantNodesStatus - }, And( - HaveField("Replicas", Equal(int32(0))), - HaveField("ReadyReplicas", Equal(int32(0))), - HaveField("CurrentRevision", Equal("")), - HaveField("CurrentReplicas", Equal(int32(0))), - HaveField("UpdateRevision", Equal("")), - HaveField("UpdateReplicas", Equal(int32(0))), - )), + }, BeNil()), ), ) @@ -358,7 +330,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.CoreNodesStatus + return *instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -368,7 +340,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { HaveField("UpdateReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), )), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.ReplicantNodesStatus + return *instance.Status.ReplicantNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.ReplicantTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.ReplicantTemplate.Spec.Replicas))), @@ -413,7 +385,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.CoreNodes }, HaveLen(int(*instance.Spec.CoreTemplate.Spec.Replicas))), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.CoreNodesStatus + return *instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -426,7 +398,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.ReplicantNodes }, HaveLen(int(*instance.Spec.ReplicantTemplate.Spec.Replicas))), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.ReplicantNodesStatus + return *instance.Status.ReplicantNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.ReplicantTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.ReplicantTemplate.Spec.Replicas))), @@ -471,7 +443,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.CoreNodes }, HaveLen(int(*instance.Spec.CoreTemplate.Spec.Replicas))), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.CoreNodesStatus + return *instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -484,7 +456,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.ReplicantNodes }, HaveLen(int(*instance.Spec.ReplicantTemplate.Spec.Replicas))), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.ReplicantNodesStatus + return *instance.Status.ReplicantNodesStatus }, And( HaveField("Replicas", Equal(int32(0))), HaveField("ReadyReplicas", Equal(int32(0))), @@ -526,7 +498,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.CoreNodesStatus + return *instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -536,7 +508,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { HaveField("UpdateReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), )), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.ReplicantNodesStatus + return *instance.Status.ReplicantNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.ReplicantTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.ReplicantTemplate.Spec.Replicas))), @@ -579,7 +551,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { return instance.Status.IsConditionTrue(appsv2beta1.Ready) }, BeTrue()), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.CoreNodesStatus + return *instance.Status.CoreNodesStatus }, And( HaveField("Replicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), HaveField("ReadyReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), @@ -589,7 +561,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() { HaveField("UpdateReplicas", Equal(int32(*instance.Spec.CoreTemplate.Spec.Replicas))), )), WithTransform(func(instance *appsv2beta1.EMQX) appsv2beta1.EMQXNodesStatus { - return instance.Status.ReplicantNodesStatus + return *instance.Status.ReplicantNodesStatus }, And( HaveField("Replicas", Equal(int32(0))), HaveField("ReadyReplicas", Equal(int32(0))), diff --git a/e2e/v2beta1/suite_test.go b/e2e/v2beta1/suite_test.go index a13b16ac..b02da1d2 100644 --- a/e2e/v2beta1/suite_test.go +++ b/e2e/v2beta1/suite_test.go @@ -149,7 +149,7 @@ func genEMQX() *appsv2beta1.EMQX { Namespace: "e2e-test-v2beta1" + "-" + rand.String(5), }, Spec: appsv2beta1.EMQXSpec{ - Image: "emqx:latest", + Image: "emqx/emqx-enterprise:5.8", ImagePullPolicy: corev1.PullAlways, ClusterDomain: "cluster.local", Config: appsv2beta1.Config{