~openstack-charmers-next/charms/xenial/heat/trunk

« back to all changes in this revision

Viewing changes to tests/charmhelpers/contrib/amulet/utils.py

  • Committer: Liam Young
  • Date: 2016-04-12 14:05:01 UTC
  • Revision ID: liam.young@canonical.com-20160412140501-udzdt70fp0deay35
Charmhelper sync before 1604 testing

Change-Id: I330dc75732845ebb0d5d4edb2f1bbb9e144bd393

Show diffs side-by-side

added added

removed removed

Lines of Context:
601
601
                return ('Process name count mismatch.  expected, actual: {}, '
602
602
                        '{}'.format(len(expected), len(actual)))
603
603
 
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,
614
614
                                                 a_pids))
615
615
 
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:
 
619
                    return fail_msg
 
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:
619
625
                    return fail_msg
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:
623
629
                    return fail_msg
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:
627
633
                    return fail_msg
628
634
                else:
629
635
                    self.log.debug('PID check OK: {} {} {}: '
630
636
                                   '{}'.format(e_sentry_name, e_proc_name,
631
 
                                               e_pids_length, a_pids))
 
637
                                               e_pids, a_pids))
632
638
        return None
633
639
 
634
640
    def validate_list_of_identical_dicts(self, list_of_dicts):