~giuseppe-maxia/mysql-sandbox/mysql-sandbox-3

« back to all changes in this revision

Viewing changes to lib/MySQL/Sandbox/Scripts.pm

  • Committer: g.maxia at gmail
  • Date: 2015-08-02 15:15:16 UTC
  • Revision ID: g.maxia@gmail.com-20150802151516-3blys2q56v788sc1
- Added default name for relay log files.
- Added 'show_binlog' script in each sandbox
- improved tests by getting all the version components from a single function call
- Added GTID initialization options for MySQL 5.6, 5.7, and MariaDB 10
- Added GTID enabling test for MySQL 5.6 and 5.7
- added and improved more tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    );
18
18
our @EXPORT = @EXPORT_OK;
19
19
 
20
 
our $VERSION="3.0.61";
 
20
our $VERSION="3.0.62";
21
21
 
22
22
our @MANIFEST = (
23
23
'clear.sh',
41
41
'grants.mysql',
42
42
'grants_5_7_6.mysql',
43
43
'json_in_db.sh',
 
44
'show_binlog.sh',
 
45
'add_option.sh',
44
46
'# INSTALL FILES',
45
47
'sandbox_action.pl',
46
48
'test_replication.sh',
2027
2029
 
2028
2030
TEST_REPLICATION
2029
2031
 
 
2032
    'show_binlog.sh' => <<'SHOW_BINLOG',
 
2033
#!_BINBASH_
 
2034
__LICENSE__
 
2035
 
 
2036
curdir="_HOME_DIR_/_SANDBOXDIR_"
 
2037
cd $curdir
 
2038
 
 
2039
if [ ! -d ./data ]
 
2040
then
 
2041
    echo "$curdir/data not found"
 
2042
    exit 1
 
2043
fi
 
2044
 
 
2045
pattern=$1
 
2046
[ -z "$pattern" -o "$pattern" == 'N' ] && pattern='[0-9]*'
 
2047
if [ "$pattern" == "-h" -o "$pattern" == "--help" -o "$pattern" == "-help" -o "$pattern" == "help" ]
 
2048
then
 
2049
    echo "# Usage: $0 [BINLOG_PATTERN] [pager] "
 
2050
    echo "# Where BINLOG_PATTERN is a number, or part of a number used after 'mysql-bin'"
 
2051
    echo "# (The default is '[0-9]*]': you can use 'N' to confirm the default pattern)"
 
2052
    echo "# The default 'pager' is 'less'. You may use 'vim -', or 'grep GTID_NEXT', or whatever is right"
 
2053
    echo "# examples:" 
 
2054
    echo "#          ./show_binlog 000012 'vim -'"
 
2055
    echo "#          ./show_binlog N 'grep -i \"CREATE TABLE\"'"
 
2056
    exit 0
 
2057
fi
 
2058
set -x
 
2059
last_binlog=$(ls -lotr data/mysql-bin.$pattern | tail -n 1 | awk '{print $NF}')
 
2060
 
 
2061
if [ -z "$last_binlog" ]
 
2062
then
 
2063
    echo "No binlog found in $curdir/data"
 
2064
    exit 1
 
2065
fi
 
2066
 
 
2067
pager="$2"
 
2068
 
 
2069
if [ -z "$pager" ] 
 
2070
then
 
2071
    pager=less
 
2072
fi
 
2073
 
 
2074
(printf "#\n# using '$pager' with  $last_binlog\n#\n" ; ./my sqlbinlog $last_binlog ) | $pager
 
2075
 
 
2076
SHOW_BINLOG
 
2077
 
 
2078
    'add_option.sh' => <<'ADD_OPTION',
 
2079
#!_BINBASH_
 
2080
__LICENSE__
 
2081
 
 
2082
curdir="_HOME_DIR_/_SANDBOXDIR_"
 
2083
cd $curdir
 
2084
 
 
2085
if [ -z "$*" ]
 
2086
then
 
2087
    echo "# Syntax $0 options-for-my.cnf [more options] "
 
2088
    exit
 
2089
fi
 
2090
 
 
2091
CHANGED=''
 
2092
for OPTION in $@
 
2093
do
 
2094
    option_exists=$(grep $OPTION ./my.sandbox.cnf)
 
2095
    if [ -z "$option_exists" ]
 
2096
    then
 
2097
        echo "$OPTION" >> my.sandbox.cnf
 
2098
        echo "# option '$OPTION' added to configuration file"
 
2099
        CHANGED=1
 
2100
    else
 
2101
        echo "# option '$OPTION' already exists configuration file"
 
2102
    fi
 
2103
done
 
2104
 
 
2105
if [ -n "$CHANGED" ]
 
2106
then
 
2107
    ./restart
 
2108
fi
 
2109
 
 
2110
ADD_OPTION
 
2111
 
2030
2112
);
2031
2113
 
2032
2114
# --- END SCRIPTS IN CODE ---
2033
2115
 
2034
2116
my $license_text = <<'LICENSE';
2035
2117
#    The MySQL Sandbox
2036
 
#    Copyright (C) 2006-2013 Giuseppe Maxia
 
2118
#    Copyright (C) 2006-2015 Giuseppe Maxia
2037
2119
#    Contacts: http://datacharmer.org
2038
2120
#
2039
2121
#    This program is free software; you can redistribute it and/or modify
2182
2264
 
2183
2265
Version 3.0
2184
2266
 
2185
 
Copyright (C) 2006-2013 Giuseppe Maxia
 
2267
Copyright (C) 2006-2015 Giuseppe Maxia
2186
2268
 
2187
2269
Home Page  http://launchpad.net/mysql-sandbox/
2188
2270