@@ -342,5 +342,88 @@ def base_test_job_monitoring_solve_racecondition(fts3db, fts3Client):
342
342
assert not filesToSubmit
343
343
344
344
345
+ def base_test_delete_operations (fts3db , fts3Client ):
346
+ """Test operation removals"""
347
+ op1 = generateOperation ("Transfer" , 2 , ["Target1" ])
348
+
349
+ res = fts3Client .persistOperation (op1 )
350
+ opID1 = res ["Value" ]
351
+
352
+ # Create two other operations, to test the limit feature
353
+ op2 = generateOperation ("Transfer" , 2 , ["Target2" ])
354
+ res = fts3Client .persistOperation (op2 )
355
+ opID2 = res ["Value" ]
356
+
357
+ op3 = generateOperation ("Transfer" , 2 , ["Target3" ])
358
+ res = fts3Client .persistOperation (op3 )
359
+ opID3 = res ["Value" ]
360
+
361
+ # Now, call delete, and make sure that operation is not delete
362
+ # Ops is not in a final state, and delay is not passed
363
+ res = fts3db .deleteFinalOperations ()
364
+ assert res ["OK" ]
365
+
366
+ res = fts3Client .getOperation (opID1 )
367
+ assert res ["OK" ]
368
+ op1 = res ["Value" ]
369
+
370
+ # Try again with no delay, but still not final state
371
+ res = fts3db .deleteFinalOperations (deleteDelay = 0 )
372
+ assert res ["OK" ]
373
+
374
+ res = fts3Client .getOperation (opID1 )
375
+ assert res ["OK" ]
376
+ op1 = res ["Value" ]
377
+
378
+ # Set the final status
379
+ op1 .status = "Finished"
380
+ res = fts3Client .persistOperation (op1 )
381
+ assert res ["OK" ]
382
+
383
+ # Now try to delete again.
384
+ # It should still not work because of the delay
385
+ res = fts3db .deleteFinalOperations ()
386
+ assert res ["OK" ]
387
+
388
+ res = fts3Client .getOperation (opID1 )
389
+ assert res ["OK" ]
390
+ op1 = res ["Value" ]
391
+
392
+ # Finally, it should work, with no delay and a final status
393
+ res = fts3db .deleteFinalOperations (deleteDelay = 0 )
394
+ assert res ["OK" ]
395
+
396
+ res = fts3Client .getOperation (opID1 )
397
+ assert not res ["OK" ]
398
+
399
+ # op2 and op3 should still be here though !
400
+
401
+ res = fts3Client .getOperation (opID2 )
402
+ assert res ["OK" ]
403
+ op2 = res ["Value" ]
404
+ res = fts3Client .getOperation (opID3 )
405
+ assert res ["OK" ]
406
+ op3 = res ["Value" ]
407
+
408
+ # Set them both to a final status
409
+ op2 .status = "Finished"
410
+ res = fts3Client .persistOperation (op2 )
411
+ assert res ["OK" ]
412
+ op3 .status = "Finished"
413
+ res = fts3Client .persistOperation (op3 )
414
+ assert res ["OK" ]
415
+
416
+ # Now try to delete, but only one
417
+ res = fts3db .deleteFinalOperations (limit = 1 , deleteDelay = 0 )
418
+ assert res ["OK" ]
419
+
420
+ # Now only op2 or op3 should be here
421
+
422
+ res2 = fts3Client .getOperation (opID2 )
423
+ res3 = fts3Client .getOperation (opID3 )
424
+
425
+ assert res2 ["OK" ] ^ res3 ["OK" ]
426
+
427
+
345
428
# All base tests defined in this module
346
429
allBaseTests = [test_func for testName , test_func in globals ().items () if testName .startswith ("base_test" )]
0 commit comments