当前位置: 首页 > 软件库 > 数据库相关 > >

mysql-sandbox

授权协议 Apache-2.0 License
开发语言 C/C++
所属分类 数据库相关
软件类型 开源软件
地区 不详
投 递 者 伯逸明
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

NAME

MySQL::Sandbox - Quickly installs one or more MySQL servers (or forks) in the same host, either standalone or in groups

SYNOPSIS

make_sandbox /path/to/MySQL-VERSION.tar.gz

export SANDBOX_BINARY=$HOME/opt/mysql
make_sandbox --export_binaries /path/to/MySQL-VERSION.tar.gz

make_sandbox $SANDBOX_BINARY/VERSION

make_sandbox VERSION

WARNING

This project is replaced by dbdeployer, which is now GA. It can already support all MySQL-Sandbox features, plus many new ones. This project is now archived and will not be updated.

PURPOSE

This package is a sandbox for testing features under any version ofMySQL from 3.23 to 8.0 (and any version of MariaDB.)

It will install one node under your home directory, and it willprovide some useful commands to start, use and stop this sandbox.

With this package you can play with new MySQL releases without needingto use other computers. The server installed in the sandbox usenon-standard data directory, ports and sockets, so they won'tinterfere with existing MYSQL installations.

INSTALLATION

MySQL Sandbox installs as a normal Perl Module. Since its purpose is toinstall side servers in user space, you can install it as root (default)or as an unprivileged user. In this case, you need to set the PERL5LIBand PATH variables.

# as root
perl Makefile.PL 
make
make test
make install

# as normal user
export PATH=$HOME/usr/local/bin:$PATH
export PERL5LIB=$HOME/usr/local/lib/perl5/site_perl/x.x.x
perl Makefile.PL PREFIX=$HOME/usr/local
make
make test
make install

Notice that PERL5LIB could be different in various operating systems. If you opt for this installation method, you must adapt it to your operating system path and Perl version.

See also under "TESTING" for more options before running 'make test'

MAKING SANDBOXES

Single server sandbox

The easiest way to make a sandbox is

  1. download the sandbox package and install it as instructed above

  2. download a MySQL binary tarball

  3. run this command

     $ make_sandbox  /path/to/mysql-X.X.XX-osinfo.tar.gz
    

That's all it takes to get started. The Sandbox will ask you for confirmation, and then it will tell you where it has installed your server.

By default, the sandbox creates a new instance for you under

$SANDBOX_HOME/msb_X_X_XX

Making a replication sandbox

It's as easy as making a single sandbox

$ make_replication_sandbox /path/to/mysql-X.X.XX-osinfo.tar.gz

This will create a new instance of one master and two slaves

under $SANDBOX_HOME/rsandbox_X_X_XX

Circular replication

It requires an appropriate option when you start a replication sandbox

$ make_replication_sandbox --circular=4 /path/to/mysql-X.X.XX-osinfo.tar.gz

This will create a replication system with three servers connected by circular replication.A handy shortcut is --master_master, which will create a circular replication system of exactly two members.

Multiple sandboxes

You can create a group of sandboxes without any replication among its members.If you need three servers of the same version, you can use

$ make_multiple_sandbox /path/to/tarball 

If you need servers of different versions in the same group, you may like

$ make_multiple_custom_sandbox /path/to/tarball1 path/to/tarball2 /path/to/tb3 

Assuming that each tarball is from a different version, you will group three servers under one directory, with the handy sandbox scripts to manipulate them.

Creating a sandbox from source

If you want to create a sandbox from the code that you have just compiled, but you don't want to install, there is a script that makesa binary tarball for you and installs a sandbox in one go.

$ make_sandbox_from_source {SOURCE_DIRECTORY} {sandbox_type} [options]

The first parameters is the directory where you have successfully run "./configure && make".The second parameter is what kind of sandbox you want to create: One of the following:

* single
* multiple
* replication
* circular

You can then add all the options you need at the end.For example:

$ make_sandbox_from_source $HOME/build/5.0 single --export_binaries --check_port 

or

$ make_sandbox_from_source $HOME/build/5.0 replication --how_many_slaves=5

If you call this program several times from the same directory, it will check if the compiled binaries are newer than the extracted ones, and if they aren't, it will reuse the ones created during the previous run, thus saving time and CPU.

Creating a sandbox from already installed binaries

The script make_sandbox_from_installed tries to create a sandbox using already installed binaries.Since these binaries can be in several different places, the script creates a container with symbolic links, where the binaries (their links, actually) are arranged as MySQL Sandbox expects them to be.

To use this version, change directory to a place where you want to store this symbolic links container, and invoke

make_sandbox_from_installed X.X.XX [options]

where X.X.XX is the version number. You can then pass any options accepted by make_sandbox.

Defaults and shortcuts

If you use sandboxes often, instead of pointing to a tarball you can set a directory containing expanded tarballs.By default, the sandbox looks under $HOME/opt/mysql and /opt/mysql

The expanded tarballs must be named with the full version.e.g.

$HOME/opt/mysql/5.0.64 
/opt/mysql/5.1.24

If you have such an organization, then you can invoke every sandbox script with this abridged syntax:

make_sandbox 5.0.64
make_replication_sandbox 5.1.25
make_multiple_custom_sandbox 5.0.64 5.1.25

If you use some options frequently, it would make sense to add them to the default option file, which is $HOME/.msandboxrc

Fine tuning

Every sandbox script will give you additional information if you invoke itwith the "--help" option.

When creating a single sandbox, you can pass to the new server most any optionthat can be used in a my.cnf file, in addition to specific sandbox options.

Multiple and replication sandboxes, for example, accept a --how_many_slaves=Xor --how_many_nodes=X option, allowing you to create very large groups.

SANDBOX HOME

Unless you override the defaults, sandboxes are created inside adirectory that servers two purposes:

  • further isolates the sandboxes, and keep them under easy control if you are in the habit of creating many of them;
  • provides a set of handy super-commands, which can be passed to all the sandboxes. Running "$SANDBOX_HOME/stop_all" you will stop all servers of all sandboxes, single or groups, below that directory.

USING A SANDBOX

Change directory to the newly created one(default: $SANDBOX_HOME/msb_VERSION for single sandboxes)

The sandbox directory of the instance you just created containssome handy scripts to manage your server easily and in isolation.

  • start

  • restart

  • stop

    "./start", "./restart", and "./stop" do what their name suggests.start and restart accept parameters that are eventually passed to the server. e.g.:

      ./start --skip-innodb
    
      ./restart --event-scheduler=disabled
    
  • use

    "./use" calls the command line client with the appropriate parameters,

  • clear

    "./clear" stops the server and removes everything from the data directory, letting you ready to start from scratch.

  • multiple server sandbox

    On a replication sandbox, you have the same commands, with a "_all"suffix, meaning that you propagate the command to all the members.Then you have "./m" as a shortcut to use the master, "./s1" and "./s2"to access the slaves (and "s3", "s4" ... if you define more).

    In group sandboxes without a master slave relationship (circular replication and multiple sandboxes) the nodes can be accessed by ./n1, ./n2, ./n3, and so on.

    • start_all
    • restart_all
    • stop_all
    • use_all
    • clear_all
    • m
    • s1,s2

Database users

There are 2 database users installed by default:

+-----------------+-------------+-------------------------------+
|  user name      | password    | privileges                    |
+-----------------+-------------+-------------------------------+
|  root@localhost | msandbox    | all on *.* with grant option  |
|  msandbox@%     | msandbox    | all on *.*                    |
|  rsandbox@127.% | rsandbox    | REPLICATION SLAVE             |
|                 |             | (only replication sandboxes)  |
+-----------------+-------------+-------------------------------+

Ports and sockets

Ports are created from the server version.a 5.1.25 server will use port 5125, unless you override the default.Replicated and group sandboxes add a delta number to the versionfigure, to avoid clashing with single installations.

(note: ports can be overridden using -P option during install)

+--------+-----------------------------+
| port   | socket                      |
+--------+-----------------------------+
|  3310  | /tmp/mysql_sandbox3310.sock |
+--------+-----------------------------+

Searching for free ports

MySQL Sandbox uses a fairly reasonable system of default ports thatguarantees the usage of unused ports most of the times.If you are creating many sandboxes, however, especially if you wantseveral sandboxes using the same versions, collisions may happen.In these cases, you may ask for a port check before installing, thusmaking sure that your sandbox is really not conflicting with anything.

Single sandbox port checking

The default behavior when asking to install a sandbox over an existingone is to abort. If you specify the --force option, the old sandboxwill be saved as 'old_data' and a new one created.Instead, using the --check_port option, MySQL Sandbox searches for thefirst available unused port, and uses it. It will also create a nonconflicting data directory. For example

make_sandbox 5.0.79
# creates a sandbox with port 5079 under $SANDBOX_HOME/msb_5_0_79

A further call to the same command will be aborted unless you specifyeither --force or --check_port.

make_sandbox 5.0.79 -- --force
# Creates a sandbox with port 5079 under $SANDBOX_HOME/msb_5_0_79
# The contents of the previous data directory are saved as 'old_data'.

make_sandbox 5.0.79 -- --check_port
# Creates a sandbox with port 5080 under $SANDBOX_HOME/msb_5_0_79_a

make_sandbox 5.0.79 -- --check_port
# Creates a sandbox with port 5081 under $SANDBOX_HOME/msb_5_0_79_b

Notice that this option is disabled when you use a group sandbox (replication or multiple). Even if you set NODE_OPTIONS=--check_port, it won't be used, because every group sandbox invokes make_sandbox with the --no_check_port option.

Multiple sandbox port checking

When you create a multiple sandbox (make_replication_sandbox,make_multiple_sandbox, make_multiple_custom_sandbox) the default behavioris to overwrite the existing sandbox without asking for confirmation.The rationale is that a multiple sandbox is definitely more likely to be acreated only for testing purposes, and overwriting it should not be a problem.If you want to avoid overwriting, you can specify a different group name(--replication_directory --group_directory), but this will use thesame base port number, unless you specify --check_base_port.

make_replication_sandbox 5.0.79
# Creates a replication directory under $SANDBOX_HOME/rsandbox_5_0_79
# The default base_port is 7000

make_replication_sandbox 5.0.79
# Creates a replication directory under $SANDBOX_HOME/rsandbox_5_0_79
# overwriting the previous one. The default base port is still 7000

# WRONG
make_replication_sandbox --check_base_port 5.0.79
# Creates a replication directory under $SANDBOX_HOME/rsandbox_5_0_79
# overwriting the previous one. 

# WRONG
make_replication_sandbox --replication_directory=newdir 5.0.79
# Created a replication directory under $SANDBOX_HOME/newdir.
# The previous one is preserved, but the new sandbox does not start
# because of port conflict.

# RIGHT
make_replication_sandbox --replication_directory=newwdir \
   --check_base_port 5.0.79
# Creates a replication directory under $SANDBOX_HOME/newdir
# The previous one is preserved. No conflicts happen

Environment variables

All programs in the Sandbox suite recognize and use the following variables:

* HOME the user's home directory; ($HOME)
* SANDBOX_HOME the place where the sandboxes are going to be built. 
  ($HOME/sandboxes by default)
* USER the operating system user;
* PATH the execution path;
* if SBDEBUG if set, the programs will print debugging messages

In addition to the above, make_sandbox will use* SANDBOX_BINARY or BINARY_BASEthe directory containing the installation server binaries(default: $HOME/opt/mysql)

make_replication_sandbox will recognize the following* MASTER_OPTIONS additional options to be passed to the master* SLAVE_OPTIONS additional options to be passed to each slave* NODE_OPTIONS additional options to be passed to each node

The latter is also recognized bymake_multiple_custom_sandbox and make_multiple_sandbox

The test suite, test_sandbox, recognizes two environment variables

* TEST_SANDBOX_HOME, which sets the path where the sandboxes are
  installed, if the default $HOME/test_sb is not suitable. It is used
  when you test the package with 'make test'
* PRESERVE_TESTS. If set, this variable prevents the removal of test
  sandboxes created by test_sandbox. It is useful to inspect sandboxes
  if a test fails.

msb - the Sandbox shortcut

When you have many sandboxes, even the simple exercise of typing the path to the appropriate 'use' script can be tedious and seemingly slow.

If saving a few keystrokes is important, you may consider using msb, the sandbox shortcut.You invoke 'msb' with a version number, without dots or underscores. The shortcut script will try its best at finding the right directory.

$ msb 5135
# same as calling 
# $SANDBOX_HOME/msb_5_1_35/use

Every option that you use after the version is passed to the 'use' script.

$ msb 5135 -e "SELECT VERSION()"
# same as calling 
# $SANDBOX_HOME/msb_5_1_35/use -e "SELECT VERSION()"

Prepending a "r" to the version number indicates a replication sandbox. If the directory is found, the script will call the master.

$ msb r5135
# same as calling 
# $SANDBOX_HOME/rsandbox_5_1_35/m

To use a slave, use the corresponding number immediately after the version.

$ msb r5135 2
# same as calling 
# $SANDBOX_HOME/rsandbox_5_1_35/s2

Options for the destination script are added after the node indication.

$ msb r5135 2 -e "SELECT 1"
# same as calling 
# $SANDBOX_HOME/rsandbox_5_1_35/s2 -e "SELECT 1"

Similar to replication, you can call multiple sandboxes, using an 'm' before the version number.

$ msb m5135
# same as calling 
# $SANDBOX_HOME/multi_msb_5_1_35/n1

$ msb m5135 2
# same as calling 
# $SANDBOX_HOME/multi_msb_5_1_35/n2

If your sandbox has a non-standard name and you pass such name instead of a version, the script will attempt to open a single sandbox with that name.

$ msb testSB
# same as calling 
# $SANDBOX_HOME/testSB/use

If the identified sandbox is not active, the script will attempt to start it.

This shortcut script doesn't deal with any sandbox script other than the ones listed in the above examples.

But the msb can do even more. If you invoke it with a dotted version number, the script will run the appropriate make*sandbox script and then use the sandbox itself.

$ msb 5.1.35
# same as calling 
# make_sandbox 5.1.35 -- --no_confirm
# and then
# $SANDBOX_HOME/msb_5_1_35/use

It works for group sandboxes as well.

$ msb r5.1.35
# same as calling 
# make_replication_sandbox 5.1.35 
# and then
# $SANDBOX_HOME/rsandbox_5_1_35/m

And finally, it also does What You Expect when using a tarball instead of a version.

$ msb mysql-5.1.35-YOUR_OS.tar.gz
# creates and uses a single sandbox from this tarball

$ msb r mysql-5.1.35-YOUR_OS.tar.gz
# creates and uses a replication sandbox from this tarball

$ msb m mysql-5.1.35-YOUR_OS.tar.gz
# creates and uses a multiple sandbox from this tarball

Using a MySQL server has never been easier.

Custom commands during installation

Starting with version 3.1.07 the installation of each sandbox supports the execution of shell and SQL commands during the installation.You can use the following commands:

## SQL statements
* --pre_grants_sql=query : runs 'query' before loading the grants.
* --pre_grants_file=filename : runs SQL file 'filename' before loading the grants.
* --post_grants_sql=query : runs 'query' after the loading the grants.
* --post_grants_file=filename : runs SQL file 'filename' before loading the grants.
* --load_plugin=plugin[:plugin_file_name] : loads the given plugin

The output of the SQL commands is sent to standard output.If the option --no_show was selected, then the the client is called without options. If --no_show was not selected (default), then the client is called with -t -v, so that the output is shown in table format.

## Shell commands
* --pre_start_exec=command  : runs 'command' after the installation, before the server starts
* --pre_grants_exec=command : runs 'command' after the server starts, before loading the grants.
* --post_grants_exec=command : runs 'command' after the loading the grants.

For each shell call, the following variables are filled:

       SANDBOX_DIR   =  sandbox directory;
       BASEDIR       =  base directory for the sandbox binaries
       DB_DATADIR    =  data directory
       MY_CNF        =  configuration file
       DB_PORT       =  database port
       DB_USER       =  database user
       DB_PASSWORD   =  database password
       DB_SOCKET     =  database socket
       MYSQL_VERSION =  MySQL version (e.g. 5.7.12)
       MYSQL_MAJOR   =  Major part of the version (e.g 5)
       MYSQL_MINOR   =  Minor part of the version (e.g 7)
       MYSQL_REV     =  Revision part of the version (e.g 12)
       EXEC_STAGE    =  Stage of the execution (pre_start_exec, pre_grants_exec, post_grants_exec)

The order of execution during the installation is the following:

* server installation (mysql_install_db or mysqld --initialize)
    * pre_start_exec
* server start
    * pre_grants_exec
    * pre_grants_sql (includes load_plugin calls)
    * pre_grants_file
* load grants
    * post_grants_exec
    * post_grants_sql
    * post_grants_file

SBTool the Sandbox helper

The Sandbox Helper, sbtool, is a tool that allows administrative operationson already existing sandboxes. It does a number of important tasks that arenot available at creation time or that would require too much manual labor.

usage: sbtool [options] 
-o     --operation       (s) <> - what task to perform
     'info'     returns configuration options from a Sandbox
     'copy'     copies data from one Sandbox to another
     'ports'    lists ports used by the Sandbox
     'tree'     creates a replication tree
     'move'     moves a Sandbox to a different location
     'range'    finds N consecutive ports not yet used by the Sandbox
     'port'     Changes a Sandbox port
     'delete'   removes a sandbox completely
     'preserve' makes a sandbox permanent
     'unpreserve' makes a sandbox NOT permanent
     'plugin'   installs a given plugin
-s     --source_dir      (s) <> - source directory for move,copy
-d     --dest_dir        (s) <> - destination directory for move,copy
-n     --new_port        (s) <> - new port while moving a sandbox
-u     --only_used       (-) <> - for "ports" operation, shows only the used ones
-i     --min_range       (i) <5000> - minimum port when searching for available ranges
-x     --max_range       (i) <64000> - maximum port when searching for available ranges
-z     --range_size      (i) <10> - size of range when searching for available port range
-f     --format          (s) <text> - format for "ports" and "info"
     'perl'     fully structured information in Perl code
     'text'     plain text dump of requested information
-p     --search_path     (s) </Users/gmax/sandboxes> - search path for ports and info
-a     --all_info        (-) <> - print more info for "ports" operation
       --tree_nodes      (s) <> - description of the tree (x-x x x-x x|x x x|x x)
       --mid_nodes       (s) <> - description of the middle nodes (x x x)
       --leaf_nodes      (s) <> - description of the leaf nodes (x x|x x x|x x)
       --tree_dir        (s) <> - which directory contains the tree nodes
       --plugin          (s) <> - which plugin needs to be installed
       --plugin_file     (s) <> - which plugin template file should be used
-v     --verbose         (-) <> - prints more info on some operations
-h     --help            (-) <1> - this screen

sbtool - Informational options

sbtool -o info

Returns configuration options from a Sandbox (if specified) or from all sandboxesunder $SANDBOX_HOME (default).You can use --search_path to tell sbtool where to start.The return information is formatted as a Perl structure.

sbtool -o ports

Lists ports used by the Sandbox. Use --search_path to tell sbtool where tostart looking (default is $SANDBOX_HOME). You can also use the --format optionto influence the outcome. Currently supported are only 'text' and 'perl'.If you add the --only_used option, sbtool will return only the ports that arecurrently open.

sbtool -o range

Finds N consecutive ports not yet used by the Sandbox.It uses the same options used with 'ports' and 'info'. Additionally, you candefine the low and high boundaries by means of --min_range and --max_range.The size of range to search is 10 ports by default. It can be changedwith --range_size.

sbtool - modification options

sbtool -o port

Changes port to an existing Sandbox.This requires the options --source_dir and --new_port to complete the task.If the sandbox is running, it will be stopped.

sbtool -o copy

Copies data from one Sandbox to another.It only works on single sandboxes.It requires the --source_dir and --dest_dir options to complete the task.Both Source and destination directory must be already installed sandboxes. If anyof them is still running, it will be stopped. If both source and destination directorypoint to the same directory, the command is not performed.At the end of the operation, all the data in the source sandbox is copied tothe destination sandbox. Existing files will be overwritten. It is advisable, but notrequired, to run a "./clear" command on the destination directory before performingthis task.

sbtool -o move

Moves a Sandbox to a different location.Unlike 'copy', this operation acts on the whole sandbox, and can move both singleand multiple sandboxes.It requires the --source_dir and --dest_dir options to complete the task.If the destination directory already exists, the task is not performed. If the sourcesandbox is running, it will be stopped before performing the operation.After the move, all paths used in the sandbox scripts will be changed.

sbtool -o tree

Creates a replication tree, with one master, one or more intermediate level slaves,and one or more leaf node slaves for each intermediate level.To create the tree, you need to create a multiple nodes sandbox (using make_multiple_sandbox)and then use sbtool with the following options:

* --tree_dir , containing the sandbox to convert to a tree
* --master_node, containing the node that will be master
* --mid_nodes, with a list of nodes for the intermediate level
* --leaf_nodes, with as many lists as how many mid_nodes
  Each list is separated from the next by a pipe sign (|).

Alternatively, you can use the --tree_nodes option to describe allthe tree at once.

For example, in a sandbox with 8 nodes, to define 1 as master node,nodes 2 and 3 as middle nodes, nodes 4, 5, and 6 as slaves of node 2and nodes 7 and 8 as slaves of node 3, you can use either of the following:

sbtool --tree_dir=/path/to/source \
   --master_node=1 \
   --mid_nodes='2 3'
   --leaf_nodes='4 5 6|7 8'

sbtool --tree_dir=/path/to/source \
   --tree_nodes='1 - 2 3 - 4 5 6|7 8' 

sbtool -o preserve

Makes a sandbox permanent.It requires the --source_dir option to complete the task.This command changes the 'clear' command within the requested sandbox,disabling its effects. The sandbox can't be erased using 'clear' or 'clear_all'.The 'delete' operation of sbtool will skip a sandbox that has been made permanent.

sbtool -o unpreserve

Makes a sandbox NOT permanent.It requires the --source_dir option to complete the task.This command cancels the changes made by a 'preserve' operation, making a sandboxerasable with the 'clear' command. The 'delete' operation can be performedsuccessfully on an unpreserved sandbox.

sbtool -o delete

Removes a sandbox completely.It requires the --source_dir option to complete the task.The requested sandbox will be stopped and then deleted completely.WARNING! No confirmation is asked!

sbtool -o plugin

Installs a given plugin into a sandbox.It requires the --source_dir and --plugin options to complete the task.The plugin indicated must be defined in the plugin template file, which is by default installed in $SANDBOX_HOME.Optionally, you can indicate a different plugin template with the --plugin_file option.By default, sbtool looks for the plugin template file in the sandbox directory that is the target of the installation. If it is not found there, it will look at $SANDBOX_HOME before giving up with an error.

Plugin template

The Plugin template is a Perl script containing the definition of the templates you want to install.Each plugin must have at least one target Server type, which could be one of all_servers, master, or slave. It is allowed to have more than one target types in the same plugin.

Each server type, in turn, must have at least one section named operation_sequence, an array reference containing the list of the actions to perform. Such actions can be regular scripts in each sandbox (start, stop, restart, clear) or one of the following template sections:

  • options_file

    It is the list of lines to add to an options file, under the [mysqld] label.

  • sql_commands

    It is a list of queries to execute. Every query must have appropriate semicolons as required. If no semicolon are found in the list, no queries are executed.

  • startup_file

    It is a file, named startup.sql, to be created under the data directory. It will contain the lines indicated in this section.You must remember to add a line 'init-file=startup.sql' to the options_file section.

TESTING

test_sandbox

The MySQL Sandbox comes with a test suite, called test_sandbox, which bydefault tests single,replicated, multiple, and custom installations of MySQLversion 5.0.77 and 5.1.32.You can override the version being tested by meansof command line options:

test_sandbox --versions=5.0.67,5.1.30

or you can specify a tarball

test_sandbox --versions=/path/to/mysql-tarball-5.1.31.tar.gz
test_sandbox --tarball=/path/to/mysql-tarball-5.1.31.tar.gz

You can also define which tests you want to run:

test_sandbox --tests=single,replication

Test isolation

The tests are not performed in the common $SANDBOX_HOME directory, buton a separate directory, which by default is $HOME/test_sb. To avoidinterferences, before the tests start, the application runs the$SANDBOX_HOME/stop_all command.The test directory is considered to exist purely for testing purposes, andit is erased several times while running the suite. Using this directoryto store valuable data is higly risky.

Tests during installation

When you build the package and run

make test

test_sandbox is called, in addition to many other tests in the ./t directory,and the tests are performed on a temporary directory under$INSTALLATION_DIRECTORY/t/test_sb. By default, version 5.6.26 is used.If this version is not found in $HOME/opt/mysql/, the test is skipped.You can override this option by setting the TEST_VERSION environment variable.

TEST_VERSION=5.7.9 make test
TEST_VERSION=$HOME/opt/mysql/5.7.9 make test
TEST_VERSION=/path/to/myswl-tarball-5.7.9.tar.gz make test

User defined tests

Starting with version 2.0.99, you can define your own tests, and run them by

$ test_sandbox --user_test=file_name

simplified test script

Inside your test file, you can define test actions.There are two kind of tests: shell and sql the test type is defined by a keyword followed by a colon.

The 'shell' test requires a 'command', which is passed to a shell.The 'expected' label is a string that you expect to find within the shell output.If you don't expect anything, you can just say "expected = OK", meaning that you willbe satisfied with a ZERO exit code reported by the operating system.The 'msg' is the description of the test that is shown to you when the test runs.

shell:
command  = make_sandbox 5.1.30 -- --no_confirm
expected = sandbox server started
msg      = sandbox creation

The 'sql' test requires a 'path', which is the place where the test engine expects to find a 'use' script.The 'query' is passed to the above mentioned script and the output is captured for further processing.The 'expected' parameter is a string that you want to find in the query output.The 'msg' parameter is like the one used with the 'shell' test.

sql:
path    = $SANDBOX_HOME/msb_5_1_30
query   = select version()
expected = 5.1.30
msg      = checking version

All strings starting with a $ are expanded to their corresponding environment variables.For example, if $SANDBOX_HOME is /home/sb/tests, the line

command  = $SANDBOX_HOME/msb_5_1_30/stop

will expand to:

command = /home/sb/tests/msb_5_1_30/stop

Perl based test scripts

In addition to the internal script language, you can also define perl scripts, which will be able to use the $sandbox_home global variable and to call routines defined inside test_sandbox. (see list below)To be identified as a Perl script, the user defined test must have the extension ".sb.pl"

  • ok_shell()

    The ok_shell function requires a hash reference containing the following labels:A 'command', which is passed to a shell.The 'expected' label is a string that you expect to find within the shell output.If you don't expect anything, you can just say "expected = OK", meaning that you willbe satisfied with a ZERO exit code reported by the operating system.The 'msg' is the description of the test that is shown to you when the test runs.

      ok_shell($hashref)
      ok_shell({
            command  => 'make_sandbox 5.1.30 --no_confirm',
            expected => 'sandbox server started',
            msg      => 'sandbox creation',
            })
    
  • ok_sql()

    The ok_sql function requires a hashref containing the following labels:A 'path', which is the place where the test engine expects to find a 'use' script.The 'query' is passed to the above mentioned script and the output is captured for further processing.The 'expected' parameter is a string that you want to find in the query output.The 'msg' parameter is like the one used with the ok_exec function.

  • get_bare_version()

    This function accepts one parameter, which can be either a MySQL tarball name or a version, and returns the bare version found in the input string.If called in list mode, it returns also a normalized version string with dots replaced by underscores.

      my $version = get_bare_version('5.1.30'); 
      # returns '5.1.30'
    
      my $version = get_bare_version('mysql-5.1.30-OS.tar.gz'); 
      # returns '5.1.30'
    
      my ($version,$dir_name) = get_bare_version('mysql-5.1.30-OS.tar.gz'); 
      # returns ('5.1.30', '5_1_30')
    
  • ok

    This is a low level function, similar to the one provided by Test::More. You should not need to call this one directly, unless you want to fine tuning a test.

    See the test script t/start_restart_arguments.sb.pl as an example

REQUIREMENTS

To use this package you need at least the following:

  • Linux or Mac OSX operating system (it may work in other *NIX OSs, but has not been tested)
  • A binary tarball of MySQL 3.23 or later
  • Perl 5.8.1 or later
  • Bash shell

COPYRIGHT

Version 3.1

Copyright (C) 2006-2018 Giuseppe Maxia

Home Page https://github.com/datacharmer

LEGAL NOTICE

Copyright 2006-2018 Giuseppe Maxia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
  • 什么是mysqlsandbox 一群海豚在属于自己的海滩上自由的玩耍,尽管只是一个方盒的大小,但是设备一样的齐全,同样可以玩的很开心,这就是我今天要说的——MySQL Sandbox2.0,3.0也将要推出。 MySQL Sandbox是一个非常简单快捷部署MySQL技术的一个工具套件,它可以让你在同一台机器上,更加快速的无干扰的去达到你的最终目的,比如,作为软件 测试人员只是要测试软件系统的良好

  • sandbox的安装可以使用github的方式,也可以使用cpan安装。 推荐使用cpan这种一键安装的。 # 安装mysqlsanbox yum install cpan perl-YAML perl-Test-Simple -ycpan MySQL::Sandboxecho 'export SANDBOX_AS_ROOT=1' >> /root/.bashrc source /root/.ba

  • 下载源码 源码下载 Github地址:https://github.com/alibaba/jvm-sandbox-repeater.git 源码下载下来后,可以通过源码目录下 /bin中的install-local.sh来生成repeater文件。 建议通过cmd命令执行,双击shell脚本执行,看不到报错信息。 执行完成后,会在用户根目录生成两个文件夹/sandbox,/.sandbox-mo

  • ##### 参考 https://github.com/datacharmer/mysql-sandbox ##### 必须下载一个二进制mysql wget https://github.com/datacharmer/mysql-sandbox/releases/download/3.2.13/MySQL-Sandbox-3.2.13.tar.gz yum install perl-ExtUt

  • 背景与导读 对 jvm-sandbox-repeater 做了有一段时间的学习和调研,看到目前 repeater 相关的文章比较少,所以将自己这段时间了解到的内容整理出来,分享给大家。 学习笔记分成入门使用篇和原理说明篇两个篇章。 入门使用篇主要是基于官方文档和 testerhome 其他的操作文档,对 repeater 的使用上的操作细节和配置做了补充说明,建议大家先按照官方的文档使用过了之后,

  • mysql --help参数详解 mysql --help mysql  Ver 14.14 Distrib 5.6.31, for Linux (x86_64) using  EditLine wrapper Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a regis

  • 使用MySQL沙盒快速设置数据库 介绍 建立MySQL快速“沙箱”实例有各种各样的原因。 您可以使用它们来测试不同类型的复制(例如主主或各种从属拓扑),根据不同版本的MySQL测试代码,或者在每个开发人员的基础上设置每个人拥有自己的数据库的MySQL实例运行在不同的端口,以便他们可以轻松地分解/设置数据库或进行模式更改,而不影响其他团队成员。 一个完美的工具来做这些事情很容易的是MySQL San

  • 什么是mysql sandbox? mysql sandbox 是一个用per语言写的一套mysql部署工具 http://sourceforge.net/projects/mysql-sandbox/ 通过mysql sandbix可以快速部署多种mysql使用环境包括: 单实例mysql 多实例mysql 单机mysql replication环境 mysqlsandbox主要用于测试环境的快

  • MySQL Sandbox是一个非常简单快捷部署MySQL技术的一个工具套件,它可以让你在同一台机器上,更加快速的无干扰的去达到你的最终目的,比如,作为软件测试人员只是要测试软件系统的良好性不需要在mysql的安装上纠缠过多,不需要对MySQL数据库有太多的经验;有的时候我们只是对新版本的一些特性感兴趣,尽可能快速结束安装部署,而是重点地去体验它的一些特性;可以使用sandbox最短时间部署我们需

  • sudo apt-get autoremove --purge mysql* 注意最后的*符号 历史代码 包括解决以下问题: >>> service mysql start Failed to start mysql.service: Unit mysql.service is masked. >>> sudo systemctl unmask mysql Removed /etc/systemd

  • 前言 经常看见新同学对于安装MySQL十分惧怕,这是因为不熟悉的缘故,确实源码编译比较麻烦,缺少各种依赖包也够折腾的。当然还有预编译包,但是对于新同学来说好像都挺麻烦的。当然有yum安装,但是我们需要多实例,测试多个版本就不方便了。那么我来说说比较简单的方法。使用沙箱环境。MySQL Sandbox是什么呢?简单来说就是一个沙盒,可以用于快速搭建mysql的环境,让我们可以不用费劲的去安装,或者编

 相关资料
  • 我有一个项目在玩!框架。我使用了MySQL5.1并添加了mysql-connector-依赖项,它工作得很好。 但是现在我需要将mysql升级到5.6,但是我找不到5.6的MySQL-Connector-。 在这种情况下,有人能提供一些走动吗?有没有可能有两个版本的mysql,其中一个用于项目,另一个用于我的其他需要,例如与数据库备份的集成,而这两个版本共享相同的数据库? 多谢.

  • 说明 常驻内存的程序在使用mysql时经常会遇到mysql gone away的错误,这个是由于程序与mysql的连接长时间没有通讯,连接被mysql服务端踢掉导致。本数据库类可以解决这个问题,当发生mysql gone away错误时,会自动重试一次。 依赖的扩展 该mysql类依赖pdo和pdo_mysql两个扩展,缺少扩展会报Undefined class constant 'MYSQL_A

  • cPanel的此功能允许远程服务器或Web应用程序访问您帐户上托管的数据库。 如果服务器或Web应用程序尝试访问您未提供访问权限的帐户上的数据库,则cPanel将不允许此主机访问您的数据库。 但是,如果您有一个应用程序,您希望授予其访问数据库的权限,则可以在此处添加其主机名或IP地址。 要访问此界面,请单击cPanel的Database Section中的Remote MySQL链接。 添加访问主

  • 一、索引 B+ Tree 原理 MySQL 索引 索引优化 索引的优点 索引的使用条件 二、查询性能优化 使用 Explain 进行分析 优化数据访问 重构查询方式 三、存储引擎 InnoDB MyISAM 比较 四、数据类型 整型 浮点数 字符串 时间和日期 五、切分 水平切分 垂直切分 Sharding 策略 Sharding 存在的问题 六、复制 主从复制 读写分离 参考资料 一、索引 B+

  • 我的sql数据库中有两个数据库表。第一个是个人表,另一个是付款明细。个人表中的自动递增id被用作付款明细的外键。我必须一次插入两个数据到这个表中。通常我应该插入数据到个人表中,并获得这一行的自动增量id,并将数据插入到付款数据表中。但是我有一些问题。 我无法使用我的sql SELECT查询获得自动增量IDeasily.because还有更多的colum要通过WHERE检查。 获取最后一个插入id不

  • 安装 我们将使用 Homebrew 安装 MySQL,同时也会安装 MySQL 的相关文件。 安装 MySQL: $ brew update # 这是一个好习惯 $ brew install mysql 在使用 MySQL 前,我们需要做一些设置: $ unset TMPDIR $ mkdir /usr/local/var $ mysql_install_db --verbose --user=`