~johnemb/randgen/xml-report

« back to all changes in this revision

Viewing changes to lib/GenTest/Server/ReplMySQLd.pm

  • Committer: John H. Embretsen
  • Date: 2010-04-08 13:28:06 UTC
  • mfrom: (140.20.39 lp-randgen)
  • Revision ID: john.embretsen@sun.com-20100408132806-vqufmjdcxqjws95j
XML: Merge in post-merge fixes and latest changes from lp:randgen. Revno 386 2010-04-08

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
use GenTest;
24
24
use GenTest::Constants;
25
25
use GenTest::Server::MySQLd;
26
 
use if windows(), Win32::Process;
 
26
use if osWindows(), Win32::Process;
27
27
use Time::HiRes;
28
28
 
29
29
use strict;
47
47
sub new {
48
48
    my $class = shift;
49
49
 
50
 
    my $self = $class->SUPER::new({'basedir' => REPLMYSQLD_BASEDIR,
 
50
    my $self = $class->SUPER::new({'master' => REPLMYSQLD_MASTER,
 
51
                                   'slave' => REPLMYSQLD_SLAVE,
 
52
                                   'basedir' => REPLMYSQLD_BASEDIR,
51
53
                                   'master_vardir' => REPLMYSQLD_MASTER_VARDIR,
52
54
                                   'master_port' => REPLMYSQLD_MASTER_PORT,
53
55
                                   'slave_vardir' => REPLMYSQLD_SLAVE_VARDIR,
58
60
                                   'valgrind' => REPLMYSQLD_VALGRIND,
59
61
                                   'valgrind_options', REPLMYSQLD_VALGRIND_OPTIONS},@_);
60
62
    
61
 
    if (not defined $self->[REPLMYSQLD_MASTER_PORT]) {
62
 
        $self->[REPLMYSQLD_MASTER_PORT] = GenTest::Server::MySQLd::MYSQLD_DEFAULT_PORT;
63
 
    }
64
 
    
65
 
    if (not defined $self->[REPLMYSQLD_SLAVE_PORT]) {
66
 
        $self->[REPLMYSQLD_SLAVE_PORT] = $self->[REPLMYSQLD_MASTER_PORT] + 2;        
67
 
    }
68
 
 
69
 
    if (not defined $self->[REPLMYSQLD_MODE]) {
70
 
        $self->[REPLMYSQLD_MODE] = 'default';
71
 
    }
72
 
    
73
 
    if (not defined $self->[REPLMYSQLD_MASTER_VARDIR]) {
74
 
        $self->[REPLMYSQLD_MASTER_VARDIR] = "mysql-test/var";
75
 
    }
76
 
    if (not defined $self->[REPLMYSQLD_SLAVE_VARDIR]) {
77
 
        my $varbase = $self->[REPLMYSQLD_MASTER_VARDIR];
78
 
        $varbase =~ s/(.*)\/$/\1/;
79
 
        $self->[REPLMYSQLD_SLAVE_VARDIR] = $varbase.'_slave';
80
 
    }
81
 
    
82
 
    my @master_options;
83
 
    push(@master_options, 
84
 
         "--server_id=1",
85
 
         "--log-bin=mysql-bin",
86
 
         "--report-host=127.0.0.1",
87
 
         "--report_port=".$self->[REPLMYSQLD_MASTER_PORT]);
88
 
    if (defined $self->[REPLMYSQLD_SERVER_OPTIONS]) {
 
63
    if (defined $self->master || defined $self->slave) {
 
64
        ## Repl pair defined from two predefined servers
 
65
 
 
66
        if (not (defined $self->master && defined $self->slave)) {
 
67
            croak("Both master and slave must be defined");
 
68
        }
 
69
        $self->master->addServerOptions(["--server_id=1",
 
70
                                         "--log-bin=mysql-bin",
 
71
                                         "--report-host=127.0.0.1",
 
72
                                         "--report_port=".$self->master->port]);
 
73
        $self->slave->addServerOptions(["--server_id=2",
 
74
                                        "--report-host=127.0.0.1",
 
75
                                        "--report_port=".$self->slave->port]);
 
76
    } else {
 
77
        ## Repl pair defined from parameters. The servers have the same basedir (is of the same version)
 
78
        if (not defined $self->[REPLMYSQLD_MASTER_PORT]) {
 
79
            $self->[REPLMYSQLD_MASTER_PORT] = GenTest::Server::MySQLd::MYSQLD_DEFAULT_PORT;
 
80
        }
 
81
    
 
82
        if (not defined $self->[REPLMYSQLD_SLAVE_PORT]) {
 
83
            $self->[REPLMYSQLD_SLAVE_PORT] = $self->[REPLMYSQLD_MASTER_PORT] + 2;        
 
84
        }
 
85
 
 
86
        if (not defined $self->[REPLMYSQLD_MODE]) {
 
87
            $self->[REPLMYSQLD_MODE] = 'default';
 
88
        }
 
89
    
 
90
        if (not defined $self->[REPLMYSQLD_MASTER_VARDIR]) {
 
91
            $self->[REPLMYSQLD_MASTER_VARDIR] = "mysql-test/var";
 
92
        }
 
93
        if (not defined $self->[REPLMYSQLD_SLAVE_VARDIR]) {
 
94
            my $varbase = $self->[REPLMYSQLD_MASTER_VARDIR];
 
95
            $varbase =~ s/(.*)\/$/\1/;
 
96
            $self->[REPLMYSQLD_SLAVE_VARDIR] = $varbase.'_slave';
 
97
        }
 
98
        
 
99
        my @master_options;
89
100
        push(@master_options, 
90
 
             @{$self->[REPLMYSQLD_SERVER_OPTIONS]});
91
 
    }
92
 
 
93
 
 
94
 
    $self->[REPLMYSQLD_MASTER] = 
95
 
        GenTest::Server::MySQLd->new(basedir => $self->basedir,
96
 
                                     vardir => $self->[REPLMYSQLD_MASTER_VARDIR],
97
 
                                     port => $self->[REPLMYSQLD_MASTER_PORT],
98
 
                                     server_options => \@master_options,
99
 
                                     start_dirty => $self->[REPLMYSQLD_START_DIRTY],
100
 
                                     valgrind => $self->[REPLMYSQLD_VALGRIND],
101
 
                                     valgrind_options => $self->[REPLMYSQLD_VALGRIND_OPTIONS]);
102
 
    
103
 
    if (not defined $self->master) {
104
 
        croak("Could not create master");
105
 
    }
106
 
    
107
 
    my @slave_options;
108
 
    push(@slave_options, 
109
 
         "--server_id=2",
110
 
         "--report-host=127.0.0.1",
111
 
         "--report_port=".$self->[REPLMYSQLD_SLAVE_PORT]);
112
 
    if (defined $self->[REPLMYSQLD_SERVER_OPTIONS]) {
 
101
             "--server_id=1",
 
102
             "--log-bin=mysql-bin",
 
103
             "--report-host=127.0.0.1",
 
104
             "--report_port=".$self->[REPLMYSQLD_MASTER_PORT]);
 
105
        if (defined $self->[REPLMYSQLD_SERVER_OPTIONS]) {
 
106
            push(@master_options, 
 
107
                 @{$self->[REPLMYSQLD_SERVER_OPTIONS]});
 
108
        }
 
109
        
 
110
        
 
111
        $self->[REPLMYSQLD_MASTER] = 
 
112
            GenTest::Server::MySQLd->new(basedir => $self->[REPLMYSQLD_BASEDIR],
 
113
                                         vardir => $self->[REPLMYSQLD_MASTER_VARDIR],
 
114
                                         port => $self->[REPLMYSQLD_MASTER_PORT],
 
115
                                         server_options => \@master_options,
 
116
                                         start_dirty => $self->[REPLMYSQLD_START_DIRTY],
 
117
                                         valgrind => $self->[REPLMYSQLD_VALGRIND],
 
118
                                         valgrind_options => $self->[REPLMYSQLD_VALGRIND_OPTIONS]);
 
119
        
 
120
        if (not defined $self->master) {
 
121
            croak("Could not create master");
 
122
        }
 
123
        
 
124
        my @slave_options;
113
125
        push(@slave_options, 
114
 
             @{$self->[REPLMYSQLD_SERVER_OPTIONS]});
115
 
    }
116
 
    
117
 
    
118
 
    $self->[REPLMYSQLD_SLAVE] = 
119
 
        GenTest::Server::MySQLd->new(basedir => $self->basedir,
120
 
                                     vardir => $self->[REPLMYSQLD_SLAVE_VARDIR],
121
 
                                     port => $self->[REPLMYSQLD_SLAVE_PORT],
122
 
                                     server_options => \@slave_options,
123
 
                                     start_dirty => $self->[REPLMYSQLD_START_DIRTY],
124
 
                                     valgrind => $self->[REPLMYSQLD_VALGRIND],
125
 
                                     valgrind_options => $self->[REPLMYSQLD_VALGRIND_OPTIONS]);
126
 
    
127
 
    if (not defined $self->slave) {
128
 
        $self->master->stopServer;
129
 
        croak("Could not create slave");
 
126
             "--server_id=2",
 
127
             "--report-host=127.0.0.1",
 
128
             "--report_port=".$self->[REPLMYSQLD_SLAVE_PORT]);
 
129
        if (defined $self->[REPLMYSQLD_SERVER_OPTIONS]) {
 
130
            push(@slave_options, 
 
131
                 @{$self->[REPLMYSQLD_SERVER_OPTIONS]});
 
132
        }
 
133
        
 
134
        
 
135
        $self->[REPLMYSQLD_SLAVE] = 
 
136
            GenTest::Server::MySQLd->new(basedir => $self->[REPLMYSQLD_BASEDIR],
 
137
                                         vardir => $self->[REPLMYSQLD_SLAVE_VARDIR],
 
138
                                         port => $self->[REPLMYSQLD_SLAVE_PORT],
 
139
                                         server_options => \@slave_options,
 
140
                                         start_dirty => $self->[REPLMYSQLD_START_DIRTY],
 
141
                                         valgrind => $self->[REPLMYSQLD_VALGRIND],
 
142
                                         valgrind_options => $self->[REPLMYSQLD_VALGRIND_OPTIONS]);
 
143
        
 
144
        if (not defined $self->slave) {
 
145
            $self->master->stopServer;
 
146
            croak("Could not create slave");
 
147
        }
130
148
    }
131
149
    
132
150
    return $self;
133
151
}
134
152
 
135
 
sub basedir {
136
 
    return $_[0]->[REPLMYSQLD_BASEDIR];
137
 
}
138
 
 
139
153
sub master {
140
154
    return $_[0]->[REPLMYSQLD_MASTER];
141
155
}