method addition:remove_containers_if_pacemaker_resources to not fail on pacemaker resources in assert_equal_container_state

Change-Id: I6b468f9e41a8af9a6a879706f57769b34772d941
This commit is contained in:
pinikomarov
2020-06-24 16:09:31 +03:00
parent c36d43630a
commit 04f08d8261
2 changed files with 32 additions and 5 deletions

View File

@@ -241,8 +241,8 @@ def check_iha_evacuation(failover_type=None, vm_type=None):
"""check vms on compute host,disrupt compute host, """check vms on compute host,disrupt compute host,
check all vms evacuated and pingable""" check all vms evacuated and pingable"""
for iteration in range(2): for iteration in range(2):
LOG.info(f'Beign IHA tests iteration {iteration}') LOG.info(f'Begin IHA tests iteration {iteration}')
LOG.info('creatr 4 vms') LOG.info('create 2 vms')
nova.create_multiple_unique_vms(n_vms=2) nova.create_multiple_unique_vms(n_vms=2)
compute_host = nova.get_random_compute_with_vms_name() compute_host = nova.get_random_compute_with_vms_name()
vms_starting_state_df = nova.get_compute_vms_df(compute_host) vms_starting_state_df = nova.get_compute_vms_df(compute_host)

View File

@@ -320,15 +320,44 @@ def get_container_states_list(containers_list,
return container_states_list return container_states_list
pcs_resource_list = ['haproxy', 'galera', 'redis', 'ovn-dbs', 'cinder',
'rabbitmq']
def remove_containers_if_pacemaker_resources(comparable_containers_df):
"""remove any containers in
param: comparable_containers_df that are pacemaker resources
i.e if they contain tha names of resources defined in
pcs_resources_list"""
for row in comparable_containers_df.iterrows():
for pcs_resource in pcs_resource_list:
if pcs_resource in str(row):
LOG.info(f'pcs resource {pcs_resource} has changed state, '
f'but that\'s ok since pcs resources can change '
f'state/host: {str(row)}')
# if a pcs resource is found , we drop that row
comparable_containers_df.drop(row[0], inplace=True)
return comparable_containers_df
def dataframe_difference(df1, df2, which=None): def dataframe_difference(df1, df2, which=None):
"""Find rows which are different between two DataFrames.""" """Find rows which are different between two DataFrames."""
comparison_df = df1.merge(df2, comparison_df = df1.merge(df2,
indicator='same_state', indicator='same_state',
how='outer') how='outer')
# return only non identical rows
if which is None: if which is None:
diff_df = comparison_df[comparison_df['same_state'] != 'both'] diff_df = comparison_df[comparison_df['same_state'] != 'both']
else: else:
diff_df = comparison_df[comparison_df['same_state'] == which] diff_df = comparison_df[comparison_df['same_state'] == which]
# if the list of diffrent state container are pacemaker resources ignore
# the error since we are checking pacemaker also.
remove_containers_if_pacemaker_resources(diff_df)
return diff_df return diff_df
@@ -393,7 +422,5 @@ def assert_equal_containers_state(expected_containers_list=None,
" OK, all containers are on the same state") " OK, all containers are on the same state")
return return
if failures: if failures:
LOG.info('container states mismatched:\n{!s}', '\n'.join( tobiko.fail('container states mismatched:\n{!s}', '\n'.join(
failures)) failures))
# tobiko.fail('container states mismatched:\n{!s}', '\n'.join(
# failures))