~ubuntu-branches/ubuntu/vivid/drizzle/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/test_tools/randgen/lib/GenTest/SimPipe/Oracle/TwiceSporadic.pm

  • Committer: Package Import Robot
  • Author(s): Tobias Frost
  • Date: 2013-08-22 20:18:31 UTC
  • mto: (20.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20130822201831-gn3ozsh7o7wmc5tk
Tags: upstream-7.2.3
ImportĀ upstreamĀ versionĀ 7.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# This program is free software; you can redistribute it and/or modify
 
3
# it under the terms of the GNU General Public License as published by
 
4
# the Free Software Foundation; version 2 of the License.
 
5
#
 
6
# This program is distributed in the hope that it will be useful, but
 
7
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
9
# General Public License for more details.
 
10
#
 
11
# You should have received a copy of the GNU General Public License
 
12
# along with this program; if not, write to the Free Software
 
13
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 
14
# USA
 
15
#
 
16
 
 
17
package GenTest::SimPipe::Oracle::TwiceSporadic;
 
18
 
 
19
require Exporter;
 
20
@ISA = qw(GenTest::SimPipe::Oracle GenTest);
 
21
@EXPORT = qw();
 
22
 
 
23
use strict;
 
24
use DBI;
 
25
use GenTest;
 
26
use GenTest::SimPipe::Oracle;
 
27
use GenTest::Constants;
 
28
use GenTest::Executor;
 
29
use GenTest::Comparator;
 
30
 
 
31
1;
 
32
 
 
33
sub oracle {
 
34
        my ($oracle, $testcase) = @_;
 
35
 
 
36
        my $executor = GenTest::Executor->newFromDSN($oracle->dsn());
 
37
        $executor->init();
 
38
        
 
39
        my $dbh = $executor->dbh();
 
40
 
 
41
        my $testcase_string = join("\n", (
 
42
                "CREATE DATABASE IF NOT EXISTS sporadic$$;",
 
43
                "USE sporadic$$;",
 
44
                $testcase->mysqldOptionsToString(),
 
45
                $testcase->dbObjectsToString()
 
46
        ));
 
47
 
 
48
        open (LD, '>/tmp/last_dump.test');
 
49
        print LD $testcase_string;
 
50
        close LD;
 
51
 
 
52
        $dbh->do($testcase_string, { RaiseError => 1 , mysql_multi_statements => 1 });
 
53
 
 
54
        $testcase_string .= "\n".join(";\n", @{$testcase->queries()}).";\n";
 
55
 
 
56
        $executor->execute($testcase->queries()->[0]);
 
57
 
 
58
        my @results = (
 
59
                $executor->execute($testcase->queries()->[1]."/* try 1 */"),    
 
60
                $executor->execute($testcase->queries()->[1]."/* try 2 */")
 
61
        );
 
62
 
 
63
        use Data::Dumper;
 
64
        print Dumper \@results;
 
65
        
 
66
        my $compare_outcome = GenTest::Comparator::compare(@results);
 
67
 
 
68
        $dbh->do("DROP DATABASE sporadic$$");
 
69
        
 
70
        if ($compare_outcome == STATUS_OK) {
 
71
                open (LR, '>/tmp/last_not_repeatable.test');
 
72
                print LR $testcase_string;
 
73
                close LR;
 
74
                return ORACLE_ISSUE_NO_LONGER_REPEATABLE;
 
75
        } else {
 
76
                open (LR, '>/tmp/last_repeatable.test');
 
77
                print LR $testcase_string;
 
78
                close LR;
 
79
                return ORACLE_ISSUE_STILL_REPEATABLE;
 
80
        }       
 
81
}
 
82
 
 
83
1;