601
601
return ('Process name count mismatch. expected, actual: {}, '
602
602
'{}'.format(len(expected), len(actual)))
604
for (e_proc_name, e_pids_length), (a_proc_name, a_pids) in \
604
for (e_proc_name, e_pids), (a_proc_name, a_pids) in \
605
605
zip(e_proc_names.items(), a_proc_names.items()):
606
606
if e_proc_name != a_proc_name:
607
607
return ('Process name mismatch. expected, actual: {}, '
610
610
a_pids_length = len(a_pids)
611
611
fail_msg = ('PID count mismatch. {} ({}) expected, actual: '
612
612
'{}, {} ({})'.format(e_sentry_name, e_proc_name,
613
e_pids_length, a_pids_length,
613
e_pids, a_pids_length,
616
# If expected is not bool, ensure PID quantities match
617
if not isinstance(e_pids_length, bool) and \
618
a_pids_length != e_pids_length:
616
# If expected is a list, ensure at least one PID quantity match
617
if isinstance(e_pids, list) and \
618
a_pids_length not in e_pids:
620
# If expected is not bool and not list,
621
# ensure PID quantities match
622
elif not isinstance(e_pids, bool) and \
623
not isinstance(e_pids, list) and \
624
a_pids_length != e_pids:
620
626
# If expected is bool True, ensure 1 or more PIDs exist
621
elif isinstance(e_pids_length, bool) and \
622
e_pids_length is True and a_pids_length < 1:
627
elif isinstance(e_pids, bool) and \
628
e_pids is True and a_pids_length < 1:
624
630
# If expected is bool False, ensure 0 PIDs exist
625
elif isinstance(e_pids_length, bool) and \
626
e_pids_length is False and a_pids_length != 0:
631
elif isinstance(e_pids, bool) and \
632
e_pids is False and a_pids_length != 0:
629
635
self.log.debug('PID check OK: {} {} {}: '
630
636
'{}'.format(e_sentry_name, e_proc_name,
631
e_pids_length, a_pids))
634
640
def validate_list_of_identical_dicts(self, list_of_dicts):