Esempio n. 1
0
def _check_data_consistency(server1, server2, obj1, obj2, reporter, options):
    """Check data consistency

    server1[in]       first server Server instance
    server2[in]       second server Server instance
    obj1[in]          first object
    obj2[in]          second object
    reporter[in]      database compare reporter class instance
    options[in]       options dictionary

    Returns list of errors debug_msgs
    """
    direction = options.get('changes-for', 'server1')
    reverse = options.get('reverse', False)
    quiet = options.get('quiet', False)

    errors = []
    debug_msgs = []
    # For each table, do row data consistency check
    if not options['no_data']:
        reporter.report_state('-')
        try:
            # Do the comparison considering the direction.
            diff_server1, diff_server2 = check_consistency(
                server1, server2, obj1, obj2, options, diag_msgs=debug_msgs,
                reporter=reporter)

            # if no differences, return
            if (diff_server1 is None and diff_server2 is None) or \
                    (not reverse and direction == 'server1' and
                     diff_server1 is None) or \
                    (not reverse and direction == 'server2' and
                     diff_server2 is None):
                return errors, debug_msgs

            # Build diff list
            new_opts = options.copy()
            new_opts['data_diff'] = True
            if direction == 'server1':
                diff_list = build_diff_list(diff_server1, diff_server2,
                                            diff_server1, diff_server2,
                                            'server1', 'server2', new_opts)
            else:
                diff_list = build_diff_list(diff_server2, diff_server1,
                                            diff_server2, diff_server1,
                                            'server2', 'server1', new_opts)
            if diff_list:
                errors = diff_list
        except UtilError, e:
            if e.errmsg.endswith("not have an usable Index or primary key."):
                reporter.report_state('SKIP')
                errors.append("# {0}".format(e.errmsg))
            else:
                reporter.report_state('FAIL')
                if not options['run_all_tests']:
                    if not quiet:
                        print
                    raise e
                else:
                    errors.append(e.errmsg)
Esempio n. 2
0
def _check_data_consistency(server1, server2, obj1, obj2, reporter, options):
    """Check data consistency

    server1[in]       first server Server instance
    server2[in]       second server Server instance
    obj1[in]          first object
    obj2[in]          second object
    reporter[in]      database compare reporter class instance
    options[in]       options dictionary

    Returns list of errors debug_msgs
    """
    direction = options.get('changes-for', 'server1')
    reverse = options.get('reverse', False)

    errors = []
    debug_msgs = []
    # For each table, do row data consistency check
    if not options['no_data']:
        reporter.report_state('-')
        try:
            # Do the comparison considering the direction.
            diff_server1, diff_server2 = check_consistency(
                server1, server2, obj1, obj2, options, diag_msgs=debug_msgs,
                reporter=reporter)

            # if no differences, return
            if (diff_server1 is None and diff_server2 is None) or \
                    (not reverse and direction == 'server1' and
                     diff_server1 is None) or \
                    (not reverse and direction == 'server2' and
                     diff_server2 is None):
                return errors, debug_msgs

            # Build diff list
            new_opts = options.copy()
            new_opts['data_diff'] = True
            if direction == 'server1':
                diff_list = build_diff_list(diff_server1, diff_server2,
                                            diff_server1, diff_server2,
                                            'server1', 'server2', new_opts)
            else:
                diff_list = build_diff_list(diff_server2, diff_server1,
                                            diff_server2, diff_server1,
                                            'server2', 'server1', new_opts)
            if diff_list:
                errors = diff_list
        except UtilError, e:
            if e.errmsg.endswith("not have an usable Index or primary key."):
                reporter.report_state('SKIP')
                errors.append("# {0}".format(e.errmsg))
            else:
                reporter.report_state('FAIL')
                if not options['run_all_tests']:
                    print
                    raise e
                else:
                    errors.append(e.errmsg)
Esempio n. 3
0
def _check_data_consistency(server1, server2, obj1, obj2, reporter, options):
    """Check data consistency

    server1[in]       first server Server instance
    server2[in]       second server Server instance
    obj1[in]          first object
    obj2[in]          second object
    reporter[in]      database compare reporter class instance
    options[in]       options dictionary

    Returns list of errors
    """
    direction = options.get('changes-for', 'server1')
    reverse = options.get('reverse', False)

    errors = []
    diff_server1 = []
    diff_server2 = []
    diff_list = []
    # For each table, do row data consistency check
    if not options['no_data']:
        try:
            # Do the comparison based on direction
            if direction == 'server1' or reverse:
                diff_server1 = check_consistency(server1, server2,
                                                 obj1, obj2, options)
            if direction == 'server2' or reverse:
                diff_server2 = check_consistency(server2, server1,
                                                 obj2, obj1, options)

            # if no differences, return
            if (diff_server1 is None and diff_server2 is None) or \
                    (not reverse and direction == 'server1' and
                     diff_server1 is None) or \
                    (not reverse and direction == 'server2' and
                     diff_server2 is None):
                reporter.report_state('pass')
                return errors

            # Build diff list
            new_opts = options.copy()
            new_opts['data_diff'] = True
            if direction == 'server1':
                diff_list = build_diff_list(diff_server1, diff_server2,
                                            diff_server1, diff_server2,
                                            'server1', 'server2', new_opts)
            else:
                diff_list = build_diff_list(diff_server2, diff_server1,
                                            diff_server2, diff_server1,
                                            'server2', 'server1', new_opts)
            if len(diff_list) == 0:
                reporter.report_state('pass')
            else:
                reporter.report_state('FAIL')
                errors = diff_list
        except UtilError, e:
            if e.errmsg == "No primary key found.":
                reporter.report_state('SKIP')
                errors.append("# {0}".format(e.errmsg))
            else:
                reporter.report_state('FAIL')
                if not options['run_all_tests']:
                    print
                    raise e
                else:
                    errors.append(e.errmsg)
Esempio n. 4
0
def _check_data_consistency(server1, server2, obj1, obj2, reporter, options):
    """Check data consistency

    server1[in]       first server Server instance
    server2[in]       second server Server instance
    obj1[in]          first object
    obj2[in]          second object
    reporter[in]      database compare reporter class instance
    options[in]       options dictionary

    Returns list of errors
    """
    direction = options.get('changes-for', 'server1')
    reverse = options.get('reverse', False)

    errors = []
    diff_server1 = []
    diff_server2 = []
    diff_list = []
    # For each table, do row data consistency check
    if not options['no_data']:
        try:
            # Do the comparison based on direction
            if direction == 'server1' or reverse:
                diff_server1 = check_consistency(server1, server2, obj1, obj2,
                                                 options)
            if direction == 'server2' or reverse:
                diff_server2 = check_consistency(server2, server1, obj2, obj1,
                                                 options)

            # if no differences, return
            if (diff_server1 is None and diff_server2 is None) or \
                    (not reverse and direction == 'server1' and
                     diff_server1 is None) or \
                    (not reverse and direction == 'server2' and
                     diff_server2 is None):
                reporter.report_state('pass')
                return errors

            # Build diff list
            new_opts = options.copy()
            new_opts['data_diff'] = True
            if direction == 'server1':
                diff_list = build_diff_list(diff_server1, diff_server2,
                                            diff_server1, diff_server2,
                                            'server1', 'server2', new_opts)
            else:
                diff_list = build_diff_list(diff_server2, diff_server1,
                                            diff_server2, diff_server1,
                                            'server2', 'server1', new_opts)
            if len(diff_list) == 0:
                reporter.report_state('pass')
            else:
                reporter.report_state('FAIL')
                errors = diff_list
        except UtilError, e:
            if e.errmsg == "No primary key found.":
                reporter.report_state('SKIP')
                errors.append("# {0}".format(e.errmsg))
            else:
                reporter.report_state('FAIL')
                if not options['run_all_tests']:
                    print
                    raise e
                else:
                    errors.append(e.errmsg)