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

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/lib/GenTest/SimPipe/Oracle/Crash.pm

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

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::Crash;
 
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
use Data::Dumper;
 
31
 
 
32
1;
 
33
 
 
34
sub oracle {
 
35
        my ($oracle, $testcase) = @_;
 
36
 
 
37
        my $executor = GenTest::Executor->newFromDSN($oracle->dsn());
 
38
        $executor->init();
 
39
        
 
40
        my $dbh = $executor->dbh();
 
41
        start_server() if not defined $dbh || !$dbh->ping();
 
42
 
 
43
        my $testcase_string = join("\n", (
 
44
                "CREATE DATABASE IF NOT EXISTS crash;",
 
45
                "USE crash;",
 
46
                $testcase->mysqldOptionsToString(),
 
47
                $testcase->dbObjectsToString()
 
48
        ));
 
49
 
 
50
        $dbh->do($testcase_string, { RaiseError => 1 , mysql_multi_statements => 1 });
 
51
 
 
52
        foreach my $query (@{$testcase->queries()}) {
 
53
                my $sth = $dbh->prepare($query, {RaiseError => 1, mysql_multi_statements => 1});
 
54
                $sth->execute();
 
55
                say("Result: ".$sth->err()." ".$sth->errstr())
 
56
        }
 
57
 
 
58
        $testcase_string .= "\n".join(";\n", @{$testcase->queries()})."\n";
 
59
 
 
60
        # We use our home-grown ping here and not $dbh->ping() as $dbh->ping() was foind
 
61
        # to be buggy in DBD::MySQL.For some reason, it returned TRUE even on a crashed server
 
62
 
 
63
        my ($ping) = $dbh->selectrow_array("SELECT 'working';");
 
64
 
 
65
        if ($ping eq 'working') {
 
66
                say("Ping working. Not repeatable.");
 
67
                open(NR, ">/tmp/last_not_repeatable.test");
 
68
                print NR $testcase_string;
 
69
                close NR;
 
70
                return ORACLE_ISSUE_NO_LONGER_REPEATABLE;
 
71
        } else {
 
72
                say("Ping not working. Server has likely crashed. Repeatable.");
 
73
                open(NR, ">/tmp/last_repeatable.test");
 
74
                print NR $testcase_string;
 
75
                close NR;
 
76
                $oracle->startServer();
 
77
                return ORACLE_ISSUE_STILL_REPEATABLE;
 
78
        }       
 
79
}
 
80
 
 
81
sub startServer {
 
82
        my $oracle = shift;
 
83
        my $basedir = $oracle->basedir();
 
84
 
 
85
        chdir($basedir.'/mysql-test');
 
86
        system("MTR_VERSION=1 perl mysql-test-run.pl --start-and-exit --mysqld=--skip-grant-tables --mysqld=--loose-skip-pbxt --mysqld=--innodb --master_port=19300 --mysqld=--log-output=file 1st");
 
87
}
 
88
 
 
89
1;