@@ -178,6 +178,16 @@ func TestMoveDeadNodes(t *testing.T) {
178
178
State : StateDead ,
179
179
StateChange : time .Now ().Add (- 10 * time .Second ),
180
180
},
181
+ // This left node should not be moved, as its state changed
182
+ // less than the specified GossipToTheDead time ago
183
+ & nodeState {
184
+ State : StateLeft ,
185
+ StateChange : time .Now ().Add (- 10 * time .Second ),
186
+ },
187
+ & nodeState {
188
+ State : StateLeft ,
189
+ StateChange : time .Now ().Add (- 20 * time .Second ),
190
+ },
181
191
& nodeState {
182
192
State : StateAlive ,
183
193
StateChange : time .Now ().Add (- 20 * time .Second ),
@@ -190,10 +200,14 @@ func TestMoveDeadNodes(t *testing.T) {
190
200
State : StateAlive ,
191
201
StateChange : time .Now ().Add (- 20 * time .Second ),
192
202
},
203
+ & nodeState {
204
+ State : StateLeft ,
205
+ StateChange : time .Now ().Add (- 20 * time .Second ),
206
+ },
193
207
}
194
208
195
209
idx := moveDeadNodes (nodes , (15 * time .Second ))
196
- if idx != 4 {
210
+ if idx != 5 {
197
211
t .Fatalf ("bad index" )
198
212
}
199
213
for i := 0 ; i < idx ; i ++ {
@@ -204,14 +218,19 @@ func TestMoveDeadNodes(t *testing.T) {
204
218
if nodes [i ].State != StateDead {
205
219
t .Fatalf ("Bad state %d" , i )
206
220
}
221
+ case 3 :
222
+ //Recently left node should remain at 3
223
+ if nodes [i ].State != StateLeft {
224
+ t .Fatalf ("Bad State %d" , i )
225
+ }
207
226
default :
208
227
if nodes [i ].State != StateAlive {
209
228
t .Fatalf ("Bad state %d" , i )
210
229
}
211
230
}
212
231
}
213
232
for i := idx ; i < len (nodes ); i ++ {
214
- if nodes [i ].State != StateDead {
233
+ if ! nodes [i ].DeadOrLeft () {
215
234
t .Fatalf ("Bad state %d" , i )
216
235
}
217
236
}
0 commit comments