@@ -265,6 +265,84 @@ def test_winner_crash(self):
265
265
self .client .bgrun ()
266
266
time .sleep (3 )
267
267
268
+ def test_consequent_shutdown (self ):
269
+ print ('### test_consequent_shutdown ###' )
270
+ docker_api = docker .from_env ()
271
+
272
+
273
+ print ('#### down on(winner) || on' )
274
+ print ('##########################' )
275
+ aggs_failure , aggs = self .performFailure (StopNode ('node1' ))
276
+
277
+ self .assertNoCommits (aggs_failure [:1 ])
278
+ self .assertCommits (aggs_failure [1 :])
279
+ self .assertIsolation (aggs_failure )
280
+
281
+ self .assertNoCommits (aggs [:1 ])
282
+ self .assertCommits (aggs [1 :])
283
+ self .assertIsolation (aggs )
284
+
285
+
286
+ print ('#### down down(winner) || on' )
287
+ print ('############################' )
288
+ aggs_failure , aggs = self .performFailure (StopNode ('node2' ))
289
+
290
+ self .assertNoCommits (aggs_failure )
291
+ self .assertIsolation (aggs_failure )
292
+
293
+ self .assertNoCommits (aggs )
294
+ self .assertIsolation (aggs )
295
+
296
+
297
+ print ('#### down down(winner) || down' )
298
+ print ('##############################' )
299
+ docker_api .containers .get ('referee' ).stop ()
300
+ time .sleep (3 )
301
+
302
+
303
+ print ('#### up down(winner) || down' )
304
+ print ('############################' )
305
+ docker_api .containers .get ('node1' ).start ()
306
+ aggs_failure , aggs = self .performFailure (NoFailure ())
307
+
308
+ self .assertNoCommits (aggs_failure )
309
+ self .assertIsolation (aggs_failure )
310
+ self .assertNoCommits (aggs )
311
+ self .assertIsolation (aggs )
312
+
313
+ print ('#### up up(winner) || down' )
314
+ print ('##########################' )
315
+ self .client .get_aggregates (clean = False )
316
+ self .client .stop ()
317
+ docker_api .containers .get ('node2' ).start ()
318
+ self .awaitOnline ("dbname=regression user=postgres host=127.0.0.1 port=15433" )
319
+ self .client .bgrun ()
320
+ time .sleep (3 )
321
+
322
+ aggs_failure , aggs = self .performFailure (NoFailure ())
323
+
324
+ self .assertCommits (aggs_failure )
325
+ self .assertIsolation (aggs_failure )
326
+ self .assertCommits (aggs )
327
+ self .assertIsolation (aggs )
328
+
329
+ print ('#### up up || up(2 -> 0)' )
330
+ print ('########################' )
331
+ docker_api .containers .get ('referee' ).start ()
332
+ time .sleep (5 )
333
+
334
+ print ('#### check that decision is cleaned' )
335
+ print ('###################################' )
336
+ con = psycopg2 .connect ("dbname=regression user=postgres host=127.0.0.1 port=15435" )
337
+ con .autocommit = True
338
+ cur = con .cursor ()
339
+ cur .execute ("select node_id from referee.decision where key = 'winner'" )
340
+ decisions_count = cur .rowcount
341
+ cur .close ()
342
+ con .close ()
343
+
344
+ self .assertEqual (decisions_count , 0 )
345
+
268
346
269
347
if __name__ == '__main__' :
270
348
unittest .main ()
0 commit comments