~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/randgen/lib/GenTest/Validator/ResultsetComparator.pm

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-10-29 15:43:40 UTC
  • mfrom: (1.2.12) (2.1.19 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029154340-2gp39el6cv8bwf2o
Tags: 1:7.2.3-2ubuntu1
* Merge from debian, remaining changes:
  - Link against boost_system because of boost_thread.
  - Add required libs to message/include.am
  - Add upstart job and adjust init script to be upstart compatible.
  - Disable -floop-parallelize-all due to gcc-4.8/4.9 compiler ICE
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57732

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2008, 2011 Oracle and/or its affiliates. All rights reserved.
2
 
# Use is subject to license terms.
3
 
#
4
 
# This program is free software; you can redistribute it and/or modify
5
 
# it under the terms of the GNU General Public License as published by
6
 
# the Free Software Foundation; version 2 of the License.
7
 
#
8
 
# This program is distributed in the hope that it will be useful, but
9
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
 
# General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
16
 
# USA
17
 
 
18
 
package GenTest::Validator::ResultsetComparator;
19
 
 
20
 
require Exporter;
21
 
@ISA = qw(GenTest GenTest::Validator);
22
 
 
23
 
use strict;
24
 
 
25
 
use GenTest;
26
 
use GenTest::Constants;
27
 
use GenTest::Comparator;
28
 
use GenTest::Result;
29
 
use GenTest::Validator;
30
 
 
31
 
sub validate {
32
 
        my ($comparator, $executors, $results) = @_;
33
 
 
34
 
        return STATUS_OK if $#$results != 1;
35
 
 
36
 
        my $query = $results->[0]->query();
37
 
        my $compare_outcome = GenTest::Comparator::compare($results->[0], $results->[1]);
38
 
 
39
 
        return STATUS_WONT_HANDLE if $results->[0]->status() == STATUS_SEMANTIC_ERROR || $results->[1]->status() == STATUS_SEMANTIC_ERROR;
40
 
        return STATUS_WONT_HANDLE if $results->[0]->query() =~ m{EXPLAIN}sio;
41
 
 
42
 
        if ( ($compare_outcome == STATUS_LENGTH_MISMATCH) ||
43
 
             ($compare_outcome == STATUS_CONTENT_MISMATCH) 
44
 
        ) {
45
 
                say("---------- RESULT COMPARISON ISSUE START ----------");
46
 
        }
47
 
 
48
 
        if ($compare_outcome == STATUS_LENGTH_MISMATCH) {
49
 
                if ($query =~ m{^\s*select}io) {
50
 
                        say("Query: $query failed: result length mismatch between servers (".$results->[0]->rows()." vs. ".$results->[1]->rows().")");
51
 
                        say(GenTest::Comparator::dumpDiff($results->[0], $results->[1]));
52
 
                } else {
53
 
                        say("Query: $query failed: affected_rows mismatch between servers (".$results->[0]->affectedRows()." vs. ".$results->[1]->affectedRows().")");
54
 
                }
55
 
        } elsif ($compare_outcome == STATUS_CONTENT_MISMATCH) {
56
 
                say("Query: ".$results->[0]->query()." failed: result content mismatch between servers.");
57
 
                say(GenTest::Comparator::dumpDiff($results->[0], $results->[1]));
58
 
        }
59
 
 
60
 
        if ( ($compare_outcome == STATUS_LENGTH_MISMATCH) ||
61
 
             ($compare_outcome == STATUS_CONTENT_MISMATCH) 
62
 
        ) {
63
 
                say("---------- RESULT COMPARISON ISSUE END ------------");
64
 
        }
65
 
 
66
 
        #
67
 
        # If the discrepancy is found on SELECT, we reduce the severity of the error so that the test can continue
68
 
        # hopefully finding further errors in the same run or providing an indication as to how frequent the error is
69
 
        #
70
 
        # If the discrepancy is on an UPDATE, then the servers have diverged and the test can not continue safely.
71
 
        # 
72
 
 
73
 
        if ($query =~ m{^[\s/*!0-9]*(EXPLAIN|SELECT|ALTER|LOAD\s+INDEX|CACHE\s+INDEX)}io) {
74
 
                return $compare_outcome - STATUS_SELECT_REDUCTION;
75
 
        } else {
76
 
                return $compare_outcome;
77
 
        }
78
 
}
79
 
 
80
 
1;