#NEWLINE# def test_expirer_object_split_brain( self ) : #NEWLINE# #INDENT# old_policy = random . choice ( ENABLED_POLICIES ) #NEWLINE# wrong_policy = random . choice ( [ p for p in ENABLED_POLICIES if ( p != old_policy ) ] ) #NEWLINE# self . brain . stop_primary_half ( ) #NEWLINE# self . brain . put_container ( int ( old_policy ) ) #NEWLINE# self . brain . put_object ( headers = { #NEWLINE# #INDENT# 'X-Delete-After' : 2 , #NEWLINE# #UNINDENT# } ) #NEWLINE# metadata = self . client . get_object_metadata ( self . account , self . container_name , self . object_name , headers = { #NEWLINE# #INDENT# 'X-Backend-Storage-Policy-Index' : int ( old_policy ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# create_timestamp = Timestamp ( metadata [ 'x-timestamp' ] ) #NEWLINE# self . brain . start_primary_half ( ) #NEWLINE# Manager ( [ 'object-updater' ] ) . once ( ) #NEWLINE# self . brain . stop_handoff_half ( ) #NEWLINE# self . brain . put_container ( int ( wrong_policy ) ) #NEWLINE# Manager ( [ 'container-updater' ] ) . once ( ) #NEWLINE# self . expirer . once ( ) #NEWLINE# self . brain . start_handoff_half ( ) #NEWLINE# self . get_to_final_state ( ) #NEWLINE# found_in_policy = None #NEWLINE# metadata = self . client . get_object_metadata ( self . account , self . container_name , self . object_name , acceptable_statuses = ( 4 , ) , headers = { #NEWLINE# #INDENT# 'X-Backend-Storage-Policy-Index' : int ( old_policy ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertTrue ( ( 'x-backend-timestamp' in metadata ) ) #NEWLINE# self . assertEqual ( Timestamp ( metadata [ 'x-backend-timestamp' ] ) , create_timestamp ) #NEWLINE# for obj in self . client . iter_objects ( self . account , self . container_name ) : #NEWLINE# #INDENT# if ( self . object_name == obj [ 'name' ] ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . fail ( ( 'Did not find listing for %s' % self . object_name ) ) #NEWLINE# #UNINDENT# client . post_container ( self . url , self . token , self . container_name , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# self . expirer . once ( ) #NEWLINE# for obj in self . client . iter_objects ( self . account , self . container_name ) : #NEWLINE# #INDENT# if ( self . object_name == obj [ 'name' ] ) : #NEWLINE# #INDENT# self . fail ( ( 'Found listing for %s' % self . object_name ) ) #NEWLINE# #UNINDENT# #UNINDENT# found_in_policy = None #NEWLINE# for policy in ENABLED_POLICIES : #NEWLINE# #INDENT# metadata = self . client . get_object_metadata ( self . account , self . container_name , self . object_name , acceptable_statuses = ( 4 , ) , headers = { #NEWLINE# #INDENT# 'X-Backend-Storage-Policy-Index' : int ( policy ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( 'x-backend-timestamp' in metadata ) : #NEWLINE# #INDENT# if found_in_policy : #NEWLINE# #INDENT# self . fail ( ( 'found object in %s and also %s' % ( found_in_policy , policy ) ) ) #NEWLINE# #UNINDENT# found_in_policy = policy #NEWLINE# self . assertTrue ( ( 'x-backend-timestamp' in metadata ) ) #NEWLINE# self . assertTrue ( ( Timestamp ( metadata [ 'x-backend-timestamp' ] ) > create_timestamp ) )