~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/randgen/gendata.pl

  • Committer: Mark Atwood
  • Date: 2011-10-08 04:50:51 UTC
  • mfrom: (2430.1.1 rf)
  • Revision ID: me@mark.atwood.name-20111008045051-6ha1qiy7k2a9c3jv
Tags: 2011.10.27
mergeĀ lp:~olafvdspek/drizzle/refactor2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
 
3
 
# Copyright (C) 2008-2009 Sun Microsystems, Inc. All rights reserved.
4
 
# Use is subject to license terms.
5
 
#
6
 
# This program is free software; you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation; version 2 of the License.
9
 
#
10
 
# This program is distributed in the hope that it will be useful, but
11
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
 
# General Public License for more details.
14
 
#
15
 
# You should have received a copy of the GNU General Public License
16
 
# along with this program; if not, write to the Free Software
17
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18
 
# USA
19
 
 
20
 
$| = 1;
21
 
use strict;
22
 
use lib 'lib';
23
 
use lib "$ENV{RQG_HOME}/lib";
24
 
use Carp;
25
 
use GenTest;
26
 
use GenTest::Constants;
27
 
use GenTest::App::Gendata;
28
 
use Getopt::Long;
29
 
 
30
 
my ($spec_file, $config_file, $debug, $engine, $help, $dsn, $rows, $varchar_len,
31
 
    $views, $server_id, $seed);
32
 
 
33
 
my $opt_result = GetOptions(
34
 
        'help'  => \$help,
35
 
        'config:s' => \$config_file, ## Kept for backward compatability.
36
 
        'spec:s' => \$spec_file,
37
 
        'debug' => \$debug,
38
 
        'dsn:s' => \$dsn,
39
 
        'seed=s' => \$seed,
40
 
        'engine:s' => \$engine,
41
 
        'rows=i' => \$rows,
42
 
        'views' => \$views,
43
 
        'varchar-length=i' => \$varchar_len,
44
 
        'server-id=i' > \$server_id
45
 
);
46
 
 
47
 
if (defined $config_file) {
48
 
    carp("--config is deprecated. Use --spec");
49
 
    $spec_file = $config_file if not defined $spec_file;
50
 
}
51
 
 
52
 
help() if !$opt_result || $help || not defined $spec_file;
53
 
 
54
 
exit(1) if !$opt_result;
55
 
 
56
 
 
57
 
my $app = GenTest::App::Gendata->new(spec_file => $spec_file,
58
 
                                     debug => $debug,
59
 
                                     dsn => $dsn,
60
 
                                     seed => $seed,
61
 
                                     engine => $engine,
62
 
                                     rows => $rows,
63
 
                                     views => $views,
64
 
                                     varchar_length => $varchar_len,
65
 
                                     server_id => $server_id);
66
 
 
67
 
 
68
 
my $status = $app->run();
69
 
 
70
 
exit $status;
71
 
 
72
 
sub help {
73
 
 
74
 
        print <<EOF
75
 
$0 - Random Data Generator. Options:
76
 
 
77
 
        --debug         : Turn on debugging for additional output
78
 
        --dsn           : DBI resource to connect to
79
 
        --engine        : Table engine to use when creating tables with gendata (default: no ENGINE for CREATE TABLE)
80
 
        --spec          : Specification ZZ file describing the data (see RandomDataGenerator in MySQL Wiki)
81
 
        --rows          : Number of rows to generate for each table, unless specified in the ZZ file
82
 
        --seed          : Seed to PRNG. if --seed=time the current time will be used. (default 1)
83
 
        --views         : Generate views
84
 
        --varchar-length: maximum length of strings (deault 1)
85
 
        --help          : This help message
86
 
EOF
87
 
        ;
88
 
        exit(1);
89
 
}