@@ -55,7 +55,7 @@ def is_localhost_synonym(name):
5555from irods .test .helpers import iRODSUserLogins
5656import irods .exception as ex
5757from irods .column import Criterion
58- from irods .data_object import chunks , irods_dirname
58+ from irods .data_object import chunks , irods_dirname , _REPLICA_FITNESS_SORT_KEY_FN
5959import irods .test .helpers as helpers
6060import irods .test .modules as test_modules
6161import irods .keywords as kw
@@ -2989,7 +2989,6 @@ def test_handling_of_termination_signals_during_multithread_put__issue_722(self)
29892989
29902990 test_put__issue_722 (self )
29912991
2992- @unittest .skipIf (irods .version .version_as_tuple () < (4 ,), 'too soon for this test.' )
29932992 def test_modified_default_sorting_of_replicas__issue_647 (self ):
29942993 basename = unique_name (my_function_name (), datetime .now ()) + '_dataobj_647'
29952994 with self .create_simple_resc () as newResc1 , self .create_simple_resc () as newResc2 :
@@ -3005,13 +3004,27 @@ def test_modified_default_sorting_of_replicas__issue_647(self):
30053004 f .write (b'.' )
30063005 time .sleep (2 )
30073006
3008- # Voting should ensure exactly two good replicas of the three.
30093007 data .replicate (resource = newResc2 )
30103008
3011- # refresh replicas
3012- data = self .sess .data_objects .get (data .path )
3009+ # At this point, there should ensure exactly two good replicas of the three.
3010+ # Assert exactly one replica is stale, to corroborate
3011+ data = self .sess .data_objects .get (
3012+ data .path ,
3013+ replica_sort_function = lambda row : int (row [DataObject .replica_status ])
3014+ )
3015+ self .assertEqual (
3016+ [repl .status for repl in data .replicas ],
3017+ ['0' , '1' , '1' ]
3018+ )
3019+
3020+ options = {}
3021+ if irods .version .version_as_tuple () < (4 ,):
3022+ options ['replica_sort_function' ] = _REPLICA_FITNESS_SORT_KEY_FN
3023+
3024+ # Get a data object with the PRC3-alternative/PRC4-default sort order.
3025+ data = self .sess .data_objects .get (data .path , ** options )
30133026
3014- # Test replica sorting.
3027+ # Test default replica sorting.
30153028 self .assertEqual (data .replicas [0 ].status , '1' )
30163029 self .assertEqual (data .replicas [0 ].modify_time , data .modify_time )
30173030 self .assertGreater (data .replicas [0 ].modify_time , data .replicas [1 ].modify_time )
0 commit comments