|
4 | 4 | "testing" |
5 | 5 |
|
6 | 6 | . "github.com/onsi/gomega" |
7 | | - apimeta "k8s.io/apimachinery/pkg/api/meta" |
8 | 7 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
9 | 8 |
|
10 | 9 | seiv1alpha1 "github.com/sei-protocol/sei-k8s-controller/api/v1alpha1" |
@@ -104,94 +103,6 @@ func makeNodes(n int, phase seiv1alpha1.SeiNodePhase) []seiv1alpha1.SeiNode { |
104 | 103 |
|
105 | 104 | // --- NetworkingStatus --- |
106 | 105 |
|
107 | | -func TestReconcileRolloutStatus_InPlace_AllReady(t *testing.T) { |
108 | | - g := NewWithT(t) |
109 | | - group := emptyGroup() |
110 | | - group.Generation = 2 |
111 | | - group.Status.Rollout = &seiv1alpha1.RolloutStatus{ |
112 | | - Strategy: seiv1alpha1.UpdateStrategyInPlace, |
113 | | - TargetHash: "newhash1234", |
114 | | - StartedAt: metav1.Now(), |
115 | | - Nodes: []seiv1alpha1.RolloutNodeStatus{ |
116 | | - {Name: "node-0"}, |
117 | | - {Name: "node-1"}, |
118 | | - }, |
119 | | - } |
120 | | - group.Status.TemplateHash = testOldHash |
121 | | - |
122 | | - nodes := []seiv1alpha1.SeiNode{ |
123 | | - {ObjectMeta: metav1.ObjectMeta{Name: "node-0"}, Status: seiv1alpha1.SeiNodeStatus{Phase: seiv1alpha1.PhaseRunning}}, |
124 | | - {ObjectMeta: metav1.ObjectMeta{Name: "node-1"}, Status: seiv1alpha1.SeiNodeStatus{Phase: seiv1alpha1.PhaseRunning}}, |
125 | | - } |
126 | | - |
127 | | - reconcileRolloutStatus(group, nodes) |
128 | | - |
129 | | - g.Expect(group.Status.Rollout).To(BeNil()) |
130 | | - g.Expect(group.Status.TemplateHash).To(Equal("newhash1234")) |
131 | | - g.Expect(group.Status.ObservedGeneration).To(Equal(int64(2))) |
132 | | - |
133 | | - cond := apimeta.FindStatusCondition(group.Status.Conditions, seiv1alpha1.ConditionRolloutInProgress) |
134 | | - g.Expect(cond).NotTo(BeNil()) |
135 | | - g.Expect(cond.Status).To(Equal(metav1.ConditionFalse)) |
136 | | - g.Expect(cond.Reason).To(Equal("RolloutComplete")) |
137 | | -} |
138 | | - |
139 | | -func TestReconcileRolloutStatus_InPlace_DoesNotClearWhilePlanActive(t *testing.T) { |
140 | | - g := NewWithT(t) |
141 | | - group := emptyGroup() |
142 | | - group.Generation = 2 |
143 | | - group.Status.Rollout = &seiv1alpha1.RolloutStatus{ |
144 | | - Strategy: seiv1alpha1.UpdateStrategyInPlace, |
145 | | - TargetHash: "newhash1234", |
146 | | - StartedAt: metav1.Now(), |
147 | | - Nodes: []seiv1alpha1.RolloutNodeStatus{ |
148 | | - {Name: "node-0"}, |
149 | | - {Name: "node-1"}, |
150 | | - }, |
151 | | - } |
152 | | - group.Status.TemplateHash = testOldHash |
153 | | - setPlanInProgress(group, "Deployment", "deploying") |
154 | | - |
155 | | - nodes := []seiv1alpha1.SeiNode{ |
156 | | - {ObjectMeta: metav1.ObjectMeta{Name: "node-0"}, Status: seiv1alpha1.SeiNodeStatus{Phase: seiv1alpha1.PhaseRunning}}, |
157 | | - {ObjectMeta: metav1.ObjectMeta{Name: "node-1"}, Status: seiv1alpha1.SeiNodeStatus{Phase: seiv1alpha1.PhaseRunning}}, |
158 | | - } |
159 | | - |
160 | | - reconcileRolloutStatus(group, nodes) |
161 | | - |
162 | | - g.Expect(group.Status.Rollout).NotTo(BeNil(), "rollout should not be cleared while PlanInProgress is true") |
163 | | - g.Expect(group.Status.TemplateHash).To(Equal(testOldHash), "templateHash should not change while plan is active") |
164 | | - g.Expect(group.Status.Rollout.Nodes[0].Ready).To(BeTrue()) |
165 | | - g.Expect(group.Status.Rollout.Nodes[1].Ready).To(BeTrue()) |
166 | | -} |
167 | | - |
168 | | -func TestReconcileRolloutStatus_InPlace_Partial(t *testing.T) { |
169 | | - g := NewWithT(t) |
170 | | - group := emptyGroup() |
171 | | - group.Status.Rollout = &seiv1alpha1.RolloutStatus{ |
172 | | - Strategy: seiv1alpha1.UpdateStrategyInPlace, |
173 | | - TargetHash: "newhash1234", |
174 | | - StartedAt: metav1.Now(), |
175 | | - Nodes: []seiv1alpha1.RolloutNodeStatus{ |
176 | | - {Name: "node-0"}, |
177 | | - {Name: "node-1"}, |
178 | | - }, |
179 | | - } |
180 | | - group.Status.TemplateHash = testOldHash |
181 | | - |
182 | | - nodes := []seiv1alpha1.SeiNode{ |
183 | | - {ObjectMeta: metav1.ObjectMeta{Name: "node-0"}, Status: seiv1alpha1.SeiNodeStatus{Phase: seiv1alpha1.PhaseRunning}}, |
184 | | - {ObjectMeta: metav1.ObjectMeta{Name: "node-1"}, Status: seiv1alpha1.SeiNodeStatus{Phase: seiv1alpha1.PhaseInitializing}}, |
185 | | - } |
186 | | - |
187 | | - reconcileRolloutStatus(group, nodes) |
188 | | - |
189 | | - g.Expect(group.Status.Rollout).NotTo(BeNil()) |
190 | | - g.Expect(group.Status.TemplateHash).To(Equal(testOldHash)) |
191 | | - g.Expect(group.Status.Rollout.Nodes[0].Ready).To(BeTrue()) |
192 | | - g.Expect(group.Status.Rollout.Nodes[1].Ready).To(BeFalse()) |
193 | | -} |
194 | | - |
195 | 106 | func TestComputeGroupPhase_RolloutInProgress(t *testing.T) { |
196 | 107 | g := NewWithT(t) |
197 | 108 | group := emptyGroup() |
|
0 commit comments