lp://staging/~percona-toolkit-dev/percona-toolkit/portable-test-suite

Created by Brian Fraser and last modified

Executive summary:

OptionParser, Daemon, DSNParser:
 * Minor changes for portability

PerconaTest.pm had a seasonal cleanup:
 * A lot of functions were either unused, or used by just one file -- so they were either removed, merged into other functions, or phased out of PerconaTest and into the file that needed them.
 * no_diff() in particular saw a large change -- most of it's options (sed, sort, trf, etc) were used only once or twice, and were undocumented. Now there's two transformation options: transform_sample and transform_result. However, it also adds a new option, cmd_is_file, meaning that the passed string is actually a filename and no_diff should just diff/apply the transforms then diff off that directly, without the need to call anything else. A large amount of no_diff uses were jumping through hoops because this was missing.
 * Some new exports: touch(), which replaces `touch $file`, remove_tree(), which replaces `rm -rf $dir`, make_path(), which replaces and enhaces `mkdir $dir`, and tempfile(). The last three, besides being exported for convenience, also work around some annoying bugs/behavior in old versions of File::Temp and File::Path.
 * cmd_output(), which replaces most backtick calls throughout the test suite. Think of it as a shelling out counterpart to output().

Nearly all of sandbox/ has been revamped:
 * start/stop-sandbox are now deprecated (you can use $sandbox_obj->stop_sandbox(...) to get the same effect, more on Sandbox later)
 * test-env is now in Perl and uses Sandbox.
 * You can use 'test-env start cluster' to start master/slave1/slave2 as a cluster.
 * load-sakila-db is gone, but you can use $sandbox_obj->load_sakila_db() to get the same effect.
 * use, start, stop and the version-specific config files are gone. They ar generated by $sandbox_obj->start_sandbox(...) now.

Sandbox.pm:
 * Largest changes. Sandbox.pm is now just a factory that returns a Sandbox plugin object. By default uses Sandbox::MySQL, but other plugins can be specified by passing a plugin => ... argument to new.

Sandbox::MySQL:
 * Actually contains only a bit of the functionality; the most interesting bits are implemented by it's three roles, described below
 * Six attributes: ->basedir() (PERCONA_SANDBOX_BASEDIR or File::Spec->tmpdir()), ->trunk() (PERCONA_TOOLKIT_BRANCH), ->sandbox() (PERCONA_TOOLKIT_SANDBOX), ->sandbox_user() and ->sandbox_pass().
 * An important bit of new functionality is ->register_server($server_name [, $port]). Registered servers are saved to disk, so you can start a server in one run and end it on another -- and more importantly, you can register and start any number of servers, and ->leftover_servers() will report them as being left open. The counterpart to ->register_server is ->remove_server($name)
 * Provides a lot of convenience functions: pid_file_for, socket_file_for, pid_for, port_for, registered_servers, get_executable, base_dir_for, config_file_for, genlog, dsn_for
 * ->use() and ->load_file() incompatible changes

Sandbox::MySQL::Role::Servers:
 * ->start_server($server_name) provides the same functionality that /tmp/PORT/start used to provide
 * ->stop_server($server_name) same as above, but for stop
 * ->kill_server($server_name) is how test-env kill is implemented.
 * ->server_is_alive($server_name) implements a portable 'mysqladmin ping'

Sandbox::MySQL::Role::Sandboxes:
 * ->start_sandbox() provides the functionality of sandbox/start-sandbox
 * ->stop_sandbox() provides the functionality of sandbox/stop-sandbox
 * ->set_as_slave($slave_name, $master_name) does exactly what it says on the tin.
 * ->_reset_sandbox() implements test-env reset
 * ->sandbox_version() implements test-env version, and also replaces $PerconaTest::sandbox_version
 * ->_call_mysql_upgrade_on() internal method used when start_sandbox is called with mysql_upgrade => 1, or when $ENV{MYSQL_UPGRADE} is true. This is needed when starting a MariaDB sandbox.
 * Additionally, this role has the methods that create the use/stop/start and config files. The first three are all in Perl now, to make them work everywhere.

Sandbox::MySQL::Role::Test:
 * Basically the dumping ground for things that we want Sandbox to have, but don't need when starting the sandbox itself. This is the only place that uses DSNParser -- everything else gets by with ->use()
 * ->wait_for_slaves(), ->verify_test_data(), ->get_dbh_for() and other methods using during the tests are here. Mostly untouched from the original Sandbox.pm
 * ->is_cluster_node()
 * ->verify_test_data() now uses ->get_checksum_tables(), since that bit of code was also used in util/checksum-test-data
 * Maybe we can put in util/checksum-test-data and util/check-load-data here?

Sandbox::Percona::XtraDB::Cluster:
 * A Sandbox plugin, and actually a subclass of Sandbox::MySQL. You can get one of these by doing Sandbox->new(plugin => "Percona::XtraDB::Cluster")
 * ->start_sandbox("cluster", cluster_size => ...) creates a cluster.

Test suite:
 * ...
 * catfile etc

Get this branch:
bzr branch lp://staging/~percona-toolkit-dev/percona-toolkit/portable-test-suite
Members of Percona Toolkit developers can upload to this branch. Log in for directions.

Branch merges

Related bugs

Related blueprints

Branch information

Recent revisions

467. By Brian Fraser

Minor speedup change in lib/Sandbox/MySQL/Role/Servers.pm: either wait for ibdata1, or for the server to respond to pings

466. By Brian Fraser

Sandboxes: Explicitly set tmpdir to the sandboxes' basedir, to avoid race conditions.

t/pt-slave-find/pt-slave-find.t occasionally fails if this isn't done,
as it hits this bug: http://bugs.mysql.com/bug.php?id=62055

465. By Brian Fraser

Remove diag()s that would have left empty lines

464. By Brian Fraser

PerconaTest: wait_for_table fix

I broke this in the most silly way.

463. By Brian Fraser

t/pt-table-checksum/basics.t: Typo from the MySQL 5.6 compat commit

462. By Brian Fraser

Minimal MySQL 5.6 support

461. By Brian Fraser <email address hidden>

Phase out version-specific config files in sandbox/servers.

460. By Brian Fraser <email address hidden>

Fix for 1063912: pt-table-checksum 2.1.4 miscategorizes Percona XtraDB Cluster-$

This commit adds two warnings; one for the case of master -> cluster,
and one for cluster1 -> cluster2.
The code that checks if two nodes belong to the same cluster
is "best effort" -- it will generally DTRT, but will fail in
the case that all of the following are true:
 * Both nodes have the same cluster name
 * They aren't in a master-slave relationship
 * Both nodes have a different wsrep_cluster_address,
   or both of their addresses aren't 'gcom://'; that is,
   they both aren't the first node of a cluster.

Which can happen in the case that
Cluster 1:
 node1 -> addr points to node2
 node2 -> addr points to node3
 node3 -> addr points to node1

Cluster 2:
 _node1 -> addr points to _node2
 _node2 -> addr points to _node3
 _node3 -> addr points to _node1

node1 is a master to _node1.
The dsns table has all of the nodes.

ptc will think that cluster 2 is only _node1, and cluster 1
is everything else. Further heuristics could check if we've
seen a second cluster and check the addresses from there,
but isn't currently worth the effort.

459. By Brian Fraser <email address hidden>

config file templates should only be created if there isn't a template in place already

458. By Brian Fraser <email address hidden>

Several fixes for starting clusters, including test-env start cluster

test-env start cluster starts master/slave1/slave2 as a PXC cluster.
This breaks nearly everywhere, at the moment.

Branch metadata

Branch format:
Branch format 7
Repository format:
Bazaar repository format 2a (needs bzr 1.16 or later)
Stacked on:
lp://staging/percona-toolkit/2.1
This branch contains Public information 
Everyone can see this information.