1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#
# Test exec and SQL during sandbox initialization
#
my $TEST_VERSION = $ENV{TEST_VERSION};
my ($version, $name_version) = get_bare_version($TEST_VERSION);
my $install_dir = 'msb_init_test';
my $install_port = 8001;
sub test_run
{
my ($stage, $command, $wanted) = @_;
ok_exec({
command => "make_sandbox $TEST_VERSION -- --no_confirm --sandbox_directory=$install_dir "
. "--sandbox_port=$install_port "
. "--$stage='$command' ",
expected => 'sandbox server started' ,
msg => 'sandbox server started',
});
for my $w (@{$wanted})
{
ok( $ENV{EXEC_RESULT} =~ /$w->{expected}/, "$w->{comment}" );
}
ok_exec( {
command => "sbtool -o delete -s $sandbox_home/$install_dir ",
expected => 'has been removed',
msg => "$install_dir removed"
});
}
my @tests = (
{
stage => 'pre_start_exec',
command => 'echo "<$EXEC_STAGE>"; ls -d $DB_DATADIR/*/',
wanted => [
{
expected => '<pre_start_exec>',
comment => 'Stage pre_start_exec detected'
},
{
expected => '/mysql/',
comment => 'directory /mysql/ found'
}
]
},
{
stage => 'pre_grants_exec',
command => 'echo "<$EXEC_STAGE>"; ls $DB_SOCKET; echo "<$DB_PORT>"' ,
wanted => [
{
expected => '<pre_grants_exec>',
comment => 'Stage pre_grants_exec detected'
},
{
expected => "mysql.*$install_port.sock",
comment => 'socket file found'
},
{
expected => "<$install_port>",
comment => "Port $install_port detected"
}
]
},
{
stage => 'post_grants_exec',
command => 'echo "<$EXEC_STAGE>";ls -l $DB_DATADIR/test',
wanted => [
{
expected => '<post_grants_exec>',
comment => 'Stage post_grants_exec detected'
},
{
expected => "/test",
comment => 'test directory found'
}
]
},
{
stage => 'pre_grants_sql',
command => 'select concat("<",count(*),">") from mysql.user where user like "_sandbox"',
wanted => [
{
expected => '<0>',
comment => 'pre_grants_sql: no users named "?sandbox" found'
},
]
},
{
stage => 'post_grants_sql',
command => 'select concat("<",count(*),">") from mysql.user where user like "_sandbox"',
wanted => [
{
expected => '<3>',
comment => 'pre_grants_sql: 3 users named "?sandbox" found'
},
]
}
);
for my $t (@tests)
{
test_run( $t->{stage}, $t->{command}, $t->{wanted});
}
|