Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Sep 3, 2024
1 parent df0410b commit ca7c214
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 30 deletions.
8 changes: 4 additions & 4 deletions apis/apps/v2beta1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
12 changes: 10 additions & 2 deletions apis/apps/v2beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion controllers/apps/v2beta1/add_emqx_core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/v2beta1/add_emqx_repl_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/v2beta1/add_emqx_repl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}

Expand Down
6 changes: 3 additions & 3 deletions controllers/apps/v2beta1/sync_pods_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ 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",
CurrentReplicas: 1,
ReadyReplicas: 2,
Replicas: 1,
},
ReplicantNodesStatus: appsv2beta1.EMQXNodesStatus{
ReplicantNodesStatus: &appsv2beta1.EMQXNodesStatus{
UpdateRevision: "update",
UpdateReplicas: 1,
CurrentRevision: "current",
Expand Down Expand Up @@ -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",
}
Expand Down
36 changes: 18 additions & 18 deletions e2e/v2beta1/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
Expand All @@ -81,7 +81,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() {
return instance.Status.ReplicantNodes
}, BeNil()),
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))),
Expand Down Expand Up @@ -126,7 +126,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))),
Expand All @@ -139,7 +139,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() {
return instance.Status.ReplicantNodes
}, BeNil()),
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))),
Expand Down Expand Up @@ -184,7 +184,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))),
Expand All @@ -197,7 +197,7 @@ var _ = Describe("E2E Test", Label("base"), Ordered, func() {
return instance.Status.ReplicantNodes
}, BeNil()),
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))),
Expand Down Expand Up @@ -239,7 +239,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))),
Expand All @@ -249,7 +249,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))),
Expand Down Expand Up @@ -358,7 +358,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))),
Expand All @@ -368,7 +368,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))),
Expand Down Expand Up @@ -413,7 +413,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))),
Expand All @@ -426,7 +426,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))),
Expand Down Expand Up @@ -471,7 +471,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))),
Expand All @@ -484,7 +484,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))),
Expand Down Expand Up @@ -526,7 +526,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))),
Expand All @@ -536,7 +536,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))),
Expand Down Expand Up @@ -579,7 +579,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))),
Expand All @@ -589,7 +589,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))),
Expand Down

0 comments on commit ca7c214

Please sign in to comment.