@@ -25,12 +25,12 @@ func TestCheckAutomationStatusIsGoal(t *testing.T) {
25
25
Processes : []ProcessStatus {
26
26
{
27
27
Name : "a" ,
28
- Plan : []string {"FCV" },
28
+ Plan : []string {},
29
29
LastGoalVersionAchieved : 1 ,
30
30
},
31
31
{
32
32
Name : "b" ,
33
- Plan : []string {"FCV" },
33
+ Plan : []string {},
34
34
LastGoalVersionAchieved : 1 ,
35
35
},
36
36
},
@@ -48,12 +48,12 @@ func TestCheckAutomationStatusIsGoal(t *testing.T) {
48
48
Processes : []ProcessStatus {
49
49
{
50
50
Name : "a" ,
51
- Plan : []string {"FCV" },
51
+ Plan : []string {},
52
52
LastGoalVersionAchieved : 0 ,
53
53
},
54
54
{
55
55
Name : "b" ,
56
- Plan : []string {"FCV" },
56
+ Plan : []string {},
57
57
LastGoalVersionAchieved : 1 ,
58
58
},
59
59
},
@@ -70,12 +70,12 @@ func TestCheckAutomationStatusIsGoal(t *testing.T) {
70
70
Processes : []ProcessStatus {
71
71
{
72
72
Name : "a" ,
73
- Plan : []string {"FCV" , " something-else" },
73
+ Plan : []string {"something-else" },
74
74
LastGoalVersionAchieved : 0 ,
75
75
},
76
76
{
77
77
Name : "b" ,
78
- Plan : []string {"FCV" , automationAgentKubeUpgradePlan },
78
+ Plan : []string {automationAgentKubeUpgradePlan },
79
79
LastGoalVersionAchieved : 1 ,
80
80
},
81
81
},
@@ -93,12 +93,12 @@ func TestCheckAutomationStatusIsGoal(t *testing.T) {
93
93
Processes : []ProcessStatus {
94
94
{
95
95
Name : "a" ,
96
- Plan : []string {"X" , "Y" },
96
+ Plan : []string {},
97
97
LastGoalVersionAchieved : 1 ,
98
98
},
99
99
{
100
100
Name : "b" ,
101
- Plan : []string {"Y" , "Z" },
101
+ Plan : []string {},
102
102
LastGoalVersionAchieved : 1 ,
103
103
},
104
104
},
@@ -119,3 +119,151 @@ func TestCheckAutomationStatusIsGoal(t *testing.T) {
119
119
})
120
120
}
121
121
}
122
+
123
+ func TestCheckAutomationStatusIsGoal_AuthenticationTransitions (t * testing.T ) {
124
+ logger := zap .NewNop ().Sugar ()
125
+
126
+ tests := []struct {
127
+ name string
128
+ automationStatus * AutomationStatus
129
+ relevantProcesses []string
130
+ expectedReady bool
131
+ expectedMessage string
132
+ }{
133
+ {
134
+ name : "should wait for UpdateAuth move to complete" ,
135
+ automationStatus : & AutomationStatus {
136
+ GoalVersion : 5 ,
137
+ Processes : []ProcessStatus {
138
+ {
139
+ Name : "rs0_0" ,
140
+ LastGoalVersionAchieved : 5 ,
141
+ Plan : []string {"UpdateAuth" },
142
+ },
143
+ },
144
+ },
145
+ relevantProcesses : []string {"rs0_0" },
146
+ expectedReady : false ,
147
+ expectedMessage : "authentication transitions in progress for 1 processes" ,
148
+ },
149
+ {
150
+ name : "should wait for InitiateReplSet move to complete" ,
151
+ automationStatus : & AutomationStatus {
152
+ GoalVersion : 3 ,
153
+ Processes : []ProcessStatus {
154
+ {
155
+ Name : "rs0_0" ,
156
+ LastGoalVersionAchieved : 3 ,
157
+ Plan : []string {"InitiateReplSet" },
158
+ },
159
+ },
160
+ },
161
+ relevantProcesses : []string {"rs0_0" },
162
+ expectedReady : false ,
163
+ expectedMessage : "authentication transitions in progress for 1 processes" ,
164
+ },
165
+ {
166
+ name : "should be ready when authentication transitions are complete" ,
167
+ automationStatus : & AutomationStatus {
168
+ GoalVersion : 5 ,
169
+ Processes : []ProcessStatus {
170
+ {
171
+ Name : "rs0_0" ,
172
+ LastGoalVersionAchieved : 5 ,
173
+ Plan : []string {}, // Empty plan means all moves completed
174
+ },
175
+ },
176
+ },
177
+ relevantProcesses : []string {"rs0_0" },
178
+ expectedReady : true ,
179
+ expectedMessage : "processes that reached goal state: [rs0_0]" ,
180
+ },
181
+ {
182
+ name : "should wait for multiple processes with auth transitions" ,
183
+ automationStatus : & AutomationStatus {
184
+ GoalVersion : 7 ,
185
+ Processes : []ProcessStatus {
186
+ {
187
+ Name : "rs0_0" ,
188
+ LastGoalVersionAchieved : 7 ,
189
+ Plan : []string {}, // This process completed
190
+ },
191
+ {
192
+ Name : "rs0_1" ,
193
+ LastGoalVersionAchieved : 7 ,
194
+ Plan : []string {"RestartMongod" }, // Auth-related move in progress
195
+ },
196
+ },
197
+ },
198
+ relevantProcesses : []string {"rs0_0" , "rs0_1" },
199
+ expectedReady : false ,
200
+ expectedMessage : "authentication transitions in progress for 1 processes" ,
201
+ },
202
+ {
203
+ name : "should ignore non-authentication moves in progress" ,
204
+ automationStatus : & AutomationStatus {
205
+ GoalVersion : 4 ,
206
+ Processes : []ProcessStatus {
207
+ {
208
+ Name : "rs0_0" ,
209
+ LastGoalVersionAchieved : 4 ,
210
+ Plan : []string {"SomeOtherMove" }, // Non-auth move
211
+ },
212
+ },
213
+ },
214
+ relevantProcesses : []string {"rs0_0" },
215
+ expectedReady : true ,
216
+ expectedMessage : "processes that reached goal state: [rs0_0]" ,
217
+ },
218
+ }
219
+
220
+ for _ , tt := range tests {
221
+ t .Run (tt .name , func (t * testing.T ) {
222
+ ready , message := checkAutomationStatusIsGoal (
223
+ tt .automationStatus ,
224
+ tt .relevantProcesses ,
225
+ logger ,
226
+ )
227
+
228
+ assert .Equal (t , tt .expectedReady , ready , "Ready state should match expected" )
229
+ assert .Contains (t , message , tt .expectedMessage , "Message should contain expected text" )
230
+
231
+ if tt .expectedReady {
232
+ t .Logf ("✅ Process correctly marked as ready: %s" , message )
233
+ } else {
234
+ t .Logf ("⏳ Process correctly waiting for auth transition: %s" , message )
235
+ }
236
+ })
237
+ }
238
+ }
239
+
240
+ func TestIsAuthenticationTransitionMove (t * testing.T ) {
241
+ authMoves := []string {
242
+ "RestartMongod" ,
243
+ "UpdateAuth" ,
244
+ "UpdateConfig" ,
245
+ "WaitForHealthy" ,
246
+ "InitiateReplSet" ,
247
+ }
248
+
249
+ nonAuthMoves := []string {
250
+ "SomeOtherMove" ,
251
+ "CreateIndex" ,
252
+ "DropCollection" ,
253
+ "BackupDatabase" ,
254
+ }
255
+
256
+ for _ , move := range authMoves {
257
+ t .Run ("auth_move_" + move , func (t * testing.T ) {
258
+ assert .True (t , isAuthenticationTransitionMove (move ),
259
+ "Move %s should be recognized as authentication transition" , move )
260
+ })
261
+ }
262
+
263
+ for _ , move := range nonAuthMoves {
264
+ t .Run ("non_auth_move_" + move , func (t * testing.T ) {
265
+ assert .False (t , isAuthenticationTransitionMove (move ),
266
+ "Move %s should not be recognized as authentication transition" , move )
267
+ })
268
+ }
269
+ }
0 commit comments