#NEWLINE# @ contextmanager #NEWLINE# def assert_node_reassigned( self ) : #NEWLINE# #INDENT# cluster = self . env . create ( cluster_kwargs = { #NEWLINE# #INDENT# 'mode' : consts . CLUSTER_MODES . ha_compact , #NEWLINE# #UNINDENT# } , release_kwargs = { #NEWLINE# #INDENT# 'version' : '2014.2-6.0' , #NEWLINE# 'operating_system' : 'Ubuntu' , #NEWLINE# #UNINDENT# } , nodes_kwargs = [ { #NEWLINE# #INDENT# 'pending_roles' : [ self . role_name ] , #NEWLINE# 'status' : consts . NODE_STATUSES . discover , #NEWLINE# 'pending_addition' : True , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'roles' : [ self . role_name ] , #NEWLINE# 'status' : consts . NODE_STATUSES . ready , #NEWLINE# 'pending_addition' : True , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# objects . Cluster . set_primary_roles ( cluster , cluster . nodes ) #NEWLINE# nodes = sorted ( cluster . nodes , key = ( lambda node : node . id ) ) #NEWLINE# self . assertEqual ( objects . Node . all_roles ( cluster [ 1 ] ) , [ self . primary_role_name ] ) #NEWLINE# self . assertEqual ( objects . Node . all_roles ( nodes [ 0 ] ) , [ self . role_name ] ) #NEWLINE# ( yield nodes [ 1 ] ) #NEWLINE# objects . Cluster . set_primary_roles ( cluster , cluster . nodes ) #NEWLINE# self . assertEqual ( objects . Node . all_roles ( nodes [ 0 ] ) , [ self . primary_role_name ] )