~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/dtr_stress.pl

  • Committer: Monty Taylor
  • Date: 2009-12-25 08:50:15 UTC
  • mto: This revision was merged to the branch mainline in revision 1255.
  • Revision ID: mordred@inaugust.com-20091225085015-83sux5qsvy312gew
MEM_ROOT == memory::Root

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- cperl -*-
2
 
# Copyright (C) 2006 MySQL AB
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,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU 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  USA
16
 
 
17
 
# This is a library file used by the Perl version of drizzle-test-run,
18
 
# and is part of the translation of the Bourne shell script with the
19
 
# same name.
20
 
 
21
 
use strict;
22
 
use File::Spec;
23
 
 
24
 
# These are not to be prefixed with "dtr_"
25
 
 
26
 
sub run_stress_test ();
27
 
 
28
 
##############################################################################
29
 
#
30
 
#  Run tests in the stress mode
31
 
#
32
 
##############################################################################
33
 
 
34
 
sub run_stress_test () 
35
 
{
36
 
 
37
 
  my $args;
38
 
  my $stress_suitedir;
39
 
 
40
 
  dtr_report("Starting stress testing\n");
41
 
 
42
 
  if ( ! $::glob_use_embedded_server )
43
 
  {
44
 
    if ( ! drizzled_start($::master->[0],[],[]) )
45
 
    {
46
 
      dtr_error("Can't start the drizzled server");
47
 
    }
48
 
  }
49
 
 
50
 
  my $stress_basedir=File::Spec->catdir($::opt_vardir, "stress");
51
 
  
52
 
  #Clean up stress dir 
53
 
  if ( -d $stress_basedir )
54
 
  {
55
 
    rmtree($stress_basedir);
56
 
  }
57
 
  mkpath($stress_basedir);
58
 
 
59
 
  if ($::opt_stress_suite ne 'main' && $::opt_stress_suite ne 'default' )
60
 
  {
61
 
    $stress_suitedir=File::Spec->catdir($::glob_drizzle_test_dir, "suite", 
62
 
                                         $::opt_stress_suite);
63
 
  }
64
 
  else
65
 
  {
66
 
    $stress_suitedir=$::glob_drizzle_test_dir;
67
 
  }
68
 
 
69
 
  if ( -d $stress_suitedir )
70
 
  {
71
 
    #$stress_suite_t_dir=File::Spec->catdir($stress_suitedir, "t");
72
 
    #$stress_suite_r_dir=File::Spec->catdir($stress_suitedir, "r");    
73
 
    #FIXME: check dirs above for existence to ensure that test suite 
74
 
    #       contains tests and results dirs
75
 
  }
76
 
  else
77
 
  {
78
 
    dtr_error("Specified test suite $::opt_stress_suite doesn't exist");
79
 
  }
80
 
 
81
 
  if ( @::opt_cases )
82
 
  {
83
 
    $::opt_stress_test_file=File::Spec->catfile($stress_basedir, "stress_tests.txt");
84
 
    open(STRESS_FILE, ">$::opt_stress_test_file");
85
 
    print STRESS_FILE join("\n",@::opt_cases),"\n";
86
 
    close(STRESS_FILE);
87
 
  }
88
 
  elsif ( $::opt_stress_test_file )
89
 
  {
90
 
    $::opt_stress_test_file=File::Spec->catfile($stress_suitedir, 
91
 
                                              $::opt_stress_test_file);
92
 
    if ( ! -f $::opt_stress_test_file )
93
 
    {
94
 
      dtr_error("Specified file $::opt_stress_test_file with list of tests does not exist\n",
95
 
                "Please ensure that file exists and has proper permissions");
96
 
    }
97
 
  }
98
 
  else
99
 
  {
100
 
    $::opt_stress_test_file=File::Spec->catfile($stress_suitedir, 
101
 
                                              "stress_tests.txt");
102
 
    if ( ! -f $::opt_stress_test_file )
103
 
    {
104
 
      dtr_error("Default file $::opt_stress_test_file with list of tests does not exist\n",
105
 
          "Please use --stress-test-file option to specify custom one or you can\n",
106
 
          "just specify name of test for testing as last argument in command line");
107
 
 
108
 
    }    
109
 
  }
110
 
 
111
 
  if ( $::opt_stress_init_file )
112
 
  {
113
 
    $::opt_stress_init_file=File::Spec->catfile($stress_suitedir, 
114
 
                                              $::opt_stress_init_file);
115
 
    if ( ! -f $::opt_stress_init_file )
116
 
    {
117
 
      dtr_error("Specified file $::opt_stress_init_file with list of tests does not exist\n",
118
 
                "Please ensure that file exists and has proper permissions");
119
 
    }
120
 
  }
121
 
  else
122
 
  {
123
 
    $::opt_stress_init_file=File::Spec->catfile($stress_suitedir, 
124
 
                                              "stress_init.txt");
125
 
    if ( ! -f $::opt_stress_init_file )
126
 
    {
127
 
      $::opt_stress_init_file='';
128
 
    }
129
 
  }  
130
 
  
131
 
  if ( $::opt_stress_mode ne 'random' && $::opt_stress_mode ne 'seq' )
132
 
  {
133
 
    dtr_error("You specified wrong mode $::opt_stress_mode for stress test\n",
134
 
              "Correct values are 'random' or 'seq'");
135
 
  }
136
 
 
137
 
  dtr_init_args(\$args);
138
 
  
139
 
  dtr_add_arg($args, "--server-socket=%s", $::master->[0]->{'path_sock'});
140
 
  dtr_add_arg($args, "--server-user=%s", $::opt_user);
141
 
  dtr_add_arg($args, "--server-database=%s", "test");  
142
 
  dtr_add_arg($args, "--stress-suite-basedir=%s", $::glob_drizzle_test_dir);  
143
 
  dtr_add_arg($args, "--suite=%s", $::opt_stress_suite);
144
 
  dtr_add_arg($args, "--stress-tests-file=%s", $::opt_stress_test_file);      
145
 
  dtr_add_arg($args, "--stress-basedir=%s", $stress_basedir);
146
 
  dtr_add_arg($args, "--server-logs-dir=%s", $stress_basedir);
147
 
  dtr_add_arg($args, "--stress-mode=%s", $::opt_stress_mode);
148
 
  dtr_add_arg($args, "--drizzletest=%s", $::exe_drizzletest);
149
 
  dtr_add_arg($args, "--threads=%s", $::opt_stress_threads);
150
 
  dtr_add_arg($args, "--verbose");
151
 
  dtr_add_arg($args, "--cleanup");
152
 
  dtr_add_arg($args, "--log-error-details");
153
 
  dtr_add_arg($args, "--abort-on-error");
154
 
 
155
 
  if ( $::opt_stress_init_file )
156
 
  {
157
 
    dtr_add_arg($args, "--stress-init-file=%s", $::opt_stress_init_file);
158
 
  }
159
 
 
160
 
  if ( !$::opt_stress_loop_count && !$::opt_stress_test_count &&
161
 
       !$::opt_stress_test_duration )
162
 
  {
163
 
    #Limit stress testing with 20 loops in case when any limit parameter 
164
 
    #was specified 
165
 
    $::opt_stress_test_count=20;
166
 
  }
167
 
 
168
 
  if ( $::opt_stress_loop_count )
169
 
  {
170
 
    dtr_add_arg($args, "--loop-count=%s", $::opt_stress_loop_count);
171
 
  }
172
 
 
173
 
  if ( $::opt_stress_test_count )
174
 
  {
175
 
    dtr_add_arg($args, "--test-count=%s", $::opt_stress_test_count);
176
 
  }
177
 
 
178
 
  if ( $::opt_stress_test_duration )
179
 
  {
180
 
    dtr_add_arg($args, "--test-duration=%s", $::opt_stress_test_duration);
181
 
  }
182
 
 
183
 
  #Run stress test
184
 
  dtr_run("$::glob_drizzle_test_dir/drizzle-stress-test.pl", $args, "", "", "", "");
185
 
  if ( ! $::glob_use_embedded_server )
186
 
  {
187
 
    stop_all_servers();
188
 
  }
189
 
}
190
 
 
191
 
1;