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

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/util/simplify-crash.pl

  • 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-2009 Sun Microsystems, Inc. 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
 
use strict;
19
 
use lib 'lib';
20
 
use lib '../lib';
21
 
use DBI;
22
 
 
23
 
use GenTest::Constants;
24
 
use GenTest::Executor::MySQL;
25
 
use GenTest::Simplifier::SQL;
26
 
use GenTest::Simplifier::Test;
27
 
 
28
 
#
29
 
# Please modify those settings to fit your environment before you run this script
30
 
#
31
 
 
32
 
my $basedir = '/home/philips/bzr/maria-5.3-mwl128/';
33
 
my $vardir = $basedir.'/mysql-test/var';
34
 
my $dsn = 'dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test';
35
 
 
36
 
my $original_query = "
37
 
        SELECT 1 FROM DUAL
38
 
";
39
 
 
40
 
# Maximum number of seconds a query will be allowed to proceed. It is assumed that most crashes will happen immediately after takeoff
41
 
my $timeout = 10;
42
 
 
43
 
my @mtr_options = (
44
 
#       '--mysqld=--innodb',
45
 
        '--mysqld=--log-output=file',   # Prevents excessively long CSV recovery on each startup
46
 
        '--start-and-exit',
47
 
        '--start-dirty',
48
 
        "--vardir=$vardir",
49
 
        "--master_port=19300",
50
 
        '--skip-ndbcluster',
51
 
        '--mysqld=--loose-core-file-size=1',
52
 
        '--fast',
53
 
        '--mysqld=--key_buffer_size=16K',
54
 
        '--mysqld=--table_open_cache=4',
55
 
        '--mysqld=--sort_buffer_size=64K',
56
 
        '--mysqld=--read_buffer_size=256K',
57
 
        '--mysqld=--read_rnd_buffer_size=256K',
58
 
        '--mysqld=--thread_stack=240K',
59
 
        '--mysqld=--loose-innodb_buffer_pool_size=16M',
60
 
        '--mysqld=--loose-innodb_additional_mem_pool_size=2M',
61
 
        '--mysqld=--innodb_log_file_size=5M',
62
 
        '--mysqld=--innodb_log_buffer_size=8M',
63
 
        '--mysqld=--innodb_flush_log_at_trx_commit=2',
64
 
        '1st'   # Required for proper operation of MTR --start-and-exit
65
 
);
66
 
 
67
 
my $orig_database = 'test';
68
 
my $new_database = 'crash';
69
 
 
70
 
my $executor;
71
 
 
72
 
start_server();
73
 
 
74
 
my $simplifier = GenTest::Simplifier::SQL->new(
75
 
        oracle => sub {
76
 
                my $oracle_query = shift;
77
 
                my $dbh = $executor->dbh();
78
 
        
79
 
                my $connection_id = $dbh->selectrow_array("SELECT CONNECTION_ID()");
80
 
                $dbh->do("CREATE EVENT timeout ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL $timeout SECOND DO KILL QUERY $connection_id");
81
 
 
82
 
                $executor->execute($oracle_query);
83
 
 
84
 
                # Or, alternatively, execute as a prepared statement
85
 
                # $executor->execute("PREPARE prep_stmt FROM \"$oracle_query\"");
86
 
                # $executor->execute("EXECUTE prep_stmt");
87
 
                # $executor->execute("EXECUTE prep_stmt");
88
 
                # $executor->execute("DEALLOCATE PREPARE prep_stmt");
89
 
 
90
 
                $dbh->do("DROP EVENT IF EXISTS timeout");
91
 
 
92
 
                if (!$executor->dbh()->ping()) {
93
 
                        start_server();
94
 
                        return ORACLE_ISSUE_STILL_REPEATABLE;
95
 
                } else {
96
 
                        return ORACLE_ISSUE_NO_LONGER_REPEATABLE;
97
 
                }
98
 
        }
99
 
);
100
 
 
101
 
my $simplified_query = $simplifier->simplify($original_query);
102
 
print "Simplified query:\n$simplified_query;\n\n";
103
 
 
104
 
my $simplifier_test = GenTest::Simplifier::Test->new(
105
 
        executors => [ $executor ],
106
 
        queries => [ $simplified_query , $original_query ]
107
 
);
108
 
 
109
 
my $simplified_test = $simplifier_test->simplify();
110
 
 
111
 
print "Simplified test\n\n";
112
 
print $simplified_test;
113
 
 
114
 
sub start_server {
115
 
        chdir($basedir.'/mysql-test') or die "Unable to chdir() to $basedir/mysql-test: $!";
116
 
 
117
 
        $executor = GenTest::Executor::MySQL->new( dsn => $dsn );
118
 
        $executor->init() if defined $executor;
119
 
 
120
 
        if ((not defined $executor) || (not defined $executor->dbh()) || (!$executor->dbh()->ping())) {
121
 
                system("MTR_VERSION=1 perl mysql-test-run.pl ".join(" ", @mtr_options));
122
 
                $executor = GenTest::Executor::MySQL->new( dsn => $dsn );
123
 
                $executor->init();
124
 
        }
125
 
 
126
 
        $executor->dbh()->do("SET GLOBAL EVENT_SCHEDULER = ON");
127
 
}