'
44 | "Here's another table:"
45 | ' | ')
48 |
49 | self.assertSoupEquals(
50 | markup,
51 | 'Here\'s another table:'
52 | ''
53 | ' |
')
54 |
55 | self.assertSoupEquals(
56 | "Foo |
"
57 | "Bar |
"
58 | "Baz |
")
59 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/bs4/tests/test_htmlparser.py:
--------------------------------------------------------------------------------
1 | """Tests to ensure that the html.parser tree builder generates good
2 | trees."""
3 |
4 | from bs4.testing import SoupTest, HTMLTreeBuilderSmokeTest
5 | from bs4.builder import HTMLParserTreeBuilder
6 |
7 | class HTMLParserTreeBuilderSmokeTest(SoupTest, HTMLTreeBuilderSmokeTest):
8 |
9 | @property
10 | def default_builder(self):
11 | return HTMLParserTreeBuilder()
12 |
13 | def test_namespaced_system_doctype(self):
14 | # html.parser can't handle namespaced doctypes, so skip this one.
15 | pass
16 |
17 | def test_namespaced_public_doctype(self):
18 | # html.parser can't handle namespaced doctypes, so skip this one.
19 | pass
20 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/check.py:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 | #
4 | # This program is free software; you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation; version 2 of the License.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program; if not, write to the Free Software
15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 | #
17 | import glob
18 | import os.path
19 | import sys
20 | import unittest
21 |
22 | if __name__ == '__main__':
23 | suite = unittest.TestSuite()
24 | for fname in glob.glob("unit_tests/test*.py"):
25 | base, ext = os.path.splitext(fname)
26 | name = '.'.join(base.split('/'))
27 | suite.addTest(unittest.defaultTestLoader.loadTestsFromName(name))
28 | result = unittest.TextTestRunner(verbosity=2).run(suite)
29 | if not result.wasSuccessful():
30 | sys.exit(1) # Results are printed above
31 |
32 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/doc/changes.rst:
--------------------------------------------------------------------------------
1 | :tocdepth: 2
2 |
3 | .. _changes:
4 |
5 | Changes in MySQL Utilities
6 | **************************
7 |
8 | .. include:: ../CHANGES.txt
9 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/doc/command/grep.rst:
--------------------------------------------------------------------------------
1 | ####################################################################
2 | :mod:`mysql.utilities.command.grep` --- Search Databases for Objects
3 | ####################################################################
4 |
5 | .. module:: mysql.utilities.command.grep
6 |
7 | This module provides utilities to search for objects on a server. The module
8 | defines a set of *object types* that can be searched by searching the
9 | *fields* of each object. The notion of an object field is
10 | very loosely defined and means any names occurring as part of the
11 | object definition. For example, the fields of a table include the table
12 | name, the column names, and the partition names (if it is a partitioned
13 | table).
14 |
15 |
16 | Constants
17 | ---------
18 |
19 | The following constants denote the object types that can be searched.
20 |
21 | .. data:: ROUTINE
22 | EVENT
23 | TRIGGER
24 | TABLE
25 | DATABASE
26 | VIEW
27 | USER
28 |
29 | The following constant is a sequence of all the object types that are
30 | available. It can be used to generate a version-independent list of object
31 | types that can be searched; for example, options and help texts.
32 |
33 | .. data:: OBJECT_TYPES
34 |
35 | Classes
36 | -------
37 |
38 | .. class:: ObjectGrep(pattern[, database_pattern=None, types=OBJECT_TYPES, check_body=False, use_regexp=False])
39 |
40 | Search MySQL server instances for objects where the name (or content, for
41 | routines, triggers, or events) matches a given pattern.
42 |
43 | .. method:: sql() -> string
44 |
45 | Return the SQL code for executing the search in the form of a
46 | `SELECT`_ statement.
47 |
48 | :returns: SQL code for executing the operation specified by the
49 | options.
50 | :rtype: string
51 |
52 | .. method:: execute(connections[, output=sys.output, connector=mysql.connector])
53 |
54 | Execute the search on each of the connections in turn and print an
55 | aggregate of the result as a grid table.
56 |
57 | :param connections: Sequence of connection specifiers to send the query to
58 | :param output: File object to use for writing the result
59 | :param connector: Connector to use for connecting to the servers
60 |
61 |
62 | .. References
63 | .. ----------
64 | .. _`SELECT`: http://dev.mysql.com/doc/mysql/en/select.html
65 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/doc/command/index.rst:
--------------------------------------------------------------------------------
1 | .. _command-index:
2 |
3 | ###############
4 | Command Package
5 | ###############
6 |
7 | .. toctree::
8 | :maxdepth: 2
9 |
10 | grep
11 | proc
12 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/doc/index.rst:
--------------------------------------------------------------------------------
1 | .. MySQL Utilities documentation master file, created by
2 | sphinx-quickstart on Thu Oct 14 14:45:08 2010.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | MySQL Utilities Documentation
7 | ===============================
8 |
9 | MySQL Utilities is both a set of command-line utilities as well as a
10 | Python library for making the common tasks easy to accomplish. The
11 | library is written entirely in Python, meaning that it is not
12 | necessary to have any other tools or libraries installed to make it
13 | work. It is currently designed to work with Python v2.6 or later and
14 | there is no support (yet) for Python v3.1.
15 |
16 | Contents:
17 |
18 | .. toctree::
19 | :maxdepth: 2
20 |
21 | intro/index
22 | command/index
23 | parser/index
24 | man/index
25 | changes
26 |
27 | Indices and tables
28 | ==================
29 |
30 | * :ref:`genindex`
31 | * :ref:`modindex`
32 | * :ref:`search`
33 |
34 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/doc/intro/connspec.rst:
--------------------------------------------------------------------------------
1 | .. `connection specification`
2 |
3 | Connection Parameters
4 | =====================
5 |
6 | To connect to a server, it is necessary to specify connection
7 | parameters such as user name, host name, password, and perhaps also port or
8 | socket.
9 |
10 | Whenever connection parameters are required, they can be specified
11 | three different ways:
12 |
13 | - As a dictionary containing the connection parameters.
14 |
15 | - As a connection specification string containing the connection
16 | parameters.
17 |
18 | - As a Server instance.
19 |
20 | When providing the connection parameters as a dictionary, the
21 | parameters are passed unchanged to the connector's ``connect``
22 | function. This enables you to pass parameters not supported through
23 | the other interfaces, but at least these parameters are supported:
24 |
25 | _`user`
26 | The name of the user to connect as. The default if no user is supplied
27 | is login name of the user, as returned by `getpass.getuser`_.
28 |
29 | _`passwd`
30 | The password to use when connecting. The default if no password is supplied
31 | is the empty password.
32 |
33 | _`host`
34 | The domain name of the host or the IP address. The default iIf no host name
35 | is provided is 'localhost'. This field accepts host names, and IPv4 and IPv6
36 | addresses. It also accepts quoted values which are not validated and passed
37 | directly to the calling methods. This enables users to specify host names and
38 | IP addresses that are outside of the supported validation mechanisms.
39 |
40 |
41 | _`port`
42 | The port to use when connecting to the server. The default if no port is
43 | supplied is 3306 (which is the default port for the MySQL server as well).
44 |
45 | _`unix_socket`
46 | The socket to connect to (instead of using the host_ and port_ parameters).
47 |
48 | .. _`connection specification`:
49 |
50 | Providing the connection parameters as a string requires the string to
51 | have the format ``user[:passwd]@host[:port][:socket]``, where some values
52 | are optional. If a connection specification string is provided, it
53 | is parsed using the options.parse_connection function.
54 |
55 | .. _`getpass.getuser`: http://docs.python.org/library/getpass.html#getpass.getuser
56 |
57 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/doc/intro/index.rst:
--------------------------------------------------------------------------------
1 |
2 | ###############################
3 | Introduction
4 | ###############################
5 |
6 | .. toctree::
7 |
8 | intro
9 | developers
10 | connspec
11 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/doc/intro/intro.rst:
--------------------------------------------------------------------------------
1 | .. _`intro`:
2 |
3 | ###############################
4 | Introduction to MySQL Utilities
5 | ###############################
6 |
7 | What are the MySQL Utilities?
8 | -----------------------------
9 |
10 | It is a package of utilities that are used for maintenance and
11 | administration of MySQL servers. These utilities encapsulate a set of
12 | primitive commands, and bundles them so they can be used to perform
13 | macro operations with a single command. They can be installed via
14 | MySQL Workbench, or as a standalone package.
15 |
16 | The utilities are written in Python, available under the GPLv2 license,
17 | and are extendable using the supplied library.
18 |
19 | How do we access the MySQL Utilities?
20 | -------------------------------------
21 |
22 | There are two ways to access the utilities from within the MySQL
23 | Workbench. Either use ``Plugins`` -> ``Start Shell for MySQL Utilities``
24 | from the main Workbench toolbar, or click the MySQL Utilities icon from
25 | the main Workbench page. Both methods will open a terminal/shell
26 | window, and list the available commands.
27 |
28 | You can launch any of the utilities listed by typing the name of the
29 | command. To find out what options are available, use the `--help` option,
30 | or read the appropriate manual page.
31 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/doc/man/index.rst:
--------------------------------------------------------------------------------
1 |
2 | ######################
3 | Command-Line Utilities
4 | ######################
5 |
6 | .. toctree::
7 |
8 | overview
9 | mysqldbcompare
10 | mysqldbcopy
11 | mysqldbimport
12 | mysqldbexport
13 | mysqldiff
14 | mysqldiskusage
15 | mysqlfailover
16 | mysqlindexcheck
17 | mysqlmetagrep
18 | mysqlprocgrep
19 | mysqlreplicate
20 | mysqlrpladmin
21 | mysqlrplcheck
22 | mysqlrplshow
23 | mysqlserverclone
24 | mysqlserverinfo
25 | mysqluserclone
26 | mut
27 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/doc/parser/index.rst:
--------------------------------------------------------------------------------
1 | .. _parser-index:
2 |
3 | #############
4 | Parser Module
5 | #############
6 |
7 | .. toctree::
8 | :maxdepth: 2
9 |
10 | parser
11 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/freeze.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #
3 | # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
4 | #
5 | # This program is free software; you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation; version 2 of the License.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program; if not, write to the Free Software
16 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | #
18 |
19 | import sys
20 |
21 | from info import META_INFO, INSTALL, COMMANDS
22 |
23 | from cx_Freeze import setup # Setup function to use
24 |
25 | if sys.platform.startswith("win32"):
26 | META_INFO['name'] = 'MySQL Utilities'
27 |
28 | ARGS = {
29 | 'executable': [
30 | cx_Freeze.Executable(exe, base="Console") for exe in INSTALL['scripts']
31 | ],
32 | 'options': {
33 | 'bdist_msi': { 'add_to_path': True, },
34 | }
35 | }
36 |
37 | ARGS.update(META_INFO)
38 | ARGS.update(INSTALL)
39 | ARGS.update(COMMANDS)
40 | setup(**ARGS)
41 |
42 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/info.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiepaup/dbatools/8549f2571aaee6a39f5c6f32179ac9c5d301a9aa/mysqlTools/mysql_utilities/info.pyc
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/disabled:
--------------------------------------------------------------------------------
1 | #
2 | # Use this file to disable tests for non-deterministic or other reasons that keep the
3 | # test from passing on all platforms.
4 | #
5 | # Include the following information (CSV):
6 | # suite.test, reason
7 | # main.example, This is a test (bug#xxxxx)
8 | #
9 | main.copy_db_multithreaded, Does not run on all platforms. Need to move to an optional performance suite.
10 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/mutlib/__init__.py:
--------------------------------------------------------------------------------
1 | from mutlib import System_test
2 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/check_index_best_worst_large.result:
--------------------------------------------------------------------------------
1 | Test case 1 - show best indexes
2 | # Source on localhost: ... connected.
3 | # Checking indexes...
4 | # Getting indexes for employees.dept_emp
5 | # The following indexes are duplicates or redundant for table employees.dept_emp:
6 | #
7 | CREATE INDEX emp_no ON employees.dept_emp (emp_no) USING BTREE
8 | # may be redundant or duplicate of:
9 | ALTER TABLE employees.dept_emp ADD PRIMARY KEY (emp_no, dept_no)
10 | #
11 | # Showing the top best performing indexes from employees.dept_emp:
12 | #
13 | database,table,name,column,sequence,num columns,cardinality,est. rows,percent
14 | employees,dept_emp,emp_no,emp_no,1,1,NNNNNNN,NNNNNNN,NNNNNNN
15 | employees,dept_emp,dept_no,dept_no,1,1,NNNNNNN,NNNNNNN,NNNNNNN
16 | #
17 | # ...done.
18 | Test case 2 - show worst indexes
19 | # Source on localhost: ... connected.
20 | # Checking indexes...
21 | # Getting indexes for employees.dept_emp
22 | # The following indexes are duplicates or redundant for table employees.dept_emp:
23 | #
24 | CREATE INDEX emp_no ON employees.dept_emp (emp_no) USING BTREE
25 | # may be redundant or duplicate of:
26 | ALTER TABLE employees.dept_emp ADD PRIMARY KEY (emp_no, dept_no)
27 | #
28 | # Showing the top worst performing indexes from employees.dept_emp:
29 | #
30 | database,table,name,column,sequence,num columns,cardinality,est. rows,percent
31 | employees,dept_emp,dept_no,dept_no,1,1,NNNNNNN,NNNNNNN,NNNNNNN
32 | employees,dept_emp,emp_no,emp_no,1,1,NNNNNNN,NNNNNNN,NNNNNNN
33 | #
34 | # ...done.
35 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/check_index_best_worst_small.result:
--------------------------------------------------------------------------------
1 | Test case 1 - show best indexes on small database
2 | # Getting indexes for util_test_a.t1
3 | # The following indexes are duplicates or redundant for table util_test_a.t1:
4 | #
5 | CREATE INDEX s4 ON util_test_a.t1 (d(32))
6 | # may be redundant or duplicate of:
7 | CREATE INDEX s2 ON util_test_a.t1 (d(32))
8 | #
9 | CREATE INDEX s2 ON util_test_a.t1 (d(32))
10 | # may be redundant or duplicate of:
11 | CREATE INDEX s4 ON util_test_a.t1 (d(32))
12 | # Getting indexes for util_test_a.t2
13 | # Table util_test_a.t2 has no duplicate indexes.
14 | Test case 2 - show worst indexes on small database
15 | # Getting indexes for util_test_a.t1
16 | # The following indexes are duplicates or redundant for table util_test_a.t1:
17 | #
18 | CREATE INDEX s4 ON util_test_a.t1 (d(32))
19 | # may be redundant or duplicate of:
20 | CREATE INDEX s2 ON util_test_a.t1 (d(32))
21 | #
22 | CREATE INDEX s2 ON util_test_a.t1 (d(32))
23 | # may be redundant or duplicate of:
24 | CREATE INDEX s4 ON util_test_a.t1 (d(32))
25 | # Getting indexes for util_test_a.t2
26 | # Table util_test_a.t2 has no duplicate indexes.
27 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/check_index_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - error: no db specified
2 | Usage: mysqlindexcheck.py --server=user:pass@host:port:socket db1.table1 db2 db3.table2
3 |
4 | mysqlindexcheck.py: error: You must specify at least one table or database to check.
5 | Test case 2 - error: invalid source specified
6 | # Source on nohost: ... ERROR: Cannot connect to the Source server.
7 | Error XXXX: Access denied
8 | Test case 3 - error: invalid login to server
9 | # Source on localhost: ... ERROR: Cannot connect to the Source server.
10 | Error XXXX: Access denied
11 | Test case 4 - error: stats and best=alpha
12 | Usage: mysqlindexcheck.py --server=user:pass@host:port:socket db1.table1 db2 db3.table2
13 |
14 | mysqlindexcheck.py: error: The --best parameter must be an integer > 1
15 | Test case 5 - error: stats and worst=alpha
16 | Usage: mysqlindexcheck.py --server=user:pass@host:port:socket db1.table1 db2 db3.table2
17 |
18 | mysqlindexcheck.py: error: The --worst parameter must be an integer > 1
19 | Test case 6 - error: not stats
20 | Usage: mysqlindexcheck.py --server=user:pass@host:port:socket db1.table1 db2 db3.table2
21 |
22 | mysqlindexcheck.py: error: You must specify --stats for --best or --worst to take effect.
23 | Test case 7 - error: stats and both best and worst
24 | Usage: mysqlindexcheck.py --server=user:pass@host:port:socket db1.table1 db2 db3.table2
25 |
26 | mysqlindexcheck.py: error: You must specify either --best or --worst but not both.
27 | Test case 8 - error: stats and worst=-1
28 | Usage: mysqlindexcheck.py --server=user:pass@host:port:socket db1.table1 db2 db3.table2
29 |
30 | mysqlindexcheck.py: error: The --worst parameter must be an integer > 1
31 | Test case 9 - error: stats and best=-1
32 | Usage: mysqlindexcheck.py --server=user:pass@host:port:socket db1.table1 db2 db3.table2
33 |
34 | mysqlindexcheck.py: error: The --best parameter must be an integer > 1
35 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/check_unsupported_server_version.result:
--------------------------------------------------------------------------------
1 | Test case 1 - compare two databases on unsupported server
2 | # server1 on localhost: ... connected.
3 | ERROR: The server1 version is incompatible. Utility requires version 5.1.30 or higher.
4 |
5 | # Database consistency check failed.
6 | #
7 | # ...done
8 |
9 | Test case 2 - compare two databases on unsupported 2nd server
10 | # server1 on localhost: ... connected.
11 | # server2 on localhost: ... connected.
12 | ERROR: The server2 version is incompatible. Utility requires version 5.1.30 or higher.
13 |
14 | # Database consistency check failed.
15 | #
16 | # ...done
17 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/clone_db_exclude.result:
--------------------------------------------------------------------------------
1 | Test case 1 - exclude by name
2 | # Source on localhost: ... connected.
3 | # Destination on localhost: ... connected.
4 | # Copying database util_test renamed as util_db_clone
5 | # Copying TABLE util_test.t1
6 | # Copying TABLE util_test.t2
7 | # Copying TABLE util_test.t3
8 | # Copying PROCEDURE util_test.p1
9 | # Copying FUNCTION util_test.f1
10 | # Copying data for TABLE util_test.t1
11 | # Copying data for TABLE util_test.t2
12 | # Copying data for TABLE util_test.t3
13 | # Copying TRIGGER util_test.trg
14 | # Copying EVENT util_test.e1
15 | #...done.
16 | Test case 2 - exclude by regex
17 | # Source on localhost: ... connected.
18 | # Destination on localhost: ... connected.
19 | # Copying database util_test renamed as util_db_clone
20 | # Copying TABLE util_test.t1
21 | # Copying TABLE util_test.t2
22 | # Copying TABLE util_test.t3
23 | # Copying VIEW util_test.v1
24 | # Copying PROCEDURE util_test.p1
25 | # Copying FUNCTION util_test.f1
26 | # Copying data for TABLE util_test.t1
27 | # Copying data for TABLE util_test.t2
28 | # Copying data for TABLE util_test.t3
29 | # Copying TRIGGER util_test.trg
30 | #...done.
31 | Test case 3 - exclude by name and regex
32 | # Source on localhost: ... connected.
33 | # Destination on localhost: ... connected.
34 | # Copying database util_test renamed as util_db_clone
35 | # Copying TABLE util_test.t1
36 | # Copying TABLE util_test.t2
37 | # Copying TABLE util_test.t3
38 | # Copying PROCEDURE util_test.p1
39 | # Copying FUNCTION util_test.f1
40 | # Copying data for TABLE util_test.t1
41 | # Copying data for TABLE util_test.t2
42 | # Copying data for TABLE util_test.t3
43 | #...done.
44 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/clone_server.result:
--------------------------------------------------------------------------------
1 | Test case 1 - clone a running server
2 | # Cloning the MySQL server running on localhost.
3 | # Creating new data directory...
4 | # Configuring new instance...
5 | # Locating mysql tools...
6 | # Setting up empty database and mysql tables...
7 | # Starting new instance of the server...
8 | # Testing connection to new instance...
9 | # Success!
10 | # Setting the root password...
11 | # Connection Information:
12 | # -uroot [...]
13 | #...done.
14 | Test case 2 - clone a server from basedir
15 | # Cloning the MySQL server located at XXXX
16 | # Creating new data directory...
17 | # Configuring new instance...
18 | # Locating mysql tools...
19 | # Setting up empty database and mysql tables...
20 | # Starting new instance of the server...
21 | # Testing connection to new instance...
22 | # Success!
23 | # Setting the root password...
24 | # Connection Information:
25 | # -uroot [...]
26 | #...done.
27 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/clone_server_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - error: no --new-data option
2 | Usage: mysqlserverclone.py --server=user:pass@host:port:socket --new-data=/tmp/data2 --new-port=3310 --new-id=12 --root-password=root
3 |
4 | mysqlserverclone.py: error: No new database path. Use --help for available options.
5 | Test case 2 - error: no login
6 | # WARNING: Root password for new instance has not been set.
7 | ERROR: Cannot connect to the source server.
8 | Error ####: Can't connect to MySQL server on 'nothere:####'
9 | Test case 3 - error: cannot connect
10 | ERROR: Cannot connect to the source server.
11 | Error ####: Can't connect to MySQL server on 'nothere:####'
12 | Test case 4 - cannot create directory
13 | # Cloning the MySQL server running on localhost.
14 | # Creating new data directory...
15 | ERROR: Unable to create directory '/not/there/yes'
16 | Test case 5 - error: --new-data exists
17 | Usage: mysqlserverclone.py --server=user:pass@host:port:socket --new-data=/tmp/data2 --new-port=3310 --new-id=12 --root-password=root
18 |
19 | mysqlserverclone.py: error: Target data directory exists and is not empty. Use --delete-data option to delete folder before cloning.
20 | Test case 6 - --new-data does not exist (but cannot connect)
21 | ERROR: Cannot connect to the source server.
22 | Error ####: Can't connect to MySQL server on 'nothere:####'
23 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/clone_user_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - error: invalid login to source server
2 | # Source on localhost: ... ERROR: Cannot connect to the Source server.
3 | Error XXXX: Access denied
4 | Test case 2 - error: invalid login to destination server
5 | # Source on localhost: ... connected.
6 | # Destination on localhost: ... ERROR: Cannot connect to the Destination server.
7 | Error XXXX: Access denied
8 | Test case 3 - error: no arguments
9 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
10 |
11 | mysqluserclone.py: error: No arguments found. Use --help for available options.
12 | Test case 4 - error: no new user
13 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
14 |
15 | mysqluserclone.py: error: Wrong parameter combination or no new users.
16 | Test case 5 - error: cannot use dump and quiet together
17 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
18 |
19 | mysqluserclone.py: error: You cannot use --quiet and --dump together.
20 | Test case 6 - error: cannot parser source connection
21 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
22 |
23 | mysqluserclone.py: error: Source connection values invalid
24 | Test case 7 - error: cannot parser destination connection
25 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
26 |
27 | mysqluserclone.py: error: Destination connection values invalid
28 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/clone_user_parameters.result:
--------------------------------------------------------------------------------
1 | Test case 1 - show the grant statements
2 | # Source on localhost: ... connected.
3 | # Dumping grants for user joe_nopass@user
4 | GRANT USAGE ON *.* TO 'joe_nopass'@'user'
5 | GRANT ALL PRIVILEGES ON `util_test`.* TO 'joe_nopass'@'user'
6 | Test case 2 - show the help
7 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
8 |
9 | mysqluserclone - clone a MySQL user account to one or more new users
10 |
11 | Options:
12 | --version show program's version number and exit
13 | --help display a help message and exit
14 | --source=SOURCE connection information for source server in the form:
15 | [:]@[:][:] or
16 | [:][:].
17 | --destination=DESTINATION
18 | connection information for destination server in the
19 | form: [:]@[:][:]
20 | or [:][:].
21 | -d, --dump dump GRANT statements for user - does not require a
22 | destination
23 | --force drop the new user if it exists
24 | --include-global-privileges
25 | include privileges that match base_user@% as well as
26 | base_user@host
27 | --list list all users on the source - does not require a
28 | destination
29 | -f FORMAT, --format=FORMAT
30 | display the list of users in either grid (default),
31 | tab, csv, or vertical format - valid only for --list
32 | option
33 | -v, --verbose control how much information is displayed. e.g., -v =
34 | verbose, -vv = more verbose, -vvv = debug
35 | -q, --quiet turn off all messages for quiet execution.
36 | Test case 3 - use the quiet parameter
37 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/compare_db_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - Invalid --server1
2 | Usage: mysqldbcompare.py --server1=user:pass@host:port:socket --server2=user:pass@host:port:socket db1:db2
3 |
4 | mysqldbcompare.py: error: Server1 connection values invalid
5 | Test case 2 - Invalid --server2
6 | Usage: mysqldbcompare.py --server1=user:pass@host:port:socket --server2=user:pass@host:port:socket db1:db2
7 |
8 | mysqldbcompare.py: error: Server2 connection values invalid
9 | Test case 3 - missing backticks inventory.inventory
10 | Usage: mysqldbcompare.py --server1=user:pass@host:port:socket --server2=user:pass@host:port:socket db1:db2
11 |
12 | mysqldbcompare.py: error: Cannot parse the specified database(s): 'inventory.inventory'. Please verify that the database(s) are specified in a valid format (i.e., db1[:db2]) and that backtick quotes are properly used when required. The use of backticks is required if non alphanumeric characters are used for database names. Parsing the specified database results in db1 = 'inventory' and db2 = 'inventory'.
13 | Test case 4 - non existing database '`inventory.inventory`'
14 | # server1 on localhost: ... connected.
15 | # server2 on localhost: ... connected.
16 | ERROR: The database inventory.inventory does not exist.
17 |
18 | # Database consistency check failed.
19 | #
20 | # ...done
21 | Test case 5 - invalid format :inventory
22 | Usage: mysqldbcompare.py --server1=user:pass@host:port:socket --server2=user:pass@host:port:socket db1:db2
23 |
24 | mysqldbcompare.py: error: Cannot parse the specified database(s): ':inventory'. Please verify that the database(s) are specified in a valid format (i.e., db1[:db2]) and that backtick quotes are properly used when required.
25 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/copy_db_exclude.result:
--------------------------------------------------------------------------------
1 | Test case 1 - exclude by name
2 | # Source on localhost: ... connected.
3 | # Destination on localhost: ... connected.
4 | # Copying database util_test renamed as util_db_clone
5 | # Copying TABLE util_test.t1
6 | # Copying TABLE util_test.t2
7 | # Copying TABLE util_test.t3
8 | # Copying PROCEDURE util_test.p1
9 | # Copying FUNCTION util_test.f1
10 | # Copying data for TABLE util_test.t1
11 | # Copying data for TABLE util_test.t2
12 | # Copying data for TABLE util_test.t3
13 | # Copying TRIGGER util_test.trg
14 | # Copying EVENT util_test.e1
15 | #...done.
16 | Test case 2 - exclude by regex
17 | # Source on localhost: ... connected.
18 | # Destination on localhost: ... connected.
19 | # Copying database util_test renamed as util_db_clone
20 | # Copying TABLE util_test.t1
21 | # Copying TABLE util_test.t2
22 | # Copying TABLE util_test.t3
23 | # Copying VIEW util_test.v1
24 | # Copying PROCEDURE util_test.p1
25 | # Copying FUNCTION util_test.f1
26 | # Copying data for TABLE util_test.t1
27 | # Copying data for TABLE util_test.t2
28 | # Copying data for TABLE util_test.t3
29 | # Copying TRIGGER util_test.trg
30 | #...done.
31 | Test case 3 - exclude by name and regex
32 | # Source on localhost: ... connected.
33 | # Destination on localhost: ... connected.
34 | # Copying database util_test renamed as util_db_clone
35 | # Copying TABLE util_test.t1
36 | # Copying TABLE util_test.t2
37 | # Copying TABLE util_test.t3
38 | # Copying PROCEDURE util_test.p1
39 | # Copying FUNCTION util_test.f1
40 | # Copying data for TABLE util_test.t1
41 | # Copying data for TABLE util_test.t2
42 | # Copying data for TABLE util_test.t3
43 | #...done.
44 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/copy_db_special_symbols.result:
--------------------------------------------------------------------------------
1 | Test case 1 - copy a database with special symbols
2 | # Source on localhost: ... connected.
3 | # Destination on localhost: ... connected.
4 | # Copying database util_spec renamed as util_spec_clone
5 | # Copying FUNCTION util_spec.spec_date
6 | #...done.
7 | RETURN DATE_FORMAT(mydatetime, '%d/%m %H:%i')
8 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/copy_user_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - error: invalid login to source server
2 | # Source on localhost: ... ERROR: Cannot connect to the Source server.
3 | Error XXXX: Access denied
4 | Test case 2 - error: invalid login to destination server
5 | # Source on localhost: ... connected.
6 | # Destination on localhost: ... ERROR: Cannot connect to the Destination server.
7 | Error XXXX: Access denied
8 | Test case 3 - error: no arguments
9 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
10 |
11 | mysqluserclone.py: error: No arguments found. Use --help for available options.
12 | Test case 4 - error: no new user
13 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
14 |
15 | mysqluserclone.py: error: Wrong parameter combination or no new users.
16 | Test case 5 - error: cannot use dump and quiet together
17 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
18 |
19 | mysqluserclone.py: error: You cannot use --quiet and --dump together.
20 | Test case 6 - error: cannot parser source connection
21 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
22 |
23 | mysqluserclone.py: error: Source connection values invalid
24 | Test case 7 - error: cannot parser destination connection
25 | Usage: mysqluserclone.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket joe@localhost sam:secret1@localhost
26 |
27 | mysqluserclone.py: error: Destination connection values invalid
28 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/diskusage_basic.result:
--------------------------------------------------------------------------------
1 | Test Case 1 : Testing disk space (simple)
2 | # Source on localhost: ... connected.
3 | # Database totals:
4 | db_name,total
5 | util_test,XXXXXXX
6 |
7 | Total database disk usage = XXXXXXX
8 |
9 | #...done.
10 | Test Case 2 : Testing disk space (with empty)
11 | # Source on localhost: ... connected.
12 | # Database totals:
13 | +------------+----------+
14 | | db_name | total |
15 | +------------+----------+
16 | | util_test | XXXXXXX |
17 | +------------+----------+
18 |
19 | Total database disk usage = XXXXXXX
20 |
21 | #...done.
22 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/diskusage_errors.result:
--------------------------------------------------------------------------------
1 | Test Case 1 : Errors for logs, binlog, innodb
2 | # Source on localhost: ... connected.
3 | # Database totals:
4 | db_name,db_dir_size,data_size,misc_files,total
5 | mysql,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX
6 | util_test,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX
7 |
8 | Total database disk usage = XXXXXXX
9 |
10 | # Log information.
11 | # The general_log is turned off on the server.
12 | # The slow_query_log is turned off on the server.
13 | log_name,size
14 | error_log.err,XXXX
15 |
16 | Total size of logs = XXXX
17 |
18 | # Binary logging is turned off on the server.
19 | # Server is not an active slave - no relay log information.
20 | # InnoDB is disabled on this server.
21 | #...done.
22 |
23 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/diskusage_format.result:
--------------------------------------------------------------------------------
1 | Test Case 1 : Testing disk space with CSV format
2 | # Source on localhost: ... connected.
3 | # Database totals:
4 | db_name,total
5 | util_test,XXXXXXX
6 |
7 | Total database disk usage = XXXXXXX
8 |
9 | #...done.
10 | Test Case 2 : Testing disk space with TAB format
11 | # Source on localhost: ... connected.
12 | # Database totals:
13 | db_name total
14 | util_test XXXXXXX
15 |
16 | Total database disk usage = XXXXXXX
17 |
18 | #...done.
19 | Test Case 3 : Testing disk space with GRID format
20 | # Source on localhost: ... connected.
21 | # Database totals:
22 | +------------+----------+
23 | | db_name | total |
24 | +------------+----------+
25 | | util_test | XXXXXXX |
26 | +------------+----------+
27 |
28 | Total database disk usage = XXXXXXX
29 |
30 | #...done.
31 | Test Case 4 : Testing disk space with VERTICAL format
32 | # Source on localhost: ... connected.
33 | # Database totals:
34 | ************************* 1. row *************************
35 | db_name: util_test
36 | total: XXXXXXX
37 | 1 rows.
38 |
39 | Total database disk usage = XXXXXXX
40 |
41 | #...done.
42 | Test Case 5 : Testing disk space with NOT_THERE format
43 | Usage: mysqldiskusage.py --server=user:pass@host:port:socket db1 --all
44 |
45 | mysqldiskusage.py: error: option --format: invalid choice: 'NOT_THERE' (choose from 'grid', 'tab', 'csv', 'vertical')
46 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/diskusage_paths.result:
--------------------------------------------------------------------------------
1 | Test Case 1 : Testing disk space (with paths)
2 | # Source on localhost: ... connected.
3 | # Database totals:
4 | db_name,total
5 | util_test,XXXXXXX
6 |
7 | Total database disk usage = XXXXXXX
8 |
9 | # Log information.
10 | log_name,size
11 | slow.log,XXXX
12 | general.log,XXXX
13 | error_log.err,XXXXX
14 |
15 | Total size of logs = XXXX
16 |
17 | # binary log information:
18 | Current binary log file = XXXX
19 | log_file,size
20 | mysql-bin.000001,XXXX
21 | mysql-bin.index,XXXX
22 |
23 | Total size of binary logs = XXXX
24 |
25 | # Server is not an active slave - no relay log information.
26 | # InnoDB tablespace information:
27 | innodb_file,size
28 | ib_logfile0,XXXXXXXX
29 | ib_logfile1,XXXXXXXX
30 | ibdata1,XXXXXXXX
31 |
32 | Total size of InnoDB files = XXXXXXXX
33 |
34 | #...done.
35 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/export_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - bad --skip values
2 | ERROR: The value wiki-waki is not a valid value for --skip.
3 | Test case 2 - exporting data and skipping data
4 | ERROR: You cannot use --export=data and --skip-data when exporting table data.
5 | Test case 3 - no database specified
6 | Usage: mysqldbexport.py --server=user:pass@host:port:socket db1, db2, db3
7 |
8 | mysqldbexport.py: error: You must specify at least one database to export or use the --all option to export all databases.
9 | Test case 4 - cannot parse --server
10 | Usage: mysqldbexport.py --server=user:pass@host:port:socket db1, db2, db3
11 |
12 | mysqldbexport.py: error: Server connection values invalid
13 | Test case 5 - error: cannot connect to server
14 | # Source on localhost: ... ERROR: Cannot connect to the Source server.
15 | Error 1045: Access denied for user 'nope'@'localhost' (using password: YES)
16 | Test case 6 - error: not enough privileges
17 | # Source on localhost: ... connected.
18 | ERROR: User joe on the Source server does not have permissions to read all objects in util_test. User needs SELECT privilege on util_test.
19 | Test case 7 - database does not exist
20 | # Source on localhost: ... connected.
21 | ERROR: Source database does not exist - notthereatall
22 | Test case 8 - error: not enough privileges
23 | # Source on localhost: ... connected.
24 | ERROR: User joe on the Source server does not have permissions to read all objects in util_test. User needs SELECT privilege on util_test.
25 | Test case 9 - error: db list and --all
26 | Usage: mysqldbexport.py --server=user:pass@host:port:socket db1, db2, db3
27 |
28 | mysqldbexport.py: error: You cannot use the --all option with a list of databases.
29 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/export_file_per_table.result:
--------------------------------------------------------------------------------
1 | Test case 1 - warning: def only with --file-per-table
2 | # WARNING: --file-per-table option ignored for metadata export.
3 | # Source on localhost: ... connected.
4 | # Exporting metadata from util_test_mt
5 | DROP DATABASE IF EXISTS `util_test_mt`;
6 | CREATE DATABASE `util_test_mt`;
7 | USE `util_test_mt`;
8 | #...done.
9 | Test case 2 - sql format with --file-per-table
10 | # Checking for file-per-table creation:
11 | # util_test.t1.sql ................. [PASS]
12 | # util_test.t2.sql ................. [PASS]
13 | # util_test.t3.sql ................. [PASS]
14 | # util_test.t4.sql ................. [PASS]
15 |
16 | Test case 3 - grid format with --file-per-table
17 | # Checking for file-per-table creation:
18 | # util_test.t1.grid ................. [PASS]
19 | # util_test.t2.grid ................. [PASS]
20 | # util_test.t3.grid ................. [PASS]
21 | # util_test.t4.grid ................. [PASS]
22 |
23 | Test case 4 - csv format with --file-per-table
24 | # Checking for file-per-table creation:
25 | # util_test.t1.csv ................. [PASS]
26 | # util_test.t2.csv ................. [PASS]
27 | # util_test.t3.csv ................. [PASS]
28 | # util_test.t4.csv ................. [PASS]
29 |
30 | Test case 5 - tab format with --file-per-table
31 | # Checking for file-per-table creation:
32 | # util_test.t1.tab ................. [PASS]
33 | # util_test.t2.tab ................. [PASS]
34 | # util_test.t3.tab ................. [PASS]
35 | # util_test.t4.tab ................. [PASS]
36 |
37 | Test case 6 - vertical format with --file-per-table
38 | # Checking for file-per-table creation:
39 | # util_test.t1.vertical ................. [PASS]
40 | # util_test.t2.vertical ................. [PASS]
41 | # util_test.t3.vertical ................. [PASS]
42 | # util_test.t4.vertical ................. [PASS]
43 |
44 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/export_mysql.result:
--------------------------------------------------------------------------------
1 | Test case 1 - export metadata to new server via the mysql monitor
2 | OBJECT COUNTS: tables = 4, views = 1, triggers = 1, procedures = 1, functions = 1,
3 | Test case 2 - export the data to new server via the mysql monitor
4 | Showing data for table t1
5 | a
6 | 01 Test Basic database example
7 | 02 Test Basic database example
8 | 03 Test Basic database example
9 | 04 Test Basic database example
10 | 05 Test Basic database example
11 | 06 Test Basic database example
12 | 07 Test Basic database example
13 | Showing data for table t2
14 | a
15 | Test objects count
16 | Test objects count
17 | Test objects count
18 | Test objects count
19 | Test objects count
20 | Test objects count
21 | Test objects count
22 | 11 Test Basic database example
23 | 12 Test Basic database example
24 | 13 Test Basic database example
25 | Showing data for table t3
26 | a b
27 | 1 14 test fkeys
28 | 2 15 test fkeys
29 | 3 16 test fkeys
30 | Showing data for table t4
31 | c d
32 | 3 2
33 | OBJECT COUNTS: tables = 0, views = 0, triggers = 0, procedures = 0, functions = 0,
34 | Test case 3 - export all objects and data to new server via the mysql monitor
35 | OBJECT COUNTS: tables = 4, views = 1, triggers = 1, procedures = 1, functions = 1,
36 | Showing data for table t1
37 | a
38 | 01 Test Basic database example
39 | 02 Test Basic database example
40 | 03 Test Basic database example
41 | 04 Test Basic database example
42 | 05 Test Basic database example
43 | 06 Test Basic database example
44 | 07 Test Basic database example
45 | Showing data for table t2
46 | a
47 | Test objects count
48 | Test objects count
49 | Test objects count
50 | Test objects count
51 | Test objects count
52 | Test objects count
53 | Test objects count
54 | 11 Test Basic database example
55 | 12 Test Basic database example
56 | 13 Test Basic database example
57 | Showing data for table t3
58 | a b
59 | 1 14 test fkeys
60 | 2 15 test fkeys
61 | 3 16 test fkeys
62 | Showing data for table t4
63 | c d
64 | 3 2
65 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/format_list.result:
--------------------------------------------------------------------------------
1 | +--------+
2 | | a |
3 | +--------+
4 | | one |
5 | | two |
6 | | three |
7 | +--------+
8 | +--------+-------+
9 | | a | b |
10 | +--------+-------+
11 | | one | None |
12 | | two | None |
13 | | three | None |
14 | +--------+-------+
15 | +--------+-------+-----+
16 | | a | b | c |
17 | +--------+-------+-----+
18 | | one | None | 31 |
19 | | two | None | 32 |
20 | | three | None | 33 |
21 | +--------+-------+-----+
22 | ************************* 1. row *************************
23 | a: one
24 | ************************* 2. row *************************
25 | a: two
26 | ************************* 3. row *************************
27 | a: three
28 | 3 rows.
29 | ************************* 1. row *************************
30 | a: one
31 | b: None
32 | ************************* 2. row *************************
33 | a: two
34 | b: None
35 | ************************* 3. row *************************
36 | a: three
37 | b: None
38 | 3 rows.
39 | ************************* 1. row *************************
40 | a: one
41 | b: None
42 | c: 31
43 | ************************* 2. row *************************
44 | a: two
45 | b: None
46 | c: 32
47 | ************************* 3. row *************************
48 | a: three
49 | b: None
50 | c: 33
51 | 3 rows.
52 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/get_tool_windows.result:
--------------------------------------------------------------------------------
1 | Test case 1 - get_tool mysqld-nt.exe
2 | Pass
3 |
4 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/mylogin.result:
--------------------------------------------------------------------------------
1 | {'passwd': '', 'host': 'localhost', 'user': 'test_user', 'port': 3306}
2 | {'passwd': '', 'host': 'localhost', 'user': 'test_user', 'port': 3306}
3 | {'passwd': '', 'host': 'localhost', 'user': 'test_user', 'port': 1000}
4 | {'passwd': '', 'host': 'localhost', 'user': 'test_user', 'port': 1000}
5 | {'passwd': '', 'unix_socket': '/my.socket', 'host': 'localhost', 'user': 'test_user', 'port': 1000}
6 | {'passwd': '', 'unix_socket': '/my.socket', 'host': 'localhost', 'user': 'test_user', 'port': 1000}
7 | {'passwd': '', 'unix_socket': '/my.socket', 'host': 'localhost', 'user': 'test_user', 'port': 3306}
8 | {'passwd': '', 'unix_socket': '/my.socket', 'host': 'localhost', 'user': 'test_user', 'port': 3306}
9 | ('test_user', None)
10 | ('test_user', None)
11 | ('test_user', '')
12 | ('user_x', '')
13 | ('user_x', 'pass_y')
14 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/mylogin_clone_user.result:
--------------------------------------------------------------------------------
1 | Test case 1 - Clone one user to another (using login-path)
2 | # Source on localhost: ... connected.
3 | # Destination on localhost: ... connected.
4 | # Cloning 1 users...
5 | # Cloning joe_pass@user to user jill:duh@user
6 | # ...done.
7 | GRANT USAGE ON *.* TO 'jill'@'user' IDENTIFIED BY PASSWORD '*76293EBE39BB165EF83BE0C62A146506D85FDBD2'
8 | GRANT SELECT ON `util_test`.* TO 'jill'@'user'
9 | Test case 2 - Clone a user to multiple users (using login-path)
10 | # Source on localhost: ... connected.
11 | # Destination on localhost: ... connected.
12 | # Cloning 2 users...
13 | # Cloning amy_nopass@user to user jack:duh@user
14 | # Cloning amy_nopass@user to user john@user
15 | # ...done.
16 | GRANT USAGE ON *.* TO 'jack'@'user' IDENTIFIED BY PASSWORD '*76293EBE39BB165EF83BE0C62A146506D85FDBD2'
17 | GRANT INSERT ON `util_test`.* TO 'jack'@'user'
18 | GRANT USAGE ON *.* TO 'john'@'user'
19 | GRANT INSERT ON `util_test`.* TO 'john'@'user'
20 | Test case 3 - Clone one user to another (using login-path) with only source specified
21 | # Source on localhost: ... connected.
22 | # Cloning 1 users...
23 | # Cloning joe_pass@user to user jill:duh@user
24 | # ...done.
25 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/proc_grep.result:
--------------------------------------------------------------------------------
1 | Test case 1 - find processes for current user format=CSV
2 | Connection,Id,User,Host,Db,Command,Time,State,Info
3 | root[...],XXXXX,root,localhost,,Query,XXXXX,executing,"SELECT
4 | Id, User, Host, Db, Command, Time, State, Info
5 | FROM
6 | INFORMATION_SCHEMA.PROCESSLIST
7 | WHERE
8 | USER LIKE 'root'"
9 | root[...],XXXXX,root,localhost,,Sleep,XXXXX,,
10 |
11 | Test case 2 - find processes for current user format=TAB
12 | Connection Id User Host Db Command Time State Info
13 | root[...]
14 | Id, User, Host, Db, Command, Time, State, Info
15 | FROM
16 | INFORMATION_SCHEMA.PROCESSLIST
17 | WHERE
18 | USER LIKE 'root'"
19 | root[...]
20 |
21 | Test case 3 - find processes for current user format=VERTICAL
22 | ************************* 1. row *************************
23 | Connection: XXXXX
24 | Id: XXXXX
25 | User: root
26 | Host: localhost
27 | Db: None
28 | Command: Query
29 | Time: XXXXX
30 | State: executing
31 | Info: SELECT
32 | Id, User, Host, Db, Command, Time, State, Info
33 | FROM
34 | INFORMATION_SCHEMA.PROCESSLIST
35 | WHERE
36 | USER LIKE 'root'
37 | ************************* 2. row *************************
38 | Connection: XXXXX
39 | Id: XXXXX
40 | User: root
41 | Host: localhost
42 | Db: None
43 | Command: Sleep
44 | Time: XXXXX
45 | State:
46 | Info: None
47 | 2 rows.
48 |
49 | Test case 4 - find processes for current user format=GRID
50 | +---+
51 | | Connection | Id | User | Host | Db | Command | Time | State | Info [...] |
52 | +---+
53 | | root[...] | XXXXX | root | localhost | None | Query | XXXXX | executing | SELECT
54 | Id, User, Host, Db, Command, Time, State, Info
55 | FROM
56 | INFORMATION_SCHEMA.PROCESSLIST
57 | WHERE
58 | USER LIKE 'root' |
59 | | root[...] | XXXXX | root | localhost | None | Sleep | XXXXX | | None |
60 | +---+
61 |
62 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/server_info.result:
--------------------------------------------------------------------------------
1 | Test case 1 - basic serverinfo
2 | # Source on localhost: ... connected.
3 | ************************* 1. row *************************
4 | server: localhost: XXXX
5 | version: XXXX
6 | datadir: XXXX
7 | basedir: XXXX
8 | plugin_dir: XXXX
9 | config_file: XXXX
10 | binary_log: XXXX
11 | binary_log_pos: XXXX
12 | relay_log: XXXX
13 | relay_log_pos: XXXX
14 | 1 rows.
15 | #...done.
16 |
17 | Test case 2 - basic serverinfo with -d option
18 |
19 | Test case 3 - re-started server prints results
20 | # Server is offline.
21 | # Checking server version ... done.
22 | # Starting read-only instance of the server ... done.
23 | # Source on localhost: ... connected.
24 | # Shutting down server ... done.
25 | ************************* 1. row *************************
26 | server: localhost: XXXX
27 | version: XXXX
28 | datadir: XXXX
29 | basedir: XXXX
30 | plugin_dir: XXXX
31 | config_file: XXXX
32 | binary_log: XXXX
33 | binary_log_pos: XXXX
34 | relay_log: XXXX
35 | relay_log_pos: XXXX
36 | 1 rows.
37 | #...done.
38 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/r/server_info_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - no server
2 | Usage: mysqlserverinfo.py --server=user:pass@host:port:socket --format=grid
3 |
4 | mysqlserverinfo.py: error: You must specify at least one server.
5 |
6 | Test case 2 - bad server
7 | ERROR: Server connection values invalid
8 |
9 | Test case 3 - bad format
10 | Usage: mysqlserverinfo.py --server=user:pass@host:port:socket --format=grid
11 |
12 | mysqlserverinfo.py: error: option --format: invalid choice: 'ASDASDASD' (choose from 'grid', 'tab', 'csv', 'vertical')
13 |
14 | Test case 4 - wrong password
15 | ERROR: Access denied for user 'root'@'localhost' using password: YES
16 |
17 | Test case 5 - no password
18 | ERROR: Access denied for user 'root'@'localhost' using password: NO
19 |
20 | Test case 6 - offline server without start, basedir, datadir option
21 | ERROR: Server is offline. To connect, you must also provide basedir, datadir and the start option
22 |
23 | Test case 7 - offline server without start, datadir option
24 | ERROR: Server is offline. To connect, you must also provide datadir and the start option
25 |
26 | Test case 8 - offline server without start option
27 | ERROR: Server is offline. To connect, you must also provide start option
28 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/backtick_data.sql:
--------------------------------------------------------------------------------
1 | # DROP DATABASE IF EXISTS `db``:db`;
2 |
3 | CREATE DATABASE `db``:db`;
4 |
5 | CREATE TABLE `db``:db`.```t``export_1` (`id``` int not null primary key auto_increment, other char(30)) ENGINE=InnoDB;
6 | CREATE TABLE `db``:db`.```t``.``export_2` (`id``` int not null primary key auto_increment, other char(30)) ENGINE=InnoDB;
7 |
8 | INSERT INTO `db``:db`.```t``export_1` (other) VALUES ("@`var``var`");
9 | INSERT INTO `db``:db`.```t``.``export_2` (other) VALUES ("@`var`.`var`");
10 |
11 | USE `db``:db`;
12 |
13 | CREATE FUNCTION `fu``nc`(`a``` TEXT) RETURNS TEXT DETERMINISTIC RETURN `a```;
14 |
15 | # NOTE: There is a bug in MySQL server 5.6.10 when backticks are used to create a trigger
16 | # (i.e., The ACTION_STATEMENT value in INFORMATION_SCHEMA.TRIGGERS is incorrect).
17 | # Uncomment the trigger creation statment in a later release, once the bug is fixed.
18 | # CREATE TRIGGER `trg``1` AFTER INSERT ON `db``:db`.```t``export_1` FOR EACH ROW INSERT INTO `db``:db`.```t``.``export_2` (other) VALUES (`fu``nc`(new.other));
19 |
20 | CREATE PROCEDURE `pr````oc`() INSERT INTO `db``:db`.```t``export_1` (other) VALUES ("proc->trigger->func");
21 |
22 | CREATE VIEW `db``:db`.```v``export_1` as SELECT * FROM `db``:db`.```t``export_1`;
23 |
24 | CREATE EVENT `db``:db`.```e``export_1` ON SCHEDULE EVERY 1 YEAR DISABLE DO DELETE FROM `db``:db`.```t``export_1` WHERE other = "not there";
25 |
26 | GRANT ALL ON `db``:db`.* TO 'joe'@'user';
27 |
28 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/bad_engine.csv:
--------------------------------------------------------------------------------
1 | # Source on localhost: ... connected.
2 | # Exporting metadata from util_test
3 | # TABLES in util_test:
4 | TABLE_SCHEMA,TABLE_NAME,ENGINE,ORDINAL_POSITION,COLUMN_NAME,COLUMN_TYPE,IS_NULLABLE,COLUMN_DEFAULT,COLUMN_KEY,TABLE_COLLATION,CREATE_OPTIONS,CONSTRAINT_NAME,REFERENCED_TABLE_NAME,UNIQUE_CONSTRAINT_NAME,UPDATE_RULE,DELETE_RULE,CONSTRAINT_NAME,COL_NAME,REFERENCED_TABLE_SCHEMA,REFERENCED_COLUMN_NAME
5 | util_test,t1,,1,a,char(30),YES,,,latin1_swedish_ci,,,,,,,,,,
6 | util_test,t2,CAYMAN,1,a,char(30),YES,,,latin1_swedish_ci,,,,,,,,,,
7 | util_test,t3,BOXSTER,1,a,int(11),NO,,PRI,latin1_swedish_ci,,,,,,,PRIMARY,a,,
8 | util_test,t3,BOXSTER,2,b,char(30),YES,,,latin1_swedish_ci,,,,,,,PRIMARY,a,,
9 | util_test,t4,MYISAM,1,c,int(11),NO,,MUL,latin1_swedish_ci,,ref_t3,t3,PRIMARY,RESTRICT,RESTRICT,ref_t3,c,util_test,a
10 | util_test,t4,MYISAM,2,d,int(11),NO,,,latin1_swedish_ci,,ref_t3,t3,PRIMARY,RESTRICT,RESTRICT,ref_t3,c,util_test,a
11 | util_test,t5,,1,c,char(30),YES,,,latin1_swedish_ci,,,,,,,,,,
12 | util_test,t5,,2,b,char(40),YES,,,latin1_swedish_ci,,,,,,,,,,
13 | util_test,t5,,3,a,char(10),YES,,,latin1_swedish_ci,,,,,,,,,,
14 | util_test,t5,,4,d,char(20),YES,,,latin1_swedish_ci,,,,,,,,,,
15 | util_test,t6,CARRERA,1,a,char(30),YES,,,latin1_swedish_ci,,,,,,,,,,
16 | util_test,t7,,1,c,char(30),YES,,,latin1_swedish_ci,,,,,,,,,,
17 | util_test,t8,PANAMERA,1,a,char(30),YES,,,latin1_swedish_ci,,,,,,,,,,
18 | util_test,t9,INNODB,1,c,char(10),YES,,,latin1_swedish_ci,,,,,,,,,,
19 | util_test,t10,,1,b,char(60),YES,,,latin1_swedish_ci,,,,,,,,,,
20 | # done.
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/bad_sql.sql:
--------------------------------------------------------------------------------
1 | CREATE DATABASE util_test;
2 | CREATE TABLES util_test.t1 (a char(30)) ENGINE=MEMORY;
3 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/basic_data.sql:
--------------------------------------------------------------------------------
1 | #
2 | # DROP DATABASE IF EXISTS util_test;
3 | #
4 | CREATE DATABASE util_test;
5 | CREATE TABLE util_test.t1 (a char(30)) ENGINE=MEMORY;
6 | INSERT INTO util_test.t1 VALUES ("01 Test Basic database example");
7 | INSERT INTO util_test.t1 VALUES ("02 Test Basic database example");
8 | INSERT INTO util_test.t1 VALUES ("03 Test Basic database example");
9 | INSERT INTO util_test.t1 VALUES ("04 Test Basic database example");
10 | INSERT INTO util_test.t1 VALUES ("05 Test Basic database example");
11 | INSERT INTO util_test.t1 VALUES ("06 Test Basic database example");
12 | INSERT INTO util_test.t1 VALUES ("07 Test Basic database example");
13 |
14 | CREATE TABLE util_test.t2 (a char(30)) ENGINE=MYISAM;
15 | INSERT INTO util_test.t2 VALUES ("11 Test Basic database example");
16 | INSERT INTO util_test.t2 VALUES ("12 Test Basic database example");
17 | INSERT INTO util_test.t2 VALUES ("13 Test Basic database example");
18 |
19 | CREATE TABLE util_test.t3 (a int not null auto_increment, b char(30), primary key(a)) ENGINE=InnoDB;
20 | INSERT INTO util_test.t3 (b) VALUES ("14 test fkeys");
21 | INSERT INTO util_test.t3 (b) VALUES ("15 test fkeys");
22 | INSERT INTO util_test.t3 (b) VALUES ("16 test fkeys");
23 |
24 | CREATE TABLE util_test.t4 (c int not null, d int not null, CONSTRAINT ref_t3 FOREIGN KEY(c) REFERENCES util_test.t3(a)) ENGINE=InnoDB;
25 | INSERT INTO util_test.t4 VALUES (3, 2);
26 |
27 | CREATE PROCEDURE util_test.p1(p1 CHAR(20)) INSERT INTO util_test.t1 VALUES ("50");
28 |
29 | CREATE TRIGGER util_test.trg AFTER INSERT ON util_test.t1 FOR EACH ROW INSERT INTO util_test.t2 VALUES('Test objects count');
30 |
31 | CREATE FUNCTION util_test.f1() RETURNS INT DETERMINISTIC RETURN (SELECT 1);
32 |
33 | CREATE VIEW util_test.v1 as SELECT * FROM util_test.t1;
34 |
35 | CREATE EVENT util_test.e1 ON SCHEDULE EVERY 1 YEAR DISABLE DO DELETE FROM util_test.t1 WHERE a = "not there";
36 |
37 | GRANT ALL ON util_test.* TO 'joe'@'user';
38 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/basic_users.sql:
--------------------------------------------------------------------------------
1 | DROP DATABASE IF EXISTS util_test;
2 | CREATE DATABASE util_test;
3 | GRANT ALL ON util_test.* TO 'joe_nopass'@'user';
4 | GRANT SELECT ON util_test.* TO 'joe_pass'@'user' IDENTIFIED BY 'dumb';
5 | GRANT INSERT ON util_test.* TO 'amy_nopass'@'user';
6 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/clone_db_inserts.inc:
--------------------------------------------------------------------------------
1 | INSERT INTO util_test.t1 VALUES ("21 Test Basic database example");
2 | INSERT INTO util_test.t1 VALUES ("22 Test Basic database example");
3 | INSERT INTO util_test.t1 VALUES ("23 Test Basic database example");
4 | INSERT INTO util_test.t1 VALUES ("24 Test Basic database example");
5 | INSERT INTO util_test.t1 VALUES ("25 Test Basic database example");
6 | INSERT INTO util_test.t1 VALUES ("26 Test Basic database example");
7 | INSERT INTO util_test.t1 VALUES ("27 Test Basic database example");
8 | INSERT INTO util_test.t2 VALUES ("31 Test Basic database example");
9 | INSERT INTO util_test.t2 VALUES ("32 Test Basic database example");
10 | INSERT INTO util_test.t2 VALUES ("33 Test Basic database example");
11 |
12 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/db_compare_backtick.sql:
--------------------------------------------------------------------------------
1 | DROP DATABASE IF EXISTS `db``:db`;
2 |
3 | CREATE DATABASE `db``:db`;
4 |
5 | CREATE TABLE `db``:db`.```t``export_1` (`id``` int not null primary key auto_increment, other char(30)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
6 | CREATE TABLE `db``:db`.```t``.``export_2` (`id``` int not null primary key auto_increment, other char(30)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
7 |
8 | INSERT INTO `db``:db`.```t``export_1` (other) VALUES ("@`var``var1`");
9 | INSERT INTO `db``:db`.```t``export_1` (other) VALUES ("@`var``var2`");
10 | INSERT INTO `db``:db`.```t``export_1` (other) VALUES ("@`var``var3`");
11 | INSERT INTO `db``:db`.```t``export_1` (other) VALUES ("@`var``var4`");
12 | INSERT INTO `db``:db`.```t``export_1` (other) VALUES ("@`var``var5`");
13 | INSERT INTO `db``:db`.```t``.``export_2` (other) VALUES ("@`var`.`var1`");
14 | INSERT INTO `db``:db`.```t``.``export_2` (other) VALUES ("@`var`.`var2`");
15 | INSERT INTO `db``:db`.```t``.``export_2` (other) VALUES ("@`var`.`var3`");
16 |
17 | USE `db``:db`;
18 |
19 | CREATE VIEW `db``:db`.```v``export_1` as SELECT * FROM `db``:db`.```t``export_1`;
20 |
21 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/fkeys.sql:
--------------------------------------------------------------------------------
1 | #
2 | # DROP DATABASE IF EXISTS util_test_fk;
3 | #
4 | # NOTE: Must load with FKey checks OFF. This is so a1 is 'created' before
5 | # t1 to show proper functioning.
6 | #
7 | CREATE DATABASE util_test_fk;
8 | CREATE TABLE util_test_fk.a1 (a int, b char(20), c int, PRIMARY KEY(a), CONSTRAINT c FOREIGN KEY (c) REFERENCES t1(d)) ENGINE=INNODB;
9 | CREATE TABLE util_test_fk.t1 (d int, b char(20), PRIMARY KEY(d)) ENGINE=INNODB;
10 | INSERT INTO util_test_fk.t1 VALUES (1, 'one'), (2, 'two'), (3, 'three');
11 | INSERT INTO util_test_fk.a1 VALUES (4, 'four', 1), (5, 'five', 2), (6, 'six', 3), (7, NULL, 3);
12 |
13 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/index_test.sql:
--------------------------------------------------------------------------------
1 | CREATE DATABASE util_test_a
2 | CREATE DATABASE util_test_b
3 | CREATE DATABASE util_test_c
4 |
5 | CREATE TABLE util_test_a.`t1` (`A` int(11) NOT NULL DEFAULT '0', `b` varchar(2) DEFAULT NULL, `c` varchar(255) DEFAULT NULL, `d` point NOT NULL, `e` geometry NOT NULL, PRIMARY KEY (`A`), SPATIAL KEY `s1` (`e`), SPATIAL KEY `s2` (`d`), SPATIAL KEY `s4` (`d`)) ENGINE=MyISAM DEFAULT CHARSET=latin1
6 | CREATE TABLE util_test_a.`t2` (`id` int(11) DEFAULT NULL, KEY `id` (`id`) USING HASH) ENGINE=MyISAM DEFAULT CHARSET=latin1
7 | CREATE TABLE util_test_b.`t3` (`id` int(11) DEFAULT NULL, KEY `id` (`id`) USING HASH) ENGINE=MEMORY DEFAULT CHARSET=latin1
8 | CREATE TABLE util_test_b.`t4` (`id` int(11) DEFAULT NULL, KEY `id` (`id`) USING BTREE) ENGINE=MEMORY DEFAULT CHARSET=latin1
9 | CREATE TABLE util_test_c.`t5` (`x` int(11) DEFAULT NULL, `y` varchar(255) DEFAULT NULL, `a` varchar(255) DEFAULT NULL, `b` varchar(255) DEFAULT NULL, `c` varchar(255) DEFAULT NULL, FULLTEXT KEY `ft` (`y`), FULLTEXT KEY `ft1` (`y`), FULLTEXT KEY `ft2` (`a`,`b`,`c`), FULLTEXT KEY `ft3` (`a`,`b`), FULLTEXT KEY `ft4` (`a`,`b`,`y`), FULLTEXT KEY `ft5` (`y`,`a`,`b`), FULLTEXT KEY `ft6` (`c`,`a`,`b`)) ENGINE=MyISAM DEFAULT CHARSET=latin1
10 | CREATE TABLE util_test_c.`t6` (a char(30))
11 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/show_arguments.sh:
--------------------------------------------------------------------------------
1 | echo "# ARGUMENTS PASSED:"
2 | echo "# old master host: " $1
3 | echo "# old master port: " $2
4 | echo "# new master host: " $3
5 | echo "# new master port: " $4
6 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/special_data.sql:
--------------------------------------------------------------------------------
1 | #
2 | # Create a database with special symbols for compatibility testing.
3 | #
4 | CREATE DATABASE util_spec;
5 | CREATE FUNCTION util_spec.spec_date(mydatetime datetime) RETURNS datetime DETERMINISTIC RETURN DATE_FORMAT(mydatetime, '%d/%m %H:%i')
6 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/std_data/transform_data.sql:
--------------------------------------------------------------------------------
1 | #
2 | # This file is a variant of the basic_data.sql file and is used for doing
3 | # compares and generating tests for transofmations.
4 | #
5 | #DROP DATABASE IF EXISTS util_test;
6 | #
7 | CREATE DATABASE util_test;
8 | CREATE TABLE util_test.t1 (a char(30)) ENGINE=MEMORY;
9 | INSERT INTO util_test.t1 VALUES ("01 Test Basic database example");
10 | INSERT INTO util_test.t1 VALUES ("02 Test Basic mod1 database example");
11 | INSERT INTO util_test.t1 VALUES ("03 Test Basic database example");
12 | INSERT INTO util_test.t1 VALUES ("04 Test Basic database example");
13 | INSERT INTO util_test.t1 VALUES ("05 Test Basic mod2 database example");
14 | INSERT INTO util_test.t1 VALUES ("06 Test Basic database example");
15 | INSERT INTO util_test.t1 VALUES ("08 Test Basic database example");
16 |
17 | CREATE TABLE util_test.t2 (a char(30)) ENGINE=MYISAM;
18 | INSERT INTO util_test.t2 VALUES ("11 Test Basic database example");
19 | INSERT INTO util_test.t2 VALUES ("12 modified Basic database example");
20 | INSERT INTO util_test.t2 VALUES ("13 Test Basic database example");
21 |
22 | CREATE TABLE util_test.t3 (a int not null auto_increment, d char(30), primary key(a)) ENGINE=MYISAM;
23 | INSERT INTO util_test.t3 (d) VALUES ("14 test fkeys");
24 | INSERT INTO util_test.t3 (d) VALUES ("15 test fkeys");
25 | INSERT INTO util_test.t3 (d) VALUES ("16 test fkeys");
26 |
27 | CREATE TABLE util_test.t4 (c int not null, d int not null) ENGINE=MYISAM;
28 | INSERT INTO util_test.t4 VALUES (3, 2);
29 |
30 | CREATE PROCEDURE util_test.p1(p1 CHAR(20)) INSERT INTO util_test.t2 VALUES ("100");
31 |
32 | CREATE TRIGGER util_test.trg BEFORE UPDATE ON util_test.t1 FOR EACH ROW INSERT INTO util_test.t1 VALUES('Wax on, wax off');
33 |
34 | CREATE FUNCTION util_test.f1() RETURNS INT DETERMINISTIC RETURN (SELECT -1);
35 |
36 | CREATE VIEW util_test.v1 as SELECT * FROM util_test.t2;
37 |
38 | GRANT ALL ON util_test.* TO 'joe'@'user';
39 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/experimental/r/t2.result:
--------------------------------------------------------------------------------
1 | Line 1
2 | Line 2
3 | Line 3
4 | Line 4
5 | Line 5
6 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/experimental/r/t4.result:
--------------------------------------------------------------------------------
1 | Wack-a-mole 1
2 | Wack-a-mole 2
3 | Wack-a-mole 3
4 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/experimental/t/t1.py:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 | #
4 | # This program is free software; you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation; version 2 of the License.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program; if not, write to the Free Software
15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 | #
17 | import os
18 | import mutlib
19 |
20 | class test(mutlib.System_test):
21 | """Experimental test #1
22 | This is a demonstration of running a simple execution and supplying a
23 | test result file for comparison. This example compares return code only
24 | supplying a custom result to be displayed to the user on failure.
25 | """
26 |
27 | def check_prerequisites(self):
28 | return self.check_num_servers(1)
29 |
30 | def setup(self):
31 | return True
32 |
33 | def run(self):
34 | #
35 | # Note: comment out the following line and uncomment the next line
36 | # to see an unsuccessful test run
37 | #
38 | cmd = "mysqlserverclone.py --help"
39 | #cmd = "NOTREALLYTHEREATALL!"
40 | self.result = self.exec_util(cmd, "./result.txt")
41 | return True
42 |
43 | def get_result(self):
44 | str = None
45 | if self.result != 0:
46 | str = "Unexpected return code: %d\n" % (self.result)
47 | return (self.result == 0, str)
48 |
49 | def record(self):
50 | # Not a comparative test, returning True
51 | return True
52 |
53 | def cleanup(self):
54 | os.unlink("./result.txt")
55 | return True
56 |
57 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/experimental/t/t3.py:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 | #
4 | # This program is free software; you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation; version 2 of the License.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program; if not, write to the Free Software
15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 | #
17 | import mutlib
18 |
19 | class test(mutlib.System_test):
20 | """Experimental test #3
21 | This example tests the return codes for the methods. Uncomment out the
22 | False returns and comment out the True returns to see failed execution.
23 | """
24 |
25 | def check_prerequisites(self):
26 | return True
27 | #return False
28 |
29 | def setup(self):
30 | return True
31 | #return False
32 |
33 | def run(self):
34 | return True
35 | #return False
36 |
37 | def get_result(self):
38 | return (True, None)
39 | #return (False, "Test message\nAnother test message\n")
40 |
41 | def record(self):
42 | # Not a comparative test, returning True
43 | return True
44 | #return False
45 |
46 | def cleanup(self):
47 | return True
48 | #return False
49 |
50 |
51 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/experimental/t/t4.py:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 | #
4 | # This program is free software; you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation; version 2 of the License.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program; if not, write to the Free Software
15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 | #
17 | import t2
18 |
19 | class test(t2.test):
20 | """Experimental test #4
21 | This is a demonstration of how to reuse other tests to run additional
22 | test cases. This is a sample test using comparative results.
23 | In this test, we reuse the test 't2' and simulate running a different
24 | utility. We reuse the prerequisite, setup, and cleanup of t2.
25 | """
26 |
27 | def check_prerequisites(self):
28 | return t2.test.check_prerequisites(self)
29 |
30 | def setup(self):
31 | return t2.test.setup(self)
32 |
33 | def run(self):
34 |
35 | # A result list will be generated here by the callee.
36 | self.ret_val = []
37 | self.ret_val.append("Wack-a-mole 1\n")
38 | # Note: comment out the next line and uncomment out the following line
39 | # to see an unsuccessful test run
40 | self.ret_val.append("Wack-a-mole 2\n")
41 | #self.ret_val.append("Something hinky happened here\n")
42 | self.ret_val.append("Wack-a-mole 3\n")
43 | return True
44 |
45 | def get_result(self):
46 | return self.compare(__name__, self.ret_val)
47 |
48 | def record(self):
49 | return self.save_result_file(__name__, self.ret_val)
50 |
51 | def cleanup(self):
52 | return t2.test.cleanup(self)
53 |
54 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/performance/r/copy_db_multithreaded.result:
--------------------------------------------------------------------------------
1 | Test case 1 - copy a sample database
2 | # Source on localhost: ... connected.
3 | # Destination on localhost: ... connected.
4 | # Copying database employees renamed as emp_mt
5 | # Copying TABLE employees.departments
6 | # Copying data for TABLE employees.departments
7 | # Copying TABLE employees.dept_emp
8 | # Copying data for TABLE employees.dept_emp
9 | # Copying TABLE employees.dept_manager
10 | # Copying data for TABLE employees.dept_manager
11 | # Copying TABLE employees.employees
12 | # Copying data for TABLE employees.employees
13 | # Copying TABLE employees.salaries
14 | # Copying data for TABLE employees.salaries
15 | # Copying TABLE employees.titles
16 | # Copying data for TABLE employees.titles
17 | #...done.
18 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/check_gtid_version.result:
--------------------------------------------------------------------------------
1 | Test case 1 attempt failed gtid version check
2 | # Source on localhost: ... connected.
3 | ERROR: The server localhost:XXXXX does not comply to the latest GTID feature support. Errors:
4 | Server version must be 5.6.9 or greater.
5 | Missing gtid_executed system variable.
6 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/check_rpl_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - master parameter invalid
2 | Usage: mysqlrplcheck.py --master=root@localhost:3306 --slave=root@localhost:3310
3 |
4 | mysqlrplcheck.py: error: Master connection values invalid
5 | Test case 2 - slave parameter invalid
6 | Usage: mysqlrplcheck.py --master=root@localhost:3306 --slave=root@localhost:3310
7 |
8 | mysqlrplcheck.py: error: Slave connection values invalid
9 | Test case 3 - same server literal specification
10 | Usage: mysqlrplcheck.py --master=root@localhost:3306 --slave=root@localhost:3310
11 |
12 | mysqlrplcheck.py: error: The master and slave are the same host and port.
13 | Test case 4 - error: invalid login to server (master)
14 | # master on nada: ... ERROR: Cannot connect to the master server.
15 | Error ####: Can't connect to local MySQL server ####...
16 | Test case 5 - error: invalid login to server (slave)
17 | # master on localhost: ... connected.
18 | # slave on nada: ... ERROR: Cannot connect to the slave server.
19 | Error ####: Can't connect to local MySQL server ####...
20 | Test case 6 - master and slave same host
21 | Usage: mysqlrplcheck.py --master=root@localhost:3306 --slave=root@localhost:3310
22 |
23 | mysqlrplcheck.py: error: The master and slave are the same host and port.
24 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/clone_db_rpl_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - error: --rpl-user=root but no --rpl
2 | Usage: mysqldbcopy.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket orig_db:new_db
3 |
4 | mysqldbcopy.py: error: You cannot use the --rpl option for copying on the same server.
5 | Test case 2 - error: using --rpl with cloning
6 | Usage: mysqldbcopy.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket orig_db:new_db
7 |
8 | mysqldbcopy.py: error: You cannot use the --rpl option for copying on the same server.
9 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/copy_db_gtid.result:
--------------------------------------------------------------------------------
1 | Test case 1 gtid->gtid
2 | # GTID operation: SET @MYSQLUTILS_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN;
3 | # GTID operation: SET @@SESSION.SQL_LOG_BIN = 0;
4 | # GTID operation: SET @@GLOBAL.GTID_PURGED = ?
5 | # GTID operation: SET @@SESSION.SQL_LOG_BIN = @MYSQLUTILS_TEMP_LOG_BIN;
6 | Test case 2 gtid->non_gtid
7 | # WARNING: The destination server does not support GTIDs yet the source server does support GTIDs. To suppress this warning, use the --skip-gtid option when copying to a non-GTID enabled server.
8 | Test case 3 non_gtid->gtid
9 | # WARNING: The source server does not support GTIDs yet the destination server does support GTIDs. To suppress this warning, use the --skip-gtid option when copying from a non-GTID enabled server.
10 | Test case 4 partial backup
11 | # WARNING: A partial copy from a server that has GTIDs enabled will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to generate the GTID statement, use the --skip-gtid option. To export all databases, use the --all option and do not specify a list of databases.
12 | # GTID operation: SET @MYSQLUTILS_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN;
13 | # GTID operation: SET @@SESSION.SQL_LOG_BIN = 0;
14 | # GTID operation: SET @@GLOBAL.GTID_PURGED = ?
15 | # GTID operation: SET @@SESSION.SQL_LOG_BIN = @MYSQLUTILS_TEMP_LOG_BIN;
16 | Test case 5 skip gtids
17 | # WARNING: The server supports GTIDs but you have elected to skip exexcuting the GTID_EXECUTED statement. Please refer to the MySQL online reference manual for more information about how to handle GTID enabled servers with backup and restore operations.
18 | Test case 6 gtid_executed error
19 | ERROR: The copy operation contains GTID statements that require the global gtid_executed system variable on the target to be empty (no value). The gtid_executed value must be reset by issuing a RESET MASTER command on the target prior to attempting the copy operation. Once the global gtid_executed value is cleared, you may retry the copy.
20 | Test case 7 fixed empty gtid_executed error
21 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/copy_db_rpl_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - error: --rpl=both
2 | Usage: mysqldbcopy.py --source=user:pass@host:port:socket --destination=user:pass@host:port:socket orig_db:new_db
3 |
4 | mysqldbcopy.py: error: option --rpl: invalid choice: 'both' (choose from 'master', 'slave')
5 | Test case 2 - warning: --rpl-user missing
6 | # Source on localhost: ... connected.
7 | # Destination on localhost: ... connected.
8 | ERROR: No --rpl-user specified and multiple users found with replication privileges.
9 | Test case 3 - error: --rpl-user missing user
10 | # Source on localhost: ... connected.
11 | # Destination on localhost: ... connected.
12 | ERROR: The replication user missing@localhost was not found on localhost:PORT1.
13 | Test case 4 - error: --rpl-user missing privileges
14 | # Source on localhost: ... connected.
15 | # Destination on localhost: ... connected.
16 | ERROR: Replication user does not have the correct privilege. She needs 'REPLICATION SLAVE' on all replicated databases.
17 | Test case 5 - error: slave not connected
18 | # Source on localhost: ... connected.
19 | # Destination on localhost: ... connected.
20 | ERROR: Cannot generate CHANGE MASTER command. The slave is not connected to a master and no master information was provided.
21 | Test case 6 - error: no binlog
22 | # Source on localhost: ... connected.
23 | ERROR: Master must have binary logging turned on.
24 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/export_rpl_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - error: --rpl-file=test.txt but no --rpl
2 | Usage: mysqldbexport.py --server=user:pass@host:port:socket db1, db2, db3
3 |
4 | mysqldbexport.py: error: The --rpl-file option must be used with the --rpl option.
5 | Test case 2 - error: --comment-rpl but no --rpl
6 | Usage: mysqldbexport.py --server=user:pass@host:port:socket db1, db2, db3
7 |
8 | mysqldbexport.py: error: The --comment-rpl option must be used with the --rpl option.
9 | Test case 3 - error: --rpl-user=root but no --rpl
10 | Usage: mysqldbexport.py --server=user:pass@host:port:socket db1, db2, db3
11 |
12 | mysqldbexport.py: error: The --rpl-user option must be used with the --rpl option.
13 | Test case 4 - error: --rpl-file=test.txt --comment-rpl --rpl-user=root but no --rpl
14 | Usage: mysqldbexport.py --server=user:pass@host:port:socket db1, db2, db3
15 |
16 | mysqldbexport.py: error: The --rpl-file, --rpl-user, --comment-rpl options must be used with the --rpl option.
17 | Test case 5 - error: --rpl-file bad path
18 | # Source on localhost: ... connected.
19 | ERROR: File inaccessible or bad path: /bad/path/not/there.atall
20 | Test case 6 - warning: --rpl-user missing
21 | # Source on localhost: ... connected.
22 | STOP SLAVE;
23 | #...done.
24 | # Connecting to the current server as master
25 | # WARNING: No --rpl-user specified and multiple users found with replication privileges.
26 | CHANGE MASTER
27 | START SLAVE;
28 | Test case 7 - error: --rpl-user missing user
29 | # Source on localhost: ... connected.
30 | ERROR: The replication user missing@localhost was not found on localhost:PORT1.
31 | Test case 8 - error: --rpl-user missing privileges
32 | # Source on localhost: ... connected.
33 | ERROR: Replication user does not have the correct privilege. She needs 'REPLICATION SLAVE' on all replicated databases.
34 | Test case 9 - error: slave not connected
35 | # Source on localhost: ... connected.
36 | ERROR: Cannot generate CHANGE MASTER command. The slave is not connected to a master and no master information was provided.
37 | Test case 10 - error: no binlog
38 | # Source on localhost: ... connected.
39 | ERROR: Master must have binary logging turned on.
40 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/failover_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - No master
2 | Usage: mysqlfailover.py --master=root@localhost --discover-slaves-login=root --candidates=root@host123:3306,root@host456:3306
3 |
4 | mysqlfailover.py: error: You must specify a master to monitor.
5 | Test case 2 - No slaves or discover-slaves-login
6 | Usage: mysqlfailover.py --master=root@localhost --discover-slaves-login=root --candidates=root@host123:3306,root@host456:3306
7 |
8 | mysqlfailover.py: error: You must supply a list of slaves or the --discover-slaves-login option.
9 | Test case 3 - Low value for interval.
10 | Usage: mysqlfailover.py --master=root@localhost --discover-slaves-login=root --candidates=root@host123:3306,root@host456:3306
11 |
12 | mysqlfailover.py: error: The --interval option requires a value greater than or equal to 5.
13 | Test case 4 - elect mode but no candidates
14 | Usage: mysqlfailover.py --master=root@localhost --discover-slaves-login=root --candidates=root@host123:3306,root@host456:3306
15 |
16 | mysqlfailover.py: error: Failover mode = 'elect' reqiures at least one candidate.
17 | Test case 5 - FILE/TABLE mix and missing --rpl-user
18 | NOTE: Log file 'a.txt' does not exist. Will be created.
19 | # Checking privileges.
20 | ERROR: Failover requires --master-info-repository=TABLE for all slaves.
21 | Test case 6 - Master listed as a slave - literal
22 | Usage: mysqlfailover.py --master=root@localhost --discover-slaves-login=root --candidates=root@host123:3306,root@host456:3306
23 |
24 | mysqlfailover.py: error: The master and one of the slaves are the same host and port.
25 | Test case 7 - Master listed as a slave - alias
26 | Usage: mysqlfailover.py --master=root@localhost --discover-slaves-login=root --candidates=root@host123:3306,root@host456:3306
27 |
28 | mysqlfailover.py: error: The master and one of the slaves are the same host and port.
29 | Test case 8 - Master listed as a candiate - alias
30 | Usage: mysqlfailover.py --master=root@localhost --discover-slaves-login=root --candidates=root@host123:3306,root@host456:3306
31 |
32 | mysqlfailover.py: error: The master and one of the candidates are the same host and port.
33 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/gtid_no_password.result:
--------------------------------------------------------------------------------
1 | +------------+-------+---------+--------+------------+---------+
2 | | host | port | role | state | gtid_mode | health |
3 | +------------+-------+---------+--------+------------+---------+
4 | | localhost | PORT1 | MASTER | UP | ON | OK |
5 | | localhost | PORT2 | SLAVE | UP | ON | OK |
6 | +------------+-------+---------+--------+------------+---------+
7 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/rpl_admin_logfile.result:
--------------------------------------------------------------------------------
1 | Test Case 1 - Log file is newly created
2 | NOTE: Log file 'temp_log.txt' does not exist. Will be created.
3 | # Checking privileges.
4 | #
5 | # Replication Topology Health:
6 | +------------+-------+---------+--------+------------+---------+
7 | | host | port | role | state | gtid_mode | health |
8 | +------------+-------+---------+--------+------------+---------+
9 | | localhost | PORT1 | MASTER | UP | NO | OK |
10 | | localhost | PORT2 | SLAVE | UP | NO | OK |
11 | +------------+-------+---------+--------+------------+---------+
12 | # ...done.
13 | Test Case 2 - Log file is reopened
14 | # Checking privileges.
15 | #
16 | # Replication Topology Health:
17 | +------------+-------+---------+--------+------------+---------+
18 | | host | port | role | state | gtid_mode | health |
19 | +------------+-------+---------+--------+------------+---------+
20 | | localhost | PORT1 | MASTER | UP | NO | OK |
21 | | localhost | PORT2 | SLAVE | UP | NO | OK |
22 | +------------+-------+---------+--------+------------+---------+
23 | # ...done.
24 | Test Case 3 - Log file can not be written to
25 | Usage: mysqlrpladmin.py --slaves=root@localhost:3306
26 |
27 | mysqlrpladmin.py: error: Error opening log file: Permission denied
28 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/rpl_admin_warnings.result:
--------------------------------------------------------------------------------
1 | Test case 1 - warning for --exec* and not switchover or failover
2 | WARNING: The --exec-* options are used only with the failover and switchover commands.
3 | host,port,role,state,gtid_mode,health
4 | localhost,PORT1,MASTER,UP,OFF,OK
5 | localhost,PORT2,SLAVE,UP,OFF,OK
6 | localhost,PORT3,SLAVE,UP,OFF,OK
7 | localhost,PORT4,SLAVE,UP,OFF,OK
8 | Test case 2 - warning for --candidate and not switchover
9 | WARNING: The --candidates option is used only with the failover and elect commands.
10 | host,port,role,state,gtid_mode,health
11 | localhost,PORT1,MASTER,UP,OFF,OK
12 | localhost,PORT2,SLAVE,UP,OFF,OK
13 | localhost,PORT3,SLAVE,UP,OFF,OK
14 | localhost,PORT4,SLAVE,UP,OFF,OK
15 | Test case 3 - warning for --new-master and not switchover
16 | WARNING: The --new-master option is used only with the switchover command.
17 | host port role state gtid_mode health
18 | localhost PORT1 MASTER UP OFF OK
19 | localhost PORT2 SLAVE UP OFF OK
20 | localhost PORT3 SLAVE UP OFF OK
21 | localhost PORT4 SLAVE UP OFF OK
22 | Test case 4 - warning for missing --report-host
23 | # Discovering slaves for master at localhost:PORT1
24 | WARNING: There are slaves that have not been registered with --report-host or --report-port.
25 | # Checking privileges.
26 | #
27 | # Replication Topology Health:
28 | host,port,role,state,gtid_mode,health
29 | localhost,PORT1,MASTER,UP,OFF,OK
30 | localhost,PORT2,SLAVE,UP,OFF,OK
31 | localhost,PORT3,SLAVE,UP,OFF,OK
32 | localhost,PORT4,SLAVE,UP,OFF,OK
33 | # ...done.
34 | Test case 5 - warning for --format and not health or gtid
35 | WARNING: The --format option is used only with the health and gtid commands.
36 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/show_rpl_errors.result:
--------------------------------------------------------------------------------
1 | Test case 1 - error: cannot parse master string
2 | Usage: mysqlrplshow.py --master=root@localhost:3306
3 |
4 | mysqlrplshow.py: error: Master connection values invalid
5 | Test case 2 - error: invalid login to master
6 | # master on localhost: ... FAILED.
7 |
8 | ERROR: Cannot connect to the master server.
9 | Error 1045: Access denied for user 'wanda'@'localhost' (using password: YES)
10 | Test case 3 - show topology - bad format
11 | Usage: mysqlrplshow.py --master=root@localhost:3306
12 |
13 | mysqlrplshow.py: error: option --format: invalid choice: 'XXXXXX' (choose from 'grid', 'tab', 'csv', 'vertical')
14 | Test case 4a - show topology - not enough permissions
15 | # master on localhost: ... connected.
16 | ERROR: Not enough permissions. The user must have the REPLICATION SLAVE privilege.
17 | Test case 4b - show topology - not enough permissions
18 | # master on localhost: ... connected.
19 | # Finding slaves for master: localhost:PORT2
20 | # master on localhost: ... connected.
21 | # Finding slaves for master: localhost:PORT1
22 |
23 | # Replication Topology Graph
24 | localhost:PORT2 (MASTER)
25 | |
26 | +--- localhost:PORT1 - (SLAVE)
27 |
28 | +-----------------+-----------------+
29 | | Master | Slave |
30 | +-----------------+-----------------+
31 | | localhost:PORT2 | localhost:PORT1 |
32 | +-----------------+-----------------+
33 | Test case 5 - show topology - bad max-depth
34 | Usage: mysqlrplshow.py --master=root@localhost:3306
35 |
36 | mysqlrplshow.py: error: The --max-depth option needs to be >= 0.
37 | Test case 6 - show topology - large max-depth
38 | # master on localhost: ... connected.
39 | # Finding slaves for master: localhost:PORT2
40 | # master on localhost: ... connected.
41 | # Finding slaves for master: localhost:PORT1
42 |
43 | # Replication Topology Graph
44 | localhost:PORT2 (MASTER)
45 | |
46 | +--- localhost:PORT1 - (SLAVE)
47 |
48 | +-----------------+-----------------+
49 | | Master | Slave |
50 | +-----------------+-----------------+
51 | | localhost:PORT2 | localhost:PORT1 |
52 | +-----------------+-----------------+
53 | Test case 7 - show topology - discover-slaves-login missing
54 | Usage: mysqlrplshow.py --master=root@localhost:3306
55 |
56 | mysqlrplshow.py: error: The --discover-slaves-login is required to test slave connectivity.
57 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/r/show_rpl_warnings.result:
--------------------------------------------------------------------------------
1 | Test case 1 - warning for missing --report-host
2 | # master on localhost: ... connected.
3 | # Finding slaves for master: localhost:PORT1
4 | WARNING: There are slaves that have not been registered with --report-host or --report-port.
5 |
6 | # Replication Topology Graph
7 | localhost:PORT1 (MASTER)
8 | |
9 | +--- localhost:PORT2 - (SLAVE)
10 | |
11 | +--- localhost:PORT3 - (SLAVE)
12 | |
13 | +--- localhost:PORT4 - (SLAVE)
14 |
15 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/suite/replication/t/failover_parameters.py:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 | #
4 | # This program is free software; you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation; version 2 of the License.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program; if not, write to the Free Software
15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 | #
17 | import os
18 | import mutlib
19 | from mysql.utilities.exception import MUTLibError
20 |
21 | class test(mutlib.System_test):
22 | """test replication failover utility
23 | This test runs the mysqlfailover utility parameters on a known topology.
24 | """
25 |
26 | def check_prerequisites(self):
27 | return self.check_num_servers(1)
28 |
29 | def setup(self):
30 | return True
31 |
32 | def run(self):
33 | self.res_fname = "result.txt"
34 |
35 | cmd_str = "mysqlfailover.py "
36 |
37 | comment = "Test case 1 - show help"
38 | cmd_opts = " --help"
39 | res = mutlib.System_test.run_test_case(self, 0, cmd_str+cmd_opts,
40 | comment)
41 | if not res:
42 | raise MUTLibError("%s: failed" % comment)
43 |
44 | return True
45 |
46 | def get_result(self):
47 | return self.compare(__name__, self.results)
48 |
49 | def record(self):
50 | return self.save_result_file(__name__, self.results)
51 |
52 | def cleanup(self):
53 | if self.res_fname:
54 | try:
55 | os.unlink(self.res_fname)
56 | except:
57 | pass
58 | return True
59 |
60 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql-test/t/__init__.py:
--------------------------------------------------------------------------------
1 | from mutlib.mutlib import Server_list
2 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiepaup/dbatools/8549f2571aaee6a39f5c6f32179ac9c5d301a9aa/mysqlTools/mysql_utilities/mysql/__init__.py
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiepaup/dbatools/8549f2571aaee6a39f5c6f32179ac9c5d301a9aa/mysqlTools/mysql_utilities/mysql/__init__.pyc
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql/utilities/__init__.py:
--------------------------------------------------------------------------------
1 | # Major, Minor, Patch, Status
2 | VERSION = (1, 2, 1, "", 5, 2, 47)
3 | VERSION_STRING = "%s.%s.%s%s - MySQL Workbench Distribution %s.%s.%s" % VERSION
4 | RELEASE_STRING = "%s.%s.%s%s - MySQL Workbench Distribution %s.%s.%s" % VERSION
5 | COPYRIGHT = "2010, 2013 Oracle and/or its affiliates. All rights reserved."
6 | COPYRIGHT_FULL = "Copyright (c) " + COPYRIGHT + """
7 | This is a release of dual licensed MySQL Utilities. For the avoidance of
8 | doubt, this particular copy of the software is released
9 | under the version 2 of the GNU General Public License.
10 | MySQL Utilities is brought to you by Oracle.
11 | """
12 | VERSION_FRM = ("MySQL Utilities {program} version " + RELEASE_STRING
13 | + "\n" + COPYRIGHT_FULL)
14 | PYTHON_MIN_VERSION = (2, 6, 0)
15 | PYTHON_MAX_VERSION = (3, 0, 0)
16 |
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql/utilities/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiepaup/dbatools/8549f2571aaee6a39f5c6f32179ac9c5d301a9aa/mysqlTools/mysql_utilities/mysql/utilities/__init__.pyc
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql/utilities/command/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiepaup/dbatools/8549f2571aaee6a39f5c6f32179ac9c5d301a9aa/mysqlTools/mysql_utilities/mysql/utilities/command/__init__.py
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql/utilities/common/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiepaup/dbatools/8549f2571aaee6a39f5c6f32179ac9c5d301a9aa/mysqlTools/mysql_utilities/mysql/utilities/common/__init__.py
--------------------------------------------------------------------------------
/mysqlTools/mysql_utilities/mysql/utilities/common/pattern_matching.py:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
3 | #
4 | # This program is free software; you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation; version 2 of the License.
7 | #
8 | # This program is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program; if not, write to the Free Software
15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 | #
17 |
18 | """
19 | This file contains auxiliary functions to handle pattern matching.
20 | """
21 |
22 | import re
23 |
24 |
25 | def convertSQL_LIKE2REGEXP(sql_like_pattern):
26 | """Convert a standard SQL LIKE pattern to a REGEXP pattern.
27 |
28 | Function that transforms a SQL LIKE pattern to a supported python
29 | regexp. Returns a python regular expression (i.e. regexp).
30 |
31 | sql_like_pattern[in] pattern in the SQL LIKE form to be converted.
32 | """
33 | # Replace '_' by equivalent regexp, except when precede by '\'
34 | # (escape character)
35 | regexp = re.sub(r'(?
24 | 18:00:33 26749 1972 multilog >
25 | 18:00:33 26749 1972 multilog >
26 | 18:00:33 26751 ? mkdir >
27 | 18:00:33 26749 1972 multilog >
28 | 18:00:33 26752 ? chown >
29 | 18:00:33 26750 1961 multilog >
30 | 18:00:33 26750 1961 multilog >
31 | 18:00:34 26753 1961 multilog >
32 | 18:00:34 26754 1972 multilog >
33 | [...]
34 |
35 | This will be fixed in a later version, but likely requires some kernel or
36 | tracer changes first (fetching cmdline as the probe fires).
37 |
38 |
39 | The previous examples were on Linux 3.14 and 3.16 kernels. Here's a 3.2 system
40 | I'm running:
41 |
42 | # ./execsnoop
43 | ERROR: enabling tracepoint "sched:sched_process_exec" (tracepoint missing in this kernel version?) at ./execsnoop line 78.
44 |
45 | This kernel version is missing the sched_process_exec probe, which is pretty
46 | annoying.
47 |
--------------------------------------------------------------------------------
/osperftools/examples/opensnoop_example.txt:
--------------------------------------------------------------------------------
1 | Demonstrations of opensnoop, the Linux ftrace version.
2 |
3 |
4 | # ./opensnoop
5 | Tracing open()s. Ctrl-C to end.
6 | COMM PID FD FILE
7 | opensnoop 5334 0x3
8 | <...> 5343 0x3 /etc/ld.so.cache
9 | opensnoop 5342 0x3 /etc/ld.so.cache
10 | <...> 5343 0x3 /lib/x86_64-linux-gnu/libc.so.6
11 | opensnoop 5342 0x3 /lib/x86_64-linux-gnu/libm.so.6
12 | opensnoop 5342 0x3 /lib/x86_64-linux-gnu/libc.so.6
13 | <...> 5343 0x3 /usr/lib/locale/locale-archive
14 | <...> 5343 0x3 trace_pipe
15 | supervise 1684 0x9 supervise/status.new
16 | supervise 1684 0x9 supervise/status.new
17 | supervise 1688 0x9 supervise/status.new
18 | supervise 1688 0x9 supervise/status.new
19 | supervise 1686 0x9 supervise/status.new
20 | supervise 1685 0x9 supervise/status.new
21 | supervise 1685 0x9 supervise/status.new
22 | supervise 1686 0x9 supervise/status.new
23 | [...]
24 |
25 | The first several lines show opensnoop catching itself initializing.
26 |
27 |
28 | Use -h to print the USAGE message:
29 |
30 | # ./opensnoop -h
31 | USAGE: opensnoop [-htx] [-d secs] [-p PID] [-T TID] [-n name] [filename]
32 | -d seconds # trace duration, and use buffers
33 | -n name # process name to match on open
34 | -p PID # PID to match on open
35 | -L TID # thread id to match on open
36 | -t # include time (seconds)
37 | -x # only show failed opens
38 | -h # this usage message
39 | filename # match filename (partials, REs, ok)
40 | eg,
41 | opensnoop # watch open()s live (unbuffered)
42 | opensnoop -d 1 # trace 1 sec (buffered)
43 | opensnoop -p 181 # trace I/O issued by PID 181 only
44 | opensnoop conf # trace filenames containing "conf"
45 | opensnoop 'log$' # filenames ending in "log"
46 |
47 | See the man page and example file for more info.
48 |
--------------------------------------------------------------------------------
/osperftools/images/perf-tools_2016.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiepaup/dbatools/8549f2571aaee6a39f5c6f32179ac9c5d301a9aa/osperftools/images/perf-tools_2016.png
--------------------------------------------------------------------------------
/osperftools/man/man8/funccount.8:
--------------------------------------------------------------------------------
1 | .TH funccount 8 "2014-07-19" "USER COMMANDS"
2 | .SH NAME
3 | funccount \- count kernel function calls matching specified wildcards. Uses Linux ftrace.
4 | .SH SYNOPSIS
5 | .B funccount
6 | [\-hT] [\-i secs] [\-d secs] [\-t top] funcstring
7 | .SH DESCRIPTION
8 | This tool is a quick way to determine which kernel functions are being called,
9 | and at what rate. It uses ftrace function profiling capabilities.
10 |
11 | WARNING: This uses dynamic tracing of (what can be many) kernel functions,
12 | and could cause kernel panics or freezes. Test, and know what you are doing,
13 | before use.
14 |
15 | Since this uses ftrace, only the root user can use this tool.
16 | .SH REQUIREMENTS
17 | CONFIG_FUNCTION_PROFILER, which you may already have enabled and available on
18 | recent kernels, and awk.
19 | .SH OPTIONS
20 | \-d seconds
21 | Total duration of the trace.
22 | .TP
23 | \-h
24 | Print usage message.
25 | .TP
26 | \-i seconds
27 | Print an interval summary every so many seconds.
28 | .TP
29 | \-t top
30 | Print top number of entries only.
31 | .TP
32 | \-T
33 | Include timestamp on each summary.
34 | .TP
35 | funcstring
36 | A function name to trace, which may include file glob style wildcards ("*") at
37 | the beginning or ending of a string only. Eg, "vfs*" means match "vfs" followed
38 | by anything.
39 | .SH EXAMPLES
40 | .TP
41 | Count every kernel function beginning with "bio_", until Ctrl-C is hit:
42 | #
43 | .B funccount 'bio_*'
44 | .TP
45 | Count every "tcp_*" kernel function, and print a summary every one second, five in total:
46 | #
47 | .B funccount \-i 1 \-d 5 'tcp_*'
48 | .TP
49 | Count every "ext4*" kernel function, and print the top 20 when Ctrl-C is hit:
50 | #
51 | .B funccount \-t 20 'ext4*'
52 | .SH FIELDS
53 | .TP
54 | FUNC
55 | Kernel function name.
56 | .TP
57 | COUNT
58 | Number of times this function was called during the tracing interval.
59 | .SH OVERHEAD
60 | This uses the ftrace profiling framework, which does in-kernel counts,
61 | lowering the overhead (compared to tracing each event).
62 | .SH SOURCE
63 | This is from the perf-tools collection:
64 | .IP
65 | https://github.com/brendangregg/perf-tools
66 | .PP
67 | Also look under the examples directory for a text file containing example
68 | usage, output, and commentary for this tool.
69 | .SH OS
70 | Linux
71 | .SH STABILITY
72 | Unstable - in development.
73 | .SH AUTHOR
74 | Brendan Gregg
75 | .SH SEE ALSO
76 | functrace(8)
77 |
--------------------------------------------------------------------------------
/osperftools/man/man8/reset-ftrace.8:
--------------------------------------------------------------------------------
1 | .TH reset-ftrace 8 "2014-07-07" "USER COMMANDS"
2 | .SH NAME
3 | reset-ftrace \- reset state of ftrace, disabling all tracing. Written for Linux ftrace.
4 | .SH SYNOPSIS
5 | .B reset-ftrace
6 | [\-fhq]
7 | .SH DESCRIPTION
8 | This resets the state of various ftrace files, and shows the before and after
9 | state.
10 |
11 | This may only be of use to ftrace hackers who, in the process of developing
12 | ftrace software, often get the subsystem into a partially active state, and
13 | would like a quick way to reset state. Check the end of this script for the
14 | actually files reset, and add more if you need.
15 |
16 | WARNING: Only use this if and when you are sure that there are no other active
17 | ftrace sessions on your system, as otherwise it will kill them.
18 | .SH REQUIREMENTS
19 | FTRACE CONFIG.
20 | .SH OPTIONS
21 | .TP
22 | \-f
23 | Force. If the ftrace lock file exists (/var/tmp/.ftrace-lock), delete it.
24 | .TP
25 | \-h
26 | Print usage message.
27 | .TP
28 | \-q
29 | Quiet. Run, but don't print any output.
30 | .SH EXAMPLES
31 | .TP
32 | Reset various ftrace files:
33 | #
34 | .B reset-ftrace
35 | .SH SOURCE
36 | This is from the perf-tools collection.
37 | .IP
38 | https://github.com/brendangregg/perf-tools
39 | .PP
40 | Also look under the examples directory for a text file containing example
41 | usage, output, and commentary for this tool.
42 | .SH OS
43 | Linux
44 | .SH STABILITY
45 | Unstable - in development.
46 | .SH AUTHOR
47 | Brendan Gregg
48 | .SH SEE ALSO
49 | perf(1)
50 |
--------------------------------------------------------------------------------
/redisTools/README.me:
--------------------------------------------------------------------------------
1 | ##大key分析
2 | ##流量分析
3 | ##热key分析
4 | ##key分布(类型分布,过期/永久存储)
5 |
6 | ## Key聚合分析 : 可以用来做redis key 的生命周期管理使用 : https://github.com/xiepaup/redis-key-partten
7 |
--------------------------------------------------------------------------------
/redisTools/goopsrc/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright © 2018 xiepaup,
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of
5 | this software and associated documentation files (the “Software”), to deal in
6 | the Software without restriction, including without limitation the rights to
7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 | the Software, and to permit persons to whom the Software is furnished to do so,
9 | subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | IN THE SOFTWARE.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/redisTools/goopsrc/aof/aof_test.go:
--------------------------------------------------------------------------------
1 | package aof
2 |
3 | import (
4 | "testing"
5 | "fmt"
6 | )
7 |
8 | /**
9 | *
10 | * Author : xiepaup
11 | * EMail : xiepaup@163.com
12 | * Date : 2018-06-02
13 | * Project : redisTools
14 | **/
15 |
16 |
17 | func TestAOFContext_GetBigestTopKey(t *testing.T) {
18 | fmt.Println("this is unit test for aof of top n keys ...")
19 | aof,err := NewAOFContext("../test/redis-appendonly.aof")
20 | if err != nil{
21 | panic(fmt.Sprintf("init error : %s",err))
22 | }
23 | aof.SetStatTypeBySize(true)
24 | aof.GetBiggestTopKeys(10)
25 | //aof.GetBiggestTopKeys(10)
26 | }
--------------------------------------------------------------------------------
/redisTools/goopsrc/aof/aof_tools.go:
--------------------------------------------------------------------------------
1 | package aof
2 |
3 |
4 | import (
5 | "strings"
6 | )
7 | /**
8 | *
9 | * Author : xiean
10 | * EMail : xiepaup@163.com
11 | * Date : 2018-06-02
12 | * Project : redisTools
13 | **/
14 |
15 |
16 |
17 |
18 |
19 |
20 | func CommandsOpsAllTypes(cmd string) bool{
21 | REDIS_UNIVERS_COMMANDS := [...]string{"DEL"}
22 | for _,c := range REDIS_UNIVERS_COMMANDS {
23 | if strings.Compare(c,cmd) == 0 {
24 | return true
25 | }
26 | }
27 | return false
28 | }
29 |
30 | func CommandOpsStringType(cmd string) bool {
31 | REDIS_STRING_COMMANDS := [...]string{"SET", "GETSET",
32 | "SETBIT", "SETEX", "SETNX", "SETRANGE",
33 | "MSET", "MSETNX", "PSETEX", "INCR", "INCRBY", "INCRBYFOLAT", "DECR", "DECRBY", "APPEND"}
34 | for _,c := range REDIS_STRING_COMMANDS {
35 | if strings.Compare(c,cmd) == 0 {
36 | return true
37 | }
38 | }
39 | return false
40 | }
41 |
42 | func CommandOpsListType(cmd string) bool {
43 | REDIS_LIST_COMMANDS := [...]string{"LPUSH", "RPUSH", "LPOP", "RPOP", "LREM", "LSET",
44 | "LTRIM", "RPOPLPUSH", "LINSERT", "LPUSHX", "RPUSHX"}
45 |
46 | for _,c := range REDIS_LIST_COMMANDS {
47 | if strings.Compare(c,cmd) == 0 {
48 | return true
49 | }
50 | }
51 | return false
52 | }
53 |
54 | func CommandOpsHashType(cmd string) bool {
55 | REDIS_HASH_COMMANDS := [...]string{"HDEL", "HSET", "HICRBY", "HINCRBYFLOAT", "HMSET", "HSETNX"}
56 | for _,c := range REDIS_HASH_COMMANDS {
57 | if strings.Compare(c,cmd) == 0 {
58 | return true
59 | }
60 | }
61 | return false
62 | }
63 |
64 | func CommandOpsSetType(cmd string) bool {
65 | REDIS_SET_COMMANDS := [...]string{"SADD", "SREM", "SDIFFSTROE", "SINTERSTROE", "SUNIONSTROE", "SPOP", "SMOVE", "SPOP"}
66 | for _,c := range REDIS_SET_COMMANDS {
67 | if strings.Compare(c,cmd) == 0 {
68 | return true
69 | }
70 | }
71 | return false
72 | }
73 |
74 | func CommandOpsZSetType(cmd string) bool {
75 | REDIS_ZSET_COMMANDS := [...]string{"ZADD", "ZINCRBY", "ZREM", "ZREMRANGEBYLEX", "ZREMRANGEBYRANK", "ZREMRANGEBYSCORE", "ZINTERSTORE"}
76 |
77 | for _,c := range REDIS_ZSET_COMMANDS {
78 | if strings.Compare(c,cmd) == 0 {
79 | return true
80 | }
81 | }
82 | return false
83 | }
--------------------------------------------------------------------------------
/redisTools/goopsrc/aof/string_cmd_parse.go:
--------------------------------------------------------------------------------
1 | package aof
2 |
3 | import (
4 | "fmt"
5 | "strconv"
6 | )
7 |
8 | /**
9 | *
10 | * Author : xiean
11 | * EMail : xiepaup@163.com
12 | * Date : 2018-07-07
13 | * Project : OPS-Tools
14 | **/
15 |
16 |
17 | func (this *AOFContext) cmdDoStringType(db string, baseCmd string, baseKey string, args []string) {
18 | stringMap := this.SimpleKeys[db].StringKeys
19 | strVal := args[1]
20 | klen := int64(len(baseKey))
21 | vlen := int64(len(strVal))
22 |
23 | // SETBIT key bits 0/1
24 | if baseCmd == "SETBIT" {
25 | setBitsN, _ := strconv.Atoi(strVal)
26 | if kv, ok := stringMap[baseKey]; ok {
27 | setBitsN64 := int64(setBitsN)
28 | vHasBits := kv.ValueLen * 8
29 | if setBitsN64 > vHasBits {
30 | tx := (setBitsN64 - vHasBits) / 8
31 | ty := (setBitsN64 - vHasBits) % 8
32 | if ty > 0 {
33 | vlen = tx + 1 + kv.ValueLen
34 | } else {
35 | vlen = tx + kv.ValueLen
36 | }
37 | } else {
38 | vlen = kv.ValueLen
39 | }
40 | } else {
41 | vlen = int64(setBitsN / 8)
42 | if setBitsN%8 != 0 {
43 | vlen += int64(1)
44 | }
45 | //fmt.Println(fmt.Sprintf("set k :%d,v:%d,%d,%s,%#v", klen, vlen, setBitsN, strVal, args))
46 | stringMap[baseKey] = NewStringMap(klen, vlen)
47 | }
48 | }
49 | // SET ,SETEX,SETNX,GETSET,
50 | if kv, ok := stringMap[baseKey]; ok {
51 | kv.ValueLen = vlen
52 | kv.KeyLen = klen
53 | } else {
54 | stringMap[baseKey] = NewStringMap(klen, vlen)
55 | }
56 |
57 | //"INCR", "INCRBY", "INCRBYFOLAT", "DECR", "DECRBY" ---> valueLen to int64-->8
58 | if baseCmd == "INCR" || baseCmd == "INCRBY" || baseCmd == "INCRBYFOLAT" || baseCmd == "DECR" || baseCmd == "DECRBY" {
59 | vlen = 8
60 | }
61 | //MSET ,MSETNX
62 | if baseCmd == "MSET" || baseCmd == "MSETNX" {
63 | mkvLen := len(args)
64 | if mkvLen%2 != 0 {
65 | fmt.Println(fmt.Sprintf("bad MSET/MSETNX %v", args))
66 | return
67 | }
68 | for i := 0; i < mkvLen; i += 2 {
69 | k := args[i]
70 | v := args[i+1]
71 | klen = int64(len(k))
72 | vlen = int64(len(v))
73 | if kv, ok := stringMap[baseKey]; ok {
74 | kv.ValueLen = vlen
75 | kv.KeyLen = klen
76 | } else {
77 | stringMap[baseKey] = NewStringMap(klen, vlen)
78 | }
79 | }
80 | }
81 | // APPEND
82 | if baseCmd == "APPEND" {
83 | if kv, ok := stringMap[baseKey]; ok {
84 | vlen += kv.ValueLen + vlen
85 | }
86 | }
87 |
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/redisTools/goopsrc/aof/zset_cmd_parse.go:
--------------------------------------------------------------------------------
1 | package aof
2 |
3 | import "fmt"
4 |
5 | /**
6 | *
7 | * Author : xiean
8 | * EMail : xiepaup@163.com
9 | * Date : 2018-07-07
10 | * Project : OPS-Tools
11 | **/
12 |
13 |
14 | func (this *AOFContext) cmdDoZSetType(db string, baseCmd string, baseKey string, args []string) {
15 | if _, ok := this.SimpleKeys[db]; ok {
16 | //TODO
17 | fmt.Println(fmt.Sprintf("unsupport ZSET : %s,for %s %s %#v", db, baseCmd, baseKey, args))
18 | } else {
19 | fmt.Println(fmt.Sprintf("unkonw db : %s,for %s %s %#v", db, baseCmd, baseKey, args))
20 | }
21 | }
--------------------------------------------------------------------------------
/redisTools/goopsrc/cmd/redisDBATools.go:
--------------------------------------------------------------------------------
1 | package cmd
2 |
3 | /**
4 | *
5 | * Author : xiepaup
6 | * EMail : xiepaup@163.com
7 | * Date : 2018-06-02
8 | * Project : redisTools
9 | **/
10 |
11 |
12 |
--------------------------------------------------------------------------------
/redisTools/goopsrc/test/redis-appendonly.aof:
--------------------------------------------------------------------------------
1 | *2
2 | $6
3 | SELECT
4 | $1
5 | 0
6 | *3
7 | $3
8 | set
9 | $7
10 | vitodb1
11 | $11
12 | value|1|2|3
13 | *2
14 | $6
15 | SELECT
16 | $1
17 | 2
18 | *3
19 | $3
20 | set
21 | $7
22 | vitodb2
23 | $10
24 | value2|3|4
25 | *2
26 | $3
27 | del
28 | $7
29 | vitodb2
30 | *2
31 | $6
32 | SELECT
33 | $1
34 | 0
35 | *2
36 | $3
37 | del
38 | $7
39 | vitodb1
40 | *3
41 | $3
42 | set
43 | $11
44 | vitostrkey1
45 | $14
46 | valuestrvalue1
47 | *3
48 | $3
49 | set
50 | $11
51 | vitostrkey2
52 | $14
53 | valuestrvalue2
54 | *8
55 | $5
56 | hmset
57 | $9
58 | vitohash1
59 | $6
60 | shkey1
61 | $8
62 | shvalue1
63 | $6
64 | shkey2
65 | $8
66 | shvalue2
67 | $6
68 | shkey3
69 | $8
70 | shvalue3
71 | *2
72 | $3
73 | del
74 | $11
75 | vitostrkey2
76 | *2
77 | $3
78 | del
79 | $9
80 | vitohash1
81 | *2
82 | $3
83 | del
84 | $11
85 | vitostrkey1
86 | *6
87 | $5
88 | hmset
89 | $9
90 | vitohash1
91 | $6
92 | shkey1
93 | $8
94 | shvalue1
95 | $6
96 | shkey2
97 | $9
98 | shavelue2
99 | *3
100 | $3
101 | set
102 | $8
103 | vitostr1
104 | $9
105 | strvalue1
106 | *3
107 | $3
108 | set
109 | $8
110 | vitostr2
111 | $9
112 | strvalue2
113 | *4
114 | $4
115 | hset
116 | $9
117 | vitohash1
118 | $6
119 | shkey2
120 | $14
121 | xxmodifyvalue2
122 | *4
123 | $4
124 | hset
125 | $9
126 | vitohash1
127 | $6
128 | shkey3
129 | $12
130 | addmorevalue
131 | *4
132 | $6
133 | SETbit
134 | $7
135 | vitobit
136 | $2
137 | 10
138 | $1
139 | 1
140 | *2
141 | $6
142 | SELECT
143 | $1
144 | 5
145 | *4
146 | $4
147 | hset
148 | $9
149 | vitohashdb5_hash
150 | $6
151 | shkey1
152 | $12
153 | addmorevallllllue
--------------------------------------------------------------------------------
/redisTools/goopsrc/test/redis-dump.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiepaup/dbatools/8549f2571aaee6a39f5c6f32179ac9c5d301a9aa/redisTools/goopsrc/test/redis-dump.rdb
--------------------------------------------------------------------------------
/redisTools/redis-cli-new:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiepaup/dbatools/8549f2571aaee6a39f5c6f32179ac9c5d301a9aa/redisTools/redis-cli-new
--------------------------------------------------------------------------------
/redisTools/redisHealthy/README.me:
--------------------------------------------------------------------------------
1 | # TODO FUNC:
2 |
3 |
4 | ## Requirement:
5 | 1. can control
6 | -- 可以指定延迟启动时间,即多久以后启动
7 | -- 可以指定运行时长,即什么时候结束
8 | -- 监控 redis 内存增量情况,如果在运行monitor过程中发现redis内存暴涨,那么结束本次运行
9 | -- 监控 redis 负载 QPS ,超过一定阈值 ,结束本次运行? (感觉使用内存监控比较好)
10 | 2. 关注宏观层面
11 | -- 流量分析
12 | -- 总体概况, 写入流量(去掉查询流量); 读取流量(去slave查询?value值?)
13 |
14 | -- 请求类型分析
15 | -- 总体概况, 读写比例
16 | -- 各种类型KEY操作占比
17 | -- 请求类型 业务类型分析? (通过分隔符智能判断?)
18 | 3. 注意细节处理
19 | -- 特别注意 Append 指令
20 | -- 特别注意 value 超过 1k 的请求
21 | -- 特别注意 mget、hmget 这种 mutil 请求 数量超过 【 30 】个(放大30倍)?
22 | -- 特别注意 hgetall、lrange 0 N 、zrangebyscore 等 获取全部数据的key
23 | -- 如果hgetall 返回数据只是单个field ,这样存在优化空间, 建议转化成string类型存储
24 |
25 |
26 | ## Implement:
27 |
28 | 1. 1:N 生产消费模式
29 | 2. 3层 控制, 控制层,逻辑层,存储层
30 |
31 |
32 |
33 | #
34 | main.go
35 | -- time ctl ,input args parse ,
36 | -- make(monitor chan ) ; make(stop chan) ;
--------------------------------------------------------------------------------
/redisTools/redisHealthy/cmd/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "os"
7 | "os/signal"
8 | "time"
9 | )
10 |
11 | /**
12 | *
13 | * Author : xiean
14 | * EMail : xiepaup@163.com
15 | * GitHub : https://github.com/xiepaup
16 | * Date : 2018-08-03
17 | * Project : dbatools
18 | **/
19 |
20 | const MAX_QUEUE_LEN = 100
21 |
22 | var (
23 | RunSeconds int
24 | DelayRunSeconds int
25 | Addr string
26 | Paswd string
27 |
28 | monitorChan chan interface{}
29 | stopChan chan struct{}
30 | doneChan chan struct{}
31 | )
32 |
33 | func init() {
34 |
35 | stopChan = make(chan struct{}, 0)
36 | monitorChan = make(chan interface{}, MAX_QUEUE_LEN)
37 | doneChan = make(chan struct{}, 0)
38 |
39 | flag.IntVar(&RunSeconds, "runsec", 60, "how long will be monitor")
40 | flag.IntVar(&DelayRunSeconds, "delaysec", 0, "if not 0, monitor will run N seconds later ")
41 | flag.StringVar(&Addr, "addr", "127.0.0.1:6379", "redis listen address")
42 | flag.StringVar(&Paswd, "password", "", "redis auth ,usually will be requirepass config item")
43 | flag.Parse()
44 | }
45 |
46 | func terminalProgram(terminalChan chan struct{}) {
47 | c := make(chan os.Signal, 0)
48 | signal.Notify(c)
49 |
50 | <-c
51 |
52 | terminalChan <- struct{}{}
53 | }
54 |
55 | func main() {
56 |
57 | terminalProgram(doneChan)
58 |
59 | //go time ctl
60 | //go redis ctl
61 | //
62 |
63 | mainLoop()
64 |
65 | }
66 |
67 |
68 |
69 | func mainLoop() {
70 | for {
71 | fmt.Println("todo Main Loop ..")
72 |
73 | select {
74 | case <-doneChan:
75 | break
76 | case <-stopChan:
77 | //TODO --> send stop chan to monitor , and consumer
78 | default:
79 | //TODO ---> run programs .. and sleep some time
80 | time.Sleep(time.Microsecond * 10)
81 |
82 | }
83 |
84 | time.Sleep(time.Millisecond * 10)
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/redisTools/redisHealthy/cmd/test/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "github.com/xiepaup/dbatools/redisTools/redisHealthy/lib/db"
4 |
5 | import (
6 | "fmt"
7 | "os"
8 | "strings"
9 | "time"
10 | )
11 |
12 | /**
13 | *
14 | * Author : xiean
15 | * EMail : xiepaup@163.com
16 | * GitHub : https://github.com/xiepaup
17 | * Date : 2018-08-03
18 | * Project : dbatools
19 | **/
20 |
21 |
22 | const MAX_QUEUE_LEN = 1000
23 |
24 | func main() {
25 | stopChan := make(chan struct{}, 2)
26 | monitorChan := make(chan interface{}, MAX_QUEUE_LEN)
27 | r := db.NewRedis("127.0.0.1:31238", "redis@manage")
28 |
29 | redisBasicInfo(r)
30 |
31 | err := r.Monitor(monitorChan, stopChan)
32 | if err != nil {
33 | os.Exit(1)
34 | }
35 | go consumeCmds(monitorChan, stopChan)
36 | fmt.Println(fmt.Sprintf("do sleep ... wait queue done"))
37 |
38 | time.Sleep(time.Second * 1000)
39 | }
40 |
41 | func redisBasicInfo(r *db.RedisContext) {
42 | i, err := r.Info()
43 | if err != nil {
44 | fmt.Println(fmt.Sprintf("got an error from redis , %+v", err))
45 | os.Exit(2)
46 | }
47 | info := strings.Split(string(i), "\r\n")
48 | if len(info) <= 0 {
49 | return
50 | }
51 |
52 | infoInfo := make(map[string]interface{}, 0)
53 |
54 | for _, l := range info {
55 | if !strings.Contains(l, ":") || strings.HasPrefix(l, "#") || len(l) == 0 {
56 | continue
57 | }
58 | //#redis_version:2.8.17-t-v0.2
59 | kv := strings.Split(l, ":")
60 | infoInfo[kv[0]] = kv[1]
61 | }
62 |
63 | //fmt.Println(infoInfo)
64 | showBasicInfo(infoInfo)
65 | }
66 |
67 | func showBasicInfo(info map[string]interface{}) {
68 | fmt.Println(fmt.Sprintf(`
69 | -------------------------------------------------
70 | |version:%-40s|osversion:%-40s|
71 | |uptime:%10s|clients:%5s|role:%6s|cur_qps:%6s|used_memory:%8s|rss_memory:%8s|
72 | -------------------------------------------------`,
73 | info["redis_version"], info["os"],
74 | info["uptime_in_seconds"], info["connected_clients"], info["role"],
75 | info["instantaneous_ops_per_sec"],
76 | info["used_memory_human"], info["used_memory_peak_human"]))
77 | }
78 |
79 | func consumeCmds(mchan chan interface{}, schan chan struct{}) {
80 | for line := range mchan {
81 | //#1532945695.049181 [0 10.51.149.210:34992] "RPOP" "com.xiepaup.tendis.source.queue"
82 | if v, ok := line.(string); ok {
83 | fmt.Println(fmt.Sprintf("outer lib do parse cmd : %s", v))
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/redisTools/redisHealthy/ctrl/redisctl.go:
--------------------------------------------------------------------------------
1 | package ctrl
2 |
3 | /**
4 | *
5 | * Author : xiean
6 | * EMail : xiepaup@163.com
7 | * GitHub : https://github.com/xiepaup
8 | * Date : 2018-08-03
9 | * Project : dbatools
10 | **/
--------------------------------------------------------------------------------
/redisTools/redisHealthy/ctrl/timectl.go:
--------------------------------------------------------------------------------
1 | package ctrl
2 |
3 | import "time"
4 |
5 | /**
6 | *
7 | * Author : xiean
8 | * EMail : xiepaup@163.com
9 | * GitHub : https://github.com/xiepaup
10 | * Date : 2018-08-03
11 | * Project : dbatools
12 | **/
13 |
14 | type TimeCtl struct {
15 | StartTime time.Time
16 | RunSeconds int
17 | DelaySeconds int
18 |
19 | }
20 |
21 | func NewTimeCtl(r,d,int2 int) (*TimeCtl) {
22 | return &TimeCtl{
23 | StartTime:time.Now(),
24 | RunSeconds:r,
25 | DelaySeconds:d,
26 | }
27 | }
28 |
29 |
30 |
31 | func (this *TimeCtl) GetRealStartTime() {
32 |
33 | }
--------------------------------------------------------------------------------
/redisTools/redisHealthy/logic/cmds/rediscmds.go:
--------------------------------------------------------------------------------
1 | package cmds
2 |
3 | /**
4 | * Author : xiean
5 | * EMail : xiepaup@163.com
6 | * GitHub : https://github.com/xiepaup
7 | * Date : 2018-08-05 11:53
8 | * Project : dbatools
9 | **/
10 |
11 | type RedisCMD struct {
12 | }
13 |
14 | const (
15 | REDIS_DATA_TYPE_HASH_NAME = "hash"
16 | REDIS_DATA_TYPE_STRINGS_NAME = "string"
17 | REDIS_DATA_TYPE_LIST_NAME = "list"
18 | REDIS_DATA_TYPE_SET_NAME = "set"
19 | REDIS_DATA_TYPE_ZSET_NAME = "zset"
20 | REDIS_DATA_TYPE_OTHER_NAME = "unkonwn"
21 | )
22 |
23 | const (
24 | REDIS_DATA_TYPE_HAHS_CODE = iota
25 | REDIS_DATA_TYPE_STRINGS_CODE
26 | REDIS_DATA_TYPE_LIST_CODE
27 | REDIS_DATA_TYPE_SET_CODE
28 | REDIS_DATA_TYPE_ZSET_CODE
29 | REDIS_DATA_TYPE_OTHER_CODE
30 | )
31 |
32 |
33 | const (
34 | UNKOWN_CMD_TYPE = 8888
35 |
36 | HASH_CMD_TYPE_READ = 9101
37 | HASH_CMD_TYPE_WRITE = 9102
38 |
39 | STR_CMD_TYPE_READ = 9201
40 | STR_CMD_TYPE_WRITE = 9202
41 |
42 | LIST_CMD_TYPE_READ = 9301
43 | LIST_CMD_TYPE_WRITE = 9302
44 |
45 | ZSET_CMD_TYPE_READ = 9401
46 | ZSET_CMD_YTPE_WRITE = 9402
47 |
48 | SET_CMD_TYPE_READ = 9501
49 | SET_CMD_TYPE_WRITE = 9502
50 | )
51 |
52 |
53 |
54 | func GetDataTypeByCmd(c string) {
55 |
56 | }
--------------------------------------------------------------------------------
/redisTools/redisHealthy/logic/cmds/redishashcmds.go:
--------------------------------------------------------------------------------
1 | package cmds
2 |
3 | import "strings"
4 |
5 | /**
6 | * Author : xiean
7 | * EMail : xiepaup@163.com
8 | * GitHub : https://github.com/xiepaup
9 | * Date : 2018-08-05 12:06
10 | * Project : dbatools
11 | **/
12 |
13 | var supportRedisHashCmds []string
14 | var supportRedisHashReadCmds [9]string
15 | var supportRedisHashWriteCmds [6]string
16 |
17 | func init() {
18 |
19 | //supportRedisHashCmds = []string{"HKEYS","HEXISTS","HGET","HGETALL","HLEN","HMGET","HVALS","HSCAN","HSTRLEN","HSET","HMSET","HDEL","HINCRBY","HINCRBYFLOAT","HSETNX"}
20 | supportRedisHashReadCmds = [...]string{"HKEYS", "HEXISTS", "HGET", "HGETALL", "HLEN", "HMGET", "HVALS", "HSCAN", "HSTRLEN"}
21 | supportRedisHashWriteCmds = [...]string{"HSET", "HMSET", "HDEL", "HINCRBY", "HINCRBYFLOAT", "HSETNX"}
22 |
23 | supportRedisHashCmds = supportRedisHashReadCmds[0:]
24 | for _, c := range supportRedisHashWriteCmds {
25 | supportRedisHashCmds = append(supportRedisHashCmds, c)
26 | }
27 |
28 | }
29 |
30 | func GetRedisHashCmds() ([]string) {
31 | return supportRedisHashCmds
32 | }
33 |
34 | func IsHashCmd(c string) (bool) {
35 | c = strings.ToUpper(c)
36 | for _, hc := range supportRedisHashCmds {
37 | if c == hc {
38 | return true
39 | }
40 | }
41 | return false
42 | }
43 |
44 | func GetHashCmdType(c string) (int) {
45 | if IsHashCmd(c) {
46 | if isHashReadCmd(c) {
47 | return HASH_CMD_TYPE_READ
48 | }
49 |
50 | if isHashWriteCmd(c) {
51 | return HASH_CMD_TYPE_WRITE
52 | }
53 | }
54 | return UNKOWN_CMD_TYPE
55 | }
56 |
57 | func isHashReadCmd(c string) bool {
58 | c = strings.ToUpper(c)
59 | for _, hc := range supportRedisHashReadCmds {
60 | if c == hc {
61 | return true
62 | }
63 | }
64 | return false
65 | }
66 |
67 | func isHashWriteCmd(c string) bool {
68 | c = strings.ToUpper(c)
69 | for _, hc := range supportRedisHashWriteCmds {
70 | if c == hc {
71 | return true
72 | }
73 | }
74 | return false
75 | }
76 |
--------------------------------------------------------------------------------
/redisTools/redisHealthy/logic/cmds/redislistcmds.go:
--------------------------------------------------------------------------------
1 | package cmds
2 |
3 | import "strings"
4 |
5 | /**
6 | * Author : xiean
7 | * EMail : xiepaup@163.com
8 | * GitHub : https://github.com/xiepaup
9 | * Date : 2018-08-05 12:06
10 | * Project : dbatools
11 | **/
12 |
13 | var supportRedisListCmds []string
14 | var supportRedisListReadCmds [3]string
15 | var supportRedisListWriteCmds [14]string
16 |
17 |
18 | func init() {
19 | supportRedisListReadCmds = [...]string{"LINDEX", "LLEN", "LRANGE"}
20 | supportRedisListWriteCmds = [...]string{"BLPOP", "BRPOP", "BRPOPLPUSH", "LINSERT", "LPOP", "LPUSH", "LPUSHX", "LREM", "LSET", "LTRIM", "RPOP", "RPOPLPUSH", "RPUSH", "RPUSHX"}
21 |
22 | supportRedisListCmds = supportRedisListReadCmds[0:]
23 |
24 | for _, c := range supportRedisListWriteCmds {
25 | supportRedisListCmds = append(supportRedisListCmds, c)
26 | }
27 |
28 | }
29 |
30 | func IsListCmd(c string) (bool) {
31 | c = strings.ToUpper(c)
32 |
33 | for _, lc := range supportRedisListCmds {
34 | if c == lc {
35 | return true
36 | }
37 | }
38 | return false
39 | }
40 |
41 | func GetListCmdType(c string) (int) {
42 | c = strings.ToUpper(c)
43 | if IsListCmd(c) {
44 | if isListReadCmd(c) {
45 | return LIST_CMD_TYPE_READ
46 | }
47 | if isListWriteCmd(c) {
48 | return LIST_CMD_TYPE_WRITE
49 | }
50 | }
51 | return UNKOWN_CMD_TYPE
52 | }
53 |
54 | func isListReadCmd(c string) (bool) {
55 | c = strings.ToUpper(c)
56 |
57 | for _, lc := range supportRedisListReadCmds {
58 | if c == lc {
59 | return true
60 | }
61 | }
62 | return false
63 | }
64 |
65 | func isListWriteCmd(c string) (bool) {
66 | c = strings.ToUpper(c)
67 |
68 | for _, lc := range supportRedisListWriteCmds {
69 | if c == lc {
70 | return true
71 | }
72 | }
73 | return false
74 | }
75 |
--------------------------------------------------------------------------------
/redisTools/redisHealthy/logic/cmds/redissetcmds.go:
--------------------------------------------------------------------------------
1 | package cmds
2 |
3 | import "strings"
4 |
5 | /**
6 | * Author : xiean
7 | * EMail : xiepaup@163.com
8 | * GitHub : https://github.com/xiepaup
9 | * Date : 2018-08-05 12:58
10 | * Project : dbatools
11 | **/
12 |
13 | var supportRedisSETCmds []string
14 | var supportRedisSETReadCmds [10]string
15 | var supportRedisSETWriteCmds [4]string
16 |
17 |
18 | func init() {
19 | supportRedisSETReadCmds = [...]string{"SCARD", "SDIFF", "SDIFFSTORE","SINTER","SINTERSTORE","SISMEMBER","SRANDMEMBER","SUNION","SUNIONSTORE","SSCAN"}
20 | supportRedisSETWriteCmds = [...]string{"SADD", "SMOVE", "SPOP", "SREM"}
21 |
22 | supportRedisSETCmds = supportRedisListReadCmds[0:]
23 |
24 | for _, c := range supportRedisSETWriteCmds {
25 | supportRedisSETCmds = append(supportRedisSETCmds, c)
26 | }
27 |
28 | }
29 |
30 | func IsSetCmd(c string) (bool) {
31 | c = strings.ToUpper(c)
32 |
33 | for _, lc := range supportRedisSETCmds {
34 | if c == lc {
35 | return true
36 | }
37 | }
38 | return false
39 | }
40 |
41 | func GetSetCmdType(c string) (int) {
42 | c = strings.ToUpper(c)
43 | if IsSetCmd(c) {
44 | if isSetReadCmd(c) {
45 | return SET_CMD_TYPE_READ
46 | }
47 | if isSetWriteCmd(c) {
48 | return SET_CMD_TYPE_WRITE
49 | }
50 | }
51 | return UNKOWN_CMD_TYPE
52 | }
53 |
54 | func isSetReadCmd(c string) (bool) {
55 | c = strings.ToUpper(c)
56 |
57 | for _, lc := range supportRedisSETReadCmds {
58 | if c == lc {
59 | return true
60 | }
61 | }
62 | return false
63 | }
64 |
65 | func isSetWriteCmd(c string) (bool) {
66 | c = strings.ToUpper(c)
67 |
68 | for _, lc := range supportRedisSETWriteCmds {
69 | if c == lc {
70 | return true
71 | }
72 | }
73 | return false
74 | }
75 |
--------------------------------------------------------------------------------
/redisTools/redisHealthy/logic/cmds/redisstringcmds.go:
--------------------------------------------------------------------------------
1 | package cmds
2 |
3 | import "strings"
4 |
5 | /**
6 | * Author : xiean
7 | * EMail : xiepaup@163.com
8 | * GitHub : https://github.com/xiepaup
9 | * Date : 2018-08-05 12:06
10 | * Project : dbatools
11 | **/
12 |
13 | var supportRedisStringCmds []string
14 | var supportRedisStringReadCmds [9]string
15 | var supportRedisStringWriteCmds [13]string
16 |
17 | //GETSET ===> treat as write .
18 | func init() {
19 |
20 | supportRedisStringReadCmds = [...]string{"APPEND", "BITCOUNT", "BITOP", "BITFIELD", "GET", "GETBIT", "GETRANGE", "MGET", "STRLEN"}
21 | supportRedisStringWriteCmds = [...]string{"DECRBY", "DECR", "GETSET", "INCR", "INCRBY", "INCRBYFLOAT", "MSET", "MSETNX", "PSETEX", "SET", "SETEX", "SETNX", "SETRANGE"}
22 |
23 | supportRedisStringCmds = supportRedisStringReadCmds[0:]
24 | for _, c := range supportRedisStringWriteCmds {
25 | supportRedisStringCmds = append(supportRedisStringCmds, c)
26 | }
27 |
28 | }
29 |
30 | func IsStringCmd(c string) (bool) {
31 | c = strings.ToUpper(c)
32 | for _, sc := range supportRedisStringCmds {
33 | if c == sc {
34 | return true
35 | }
36 | }
37 | return false
38 | }
39 |
40 | func GetStringCmdType(c string) (int) {
41 |
42 | if IsStringCmd(c) {
43 | if isStringReadCmd(c) {
44 | return STR_CMD_TYPE_READ
45 | }
46 | if isStringWriteCmd(c) {
47 | return STR_CMD_TYPE_WRITE
48 | }
49 | }
50 | return UNKOWN_CMD_TYPE
51 | }
52 |
53 | func isStringReadCmd(c string) (bool) {
54 | c = strings.ToUpper(c)
55 |
56 | for _, sc := range supportRedisStringReadCmds {
57 | if c == sc {
58 | return true
59 | }
60 | }
61 |
62 | return false
63 | }
64 |
65 | func isStringWriteCmd(c string) (bool) {
66 | c = strings.ToUpper(c)
67 |
68 | for _, sc := range supportRedisStringWriteCmds {
69 | if c == sc {
70 | return true
71 | }
72 | }
73 | return false
74 | }
75 |
--------------------------------------------------------------------------------
/redisTools/redisHealthy/logic/cmds/rediszsetcmds.go:
--------------------------------------------------------------------------------
1 | package cmds
2 |
3 | import "strings"
4 |
5 | /**
6 | * Author : xiean
7 | * EMail : xiepaup@163.com
8 | * GitHub : https://github.com/xiepaup
9 | * Date : 2018-08-05 12:58
10 | * Project : dbatools
11 | **/
12 |
13 |
14 |
15 | var supportRedisZSetCmds []string
16 | var supportRedisZSetReadCmds [16]string
17 | var supportRedisZSetWriteCmds [3]string
18 |
19 |
20 | func init() {
21 | supportRedisZSetReadCmds = [...]string{"ZCARD","ZCOUNT","ZRANGE","ZRANGEBYSCORE","ZRANK","ZREMRANGEBYRANK","ZREMRANGEBYSCORE",
22 | "ZREVRANGE","ZREVRANGEBYSCORE","ZREVRANK","ZSCORE","ZUNIONSTORE","ZSCAN","ZRANGEBYLEX","ZLEXCOUNT","ZREMRANGEBYLEX"}
23 | supportRedisZSetWriteCmds = [...]string{"ZINCRBY","ZREM","ZADD"}
24 |
25 | supportRedisZSetCmds = supportRedisZSetReadCmds[0:]
26 |
27 | for _, c := range supportRedisZSetWriteCmds {
28 | supportRedisZSetCmds = append(supportRedisZSetCmds, c)
29 | }
30 |
31 | }
32 |
33 | func IsZSetCmd(c string) (bool) {
34 | c = strings.ToUpper(c)
35 |
36 | for _, lc := range supportRedisZSetCmds {
37 | if c == lc {
38 | return true
39 | }
40 | }
41 | return false
42 | }
43 |
44 | func GetZSetCmdType(c string) (int) {
45 | c = strings.ToUpper(c)
46 | if IsZSetCmd(c) {
47 | if isZSetReadCmd(c) {
48 | return ZSET_CMD_TYPE_READ
49 | }
50 | if isZSetWriteCmd(c) {
51 | return ZSET_CMD_YTPE_WRITE
52 | }
53 | }
54 | return UNKOWN_CMD_TYPE
55 | }
56 |
57 | func isZSetReadCmd(c string) (bool) {
58 | c = strings.ToUpper(c)
59 |
60 | for _, lc := range supportRedisZSetReadCmds {
61 | if c == lc {
62 | return true
63 | }
64 | }
65 | return false
66 | }
67 |
68 | func isZSetWriteCmd(c string) (bool) {
69 | c = strings.ToUpper(c)
70 |
71 | for _, lc := range supportRedisZSetWriteCmds {
72 | if c == lc {
73 | return true
74 | }
75 | }
76 | return false
77 | }
78 |
--------------------------------------------------------------------------------
/redisTools/redisHealthy/logic/macro/global.go:
--------------------------------------------------------------------------------
1 | package macro
2 |
3 | import (
4 | "sync"
5 | "fmt"
6 | )
7 |
8 | /**
9 | *
10 | * Author : xiean
11 | * EMail : xiepaup@163.com
12 | * GitHub : https://github.com/xiepaup
13 | * Date : 2018-08-03
14 | * Project : dbatools
15 | **/
16 |
17 | type GlobalWatch struct {
18 | mutx sync.Mutex
19 |
20 | WriteBytes int64
21 | ReadBytes int64
22 |
23 | ReadOpsCnt int64
24 | WriteOpsCnt int64
25 |
26 | HashOpsCnt int64
27 | StrOpsCnt int64
28 | ListOpsCnt int64
29 | SetOpsCnt int64
30 | ZSetOpsCnt int64
31 |
32 | AllOpsCnt int64
33 | }
34 |
35 | func NewGlobalWatch() (*GlobalWatch) {
36 | return &GlobalWatch{}
37 | }
38 |
39 | func (this *GlobalWatch) Incr() {
40 |
41 | }
42 |
43 |
44 |
45 | func (this *GlobalWatch) ToString() {
46 | fmt.Println(fmt.Sprintf("%#v",this))
47 | }
--------------------------------------------------------------------------------
/redisTools/redisHealthy/logic/micro/details.go:
--------------------------------------------------------------------------------
1 | package micro
2 |
3 | /**
4 | * Author : xiean
5 | * EMail : xiepaup@163.com
6 | * GitHub : https://github.com/xiepaup
7 | * Date : 2018-08-05 11:46
8 | * Project : dbatools
9 | **/
10 |
11 |
--------------------------------------------------------------------------------
/redisTools/redis_key_delete.py:
--------------------------------------------------------------------------------
1 | import redis
2 | import time
3 | import sys
4 | '''
5 | This Scripts is for Delete keys which miss used by dev
6 |
7 | Created by xiean@2016-04-20 Email xiepaup@163.com
8 | '''
9 |
10 |
11 |
12 | def del_keys(rdbConn,keys_list):
13 | rdbPiple = rdbConn.pipeline()
14 | for key in keys_list:
15 | rdbPiple.delete(key)
16 | rdbPiple.execute()
17 |
18 |
19 | def main(fileName,rdbConn,delCounter):
20 | keys_file = open(fileName,'r')
21 | key_counter = 0
22 | key_list = []
23 | for line in keys_file:
24 | line = line.strip()
25 | if line != '':
26 | #key = line.split(',')[1]
27 | key = line
28 | key_counter += 1
29 | key_list.append(key)
30 | if (key_counter % delCounter) == 0 :
31 | del_keys(rdbConn,key_list)
32 | key_list = []
33 | print "%s : Deleted %12s Keys" % (time.ctime(),key_counter)
34 | time.sleep(0.1)
35 |
36 | def usage():
37 | print '''
38 | Function: This Scripts is used to delete keys which miss uesed by dev !
39 | Args :
40 | -H,--help show usage
41 | -F,--file input keys will be deleted !
42 | -h,--host redis ip or domain
43 | -p,--port redis port
44 | '''
45 |
46 | if __name__ == "__main__":
47 | if len(sys.argv) < 4:
48 | print "please input argvs "
49 | usage()
50 | exit()
51 | fileName = ""
52 | host = ""
53 | port = ""
54 |
55 | try:
56 | opts,args = getopt.getopt(sys.argv[1:],"Hf:h:p:",["help","file=","host=","port="])
57 | for op,value in opts:
58 | if op in ("-f","--file"):
59 | fileName = value
60 | elif op in ("-h","--host"):
61 | host = value
62 | elif op in ("-P","--port"):
63 | port = int(value)
64 | elif op in ("-H","--help"):
65 | usage()
66 | except Exception,e:
67 | print "Parse Args Error ,%s" % (e)
68 |
69 | beginTime = time.ctime()
70 | rdbConn = redis.Redis(host=host,port=port)
71 | main(fileName,rdbConn,300)
72 |
73 | endTime = time.ctime()
74 | print "Delete Key Done ! running through %s - %s " % (beginTime,endTime)
75 |
--------------------------------------------------------------------------------