~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to lib/GenTest/Validator/SelectStability.pm

initial import from internal tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package GenTest::Validator::SelectStability;
 
2
 
 
3
require Exporter;
 
4
@ISA = qw(GenTest::Validator GenTest);
 
5
 
 
6
use strict;
 
7
 
 
8
use GenTest;
 
9
use GenTest::Comparator;
 
10
use GenTest::Constants;
 
11
use GenTest::Result;
 
12
use GenTest::Validator;
 
13
use Time::HiRes;
 
14
 
 
15
sub validate {
 
16
        my ($validator, $executors, $results) = @_;
 
17
        my $executor = $executors->[0];
 
18
        my $orig_result = $results->[0];
 
19
        my $orig_query = $orig_result->query();
 
20
 
 
21
        return STATUS_OK if $orig_query !~ m{^\s*select}io;
 
22
        return STATUS_OK if not defined $orig_result->data();
 
23
 
 
24
        foreach my $delay (0, 0.01, 0.1) {
 
25
                Time::HiRes::sleep($delay);
 
26
                my $new_result = $executor->execute($orig_query);
 
27
                return STATUS_OK if not defined $new_result->data();
 
28
                my $compare_outcome = GenTest::Comparator::compare($orig_result, $new_result);
 
29
                if ($compare_outcome > STATUS_OK) {
 
30
                        say("Query: $orig_query; returns different result when executed after a delay of $delay seconds.");
 
31
                        say(GenTest::Comparator::dumpDiff($orig_result, $new_result));
 
32
                        return $compare_outcome - STATUS_SELECT_REDUCTION;
 
33
                }
 
34
        }
 
35
 
 
36
        return STATUS_OK;
 
37
}
 
38
 
 
39
1;