本文整理汇总了Python中mysql.fabric.server.MySQLServer.discover_uuid方法的典型用法代码示例。如果您正苦于以下问题:Python MySQLServer.discover_uuid方法的具体用法?Python MySQLServer.discover_uuid怎么用?Python MySQLServer.discover_uuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql.fabric.server.MySQLServer
的用法示例。
在下文中一共展示了MySQLServer.discover_uuid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def setUp(self):
"""Configure the existing environment
"""
uuid = MySQLServer.discover_uuid(OPTIONS["address"])
OPTIONS["uuid"] = _uuid.UUID(uuid)
self.server = MySQLServer(**OPTIONS)
MySQLServer.add(self.server)
示例2: setUp
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def setUp(self):
"""Configure the existing environment
"""
uuid = MySQLServer.discover_uuid(OPTIONS_MASTER["address"])
OPTIONS_MASTER["uuid"] = _uuid.UUID(uuid)
self.master = MySQLServer(**OPTIONS_MASTER)
self.master.connect()
reset_master(self.master)
uuid = MySQLServer.discover_uuid(OPTIONS_SLAVE["address"])
OPTIONS_SLAVE["uuid"] = _uuid.UUID(uuid)
self.slave = MySQLServer(**OPTIONS_SLAVE)
self.slave.connect()
stop_slave(self.slave, wait=True)
reset_master(self.slave)
reset_slave(self.slave, clean=True)
示例3: test_max_connections
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def test_max_connections(self):
uuid = MySQLServer.discover_uuid(OPTIONS["address"])
server = MySQLServer(
_uuid.UUID(uuid), OPTIONS["address"],
)
server.connect()
res = server.get_variable("max_connections")
self.assertNotEqual(int(res), 0)
示例4: setUp
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def setUp(self):
"""Configure the existing environment
"""
uuid = MySQLServer.discover_uuid(
tests.utils.MySQLInstances().get_address(0)
)
self.server = MySQLServer(_uuid.UUID(uuid),
tests.utils.MySQLInstances().get_address(0)
)
MySQLServer.add(self.server)
示例5: configure_servers
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def configure_servers(options):
"""Check if some MySQL's addresses were specified and the number is
greater than NUMBER_OF_SERVERS.
"""
import tests.utils as _test_utils
from mysql.fabric.server import (
MySQLServer,
ConnectionPool,
)
try:
servers = _test_utils.MySQLInstances()
servers.state_store_address = "{host}:{port}".format(
host=options.host, port=options.port
)
servers.user = options.db_user
servers.passwd = None
servers.root_user = options.user
servers.root_passwd = options.password
if options.servers:
for address in options.servers.split():
servers.add_address(address)
uuid = MySQLServer.discover_uuid(
address=address, user=servers.root_user,
passwd=servers.root_passwd
)
server = MySQLServer(
_uuid.UUID(uuid), address=address, user=servers.root_user,
passwd=servers.root_passwd
)
server.connect()
server.set_session_binlog(False)
server.exec_stmt(
"GRANT {privileges} ON *.* TO '{user}'@'%%'".format(
privileges=", ".join(MySQLServer.ALL_PRIVILEGES),
user=servers.user)
)
server.exec_stmt("FLUSH PRIVILEGES")
server.set_session_binlog(True)
server.disconnect()
ConnectionPool().purge_connections(server.uuid)
if servers.get_number_addresses() < NUMBER_OF_SERVERS:
print "<<<<<<<<<< Some unit tests need %s MySQL Instances. " \
">>>>>>>>>> " % (NUMBER_OF_SERVERS, )
return False
except Exception as error:
print "Error configuring servers:", error
return False
return True
示例6: test_persister_id
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def test_persister_id(self):
"""Test Persister's uuid.
"""
# Get persister'a address.
instances = tests.utils.MySQLInstances()
address = instances.state_store_address
user = instances.root_user
passwd = instances.root_passwd
# Try to manage the MySQLPersister.
uuid = MySQLServer.discover_uuid(
address=address, user=user, passwd=passwd
)
server = MySQLServer(_uuid.UUID(uuid), address, user, passwd)
self.assertRaises(_errors.ServerError, MySQLServer.add, server)
示例7: test_server_id
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def test_server_id(self):
"""Test MySQLServer's uuid.
"""
# Configure
uuid = MySQLServer.discover_uuid(OPTIONS["address"])
OPTIONS["uuid"] = _uuid.UUID(uuid)
server_1 = MySQLServer(**OPTIONS)
server_2 = MySQLServer(**OPTIONS)
# Check that two different objects represent the same server.
self.assertEqual(server_1, server_2)
# Check that a dictionary with server_1 and server_2 has in
# fact only one entry.
hash_info = {}
hash_info[server_1] = server_1
hash_info[server_2] = server_2
self.assertEqual(len(hash_info), 1)
示例8: test_connection_pool
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def test_connection_pool(self):
"""Test connection pool.
"""
# Configuration
uuid = MySQLServer.discover_uuid(OPTIONS["address"])
OPTIONS["uuid"] = uuid = _uuid.UUID(uuid)
server_1 = MySQLServer(**OPTIONS)
server_2 = MySQLServer(**OPTIONS)
cnx_pool = ConnectionPool()
# Purge connections and check the number of connections in
# the pool.
cnx_pool.purge_connections(uuid)
self.assertEqual(cnx_pool.get_number_connections(uuid), 0)
# Connect and check the number of connections in the pool.
server_1.connect()
server_2.connect()
self.assertEqual(cnx_pool.get_number_connections(uuid), 0)
# Delete one of the servers and check the number of
# connections in the pool.
del server_1
self.assertEqual(cnx_pool.get_number_connections(uuid), 1)
# Delete one of the servers and check the number of
# connections in the pool.
del server_2
self.assertEqual(cnx_pool.get_number_connections(uuid), 2)
# Purge connections and check the number of connections in
# the pool. However, call purge_connections twice.
cnx_pool.purge_connections(uuid)
self.assertEqual(cnx_pool.get_number_connections(uuid), 0)
cnx_pool.purge_connections(uuid)
self.assertEqual(cnx_pool.get_number_connections(uuid), 0)
示例9: setUp
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def setUp(self):
self.manager, self.proxy = tests.utils.setup_xmlrpc()
self.__options_1 = {
"uuid" : _uuid.UUID("{aa75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(0),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server1 = MySQLServer.discover_uuid(self.__options_1["address"])
self.__options_1["uuid"] = _uuid.UUID(uuid_server1)
self.__server_1 = MySQLServer(**self.__options_1)
MySQLServer.add(self.__server_1)
self.__group_1 = Group("GROUPID1", "First description.")
Group.add(self.__group_1)
self.__group_1.add_server(self.__server_1)
tests.utils.configure_decoupled_master(self.__group_1, self.__server_1)
self.__options_2 = {
"uuid" : _uuid.UUID("{aa45b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(1),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server2 = MySQLServer.discover_uuid(self.__options_2["address"])
self.__options_2["uuid"] = _uuid.UUID(uuid_server2)
self.__server_2 = MySQLServer(**self.__options_2)
MySQLServer.add(self.__server_2)
self.__server_2.connect()
self.__server_2.exec_stmt("DROP DATABASE IF EXISTS db1")
self.__server_2.exec_stmt("CREATE DATABASE db1")
self.__server_2.exec_stmt("CREATE TABLE db1.t1"
"(userID INT, name VARCHAR(30))")
for i in range(1, 501):
self.__server_2.exec_stmt("INSERT INTO db1.t1 "
"VALUES(%s, 'TEST %s')" % (i, i))
self.__group_2 = Group("GROUPID2", "Second description.")
Group.add(self.__group_2)
self.__group_2.add_server(self.__server_2)
tests.utils.configure_decoupled_master(self.__group_2, self.__server_2)
self.__options_3 = {
"uuid" : _uuid.UUID("{bb75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(2),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server3 = MySQLServer.discover_uuid(self.__options_3["address"])
self.__options_3["uuid"] = _uuid.UUID(uuid_server3)
self.__server_3 = MySQLServer(**self.__options_3)
MySQLServer.add( self.__server_3)
self.__server_3.connect()
self.__server_3.exec_stmt("DROP DATABASE IF EXISTS db1")
self.__server_3.exec_stmt("CREATE DATABASE db1")
self.__server_3.exec_stmt("CREATE TABLE db1.t1"
"(userID INT, name VARCHAR(30))")
for i in range(1, 501):
self.__server_3.exec_stmt("INSERT INTO db1.t1 "
"VALUES(%s, 'TEST %s')" % (i, i))
self.__group_3 = Group("GROUPID3", "Third description.")
Group.add( self.__group_3)
self.__group_3.add_server(self.__server_3)
tests.utils.configure_decoupled_master(self.__group_3, self.__server_3)
self.__options_4 = {
"uuid" : _uuid.UUID("{bb45b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(3),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server4 = MySQLServer.discover_uuid(self.__options_4["address"])
self.__options_4["uuid"] = _uuid.UUID(uuid_server4)
self.__server_4 = MySQLServer(**self.__options_4)
MySQLServer.add(self.__server_4)
self.__server_4.connect()
self.__server_4.exec_stmt("DROP DATABASE IF EXISTS db1")
self.__server_4.exec_stmt("CREATE DATABASE db1")
self.__server_4.exec_stmt("CREATE TABLE db1.t1"
"(userID INT, name VARCHAR(30))")
for i in range(1, 501):
self.__server_4.exec_stmt("INSERT INTO db1.t1 "
"VALUES(%s, 'TEST %s')" % (i, i))
self.__group_4 = Group("GROUPID4", "Fourth description.")
Group.add( self.__group_4)
self.__group_4.add_server(self.__server_4)
tests.utils.configure_decoupled_master(self.__group_4, self.__server_4)
self.__options_5 = {
"uuid" : _uuid.UUID("{cc75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(4),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
#.........这里部分代码省略.........
示例10: setUp
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def setUp(self):
"""Configure the existing environment
"""
self.__options_1 = {
"uuid" : _uuid.UUID("{bb75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : "server_1.mysql.com:3060",
}
self.__server_1 = MySQLServer(**self.__options_1)
MySQLServer.add(self.__server_1)
self.__options_2 = {
"uuid" : _uuid.UUID("{aa75a12a-98d1-414c-96af-9e9d4b179678}"),
"address" : "server_2.mysql.com:3060",
}
self.__server_2 = MySQLServer(**self.__options_2)
MySQLServer.add(self.__server_2)
self.__group_1 = Group("GROUPID1", "First description.")
Group.add(self.__group_1)
self.__group_1.add_server(self.__server_1)
self.__group_1.add_server(self.__server_2)
self.__options_3 = {
"uuid" : _uuid.UUID("{cc75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(0),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server3 = MySQLServer.discover_uuid(self.__options_3["address"])
self.__options_3["uuid"] = _uuid.UUID(uuid_server3)
self.__server_3 = MySQLServer(**self.__options_3)
MySQLServer.add(self.__server_3)
self.__server_3.connect()
self.__server_3.exec_stmt("DROP DATABASE IF EXISTS prune_db")
self.__server_3.exec_stmt("CREATE DATABASE prune_db")
self.__server_3.exec_stmt("CREATE TABLE prune_db.prune_table"
"(userID INT, name VARCHAR(30))")
self.__server_3.exec_stmt("INSERT INTO prune_db.prune_table "
"VALUES(101, 'TEST 1')")
self.__server_3.exec_stmt("INSERT INTO prune_db.prune_table "
"VALUES(202, 'TEST 2')")
self.__options_4 = {
"uuid" : _uuid.UUID("{dd75a12a-98d1-414c-96af-9e9d4b179678}"),
"address" : "server_4.mysql.com:3060",
}
self.__server_4 = MySQLServer(**self.__options_4)
MySQLServer.add(self.__server_4)
self.__group_2 = Group("GROUPID2", "Second description.")
Group.add(self.__group_2)
self.__group_2.add_server(self.__server_3)
self.__group_2.add_server(self.__server_4)
tests.utils.configure_decoupled_master(self.__group_2, self.__server_3)
self.__options_5 = {
"uuid" : _uuid.UUID("{ee75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(2),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server5 = MySQLServer.discover_uuid(self.__options_5["address"])
self.__options_5["uuid"] = _uuid.UUID(uuid_server5)
self.__server_5 = MySQLServer(**self.__options_5)
MySQLServer.add(self.__server_5)
self.__server_5.connect()
self.__server_5.exec_stmt("DROP DATABASE IF EXISTS prune_db")
self.__server_5.exec_stmt("CREATE DATABASE prune_db")
self.__server_5.exec_stmt("CREATE TABLE prune_db.prune_table"
"(userID INT, name VARCHAR(30))")
self.__server_5.exec_stmt("INSERT INTO prune_db.prune_table "
"VALUES(101, 'TEST 1')")
self.__server_5.exec_stmt("INSERT INTO prune_db.prune_table "
"VALUES(202, 'TEST 2')")
self.__options_6 = {
"uuid" : _uuid.UUID("{ff75a12a-98d1-414c-96af-9e9d4b179678}"),
"address" : "server_6.mysql.com:3060",
}
self.__server_6 = MySQLServer(**self.__options_6)
MySQLServer.add(self.__server_6)
self.__group_3 = Group("GROUPID3", "Third description.")
Group.add(self.__group_3)
self.__group_3.add_server(self.__server_5)
self.__group_3.add_server(self.__server_6)
tests.utils.configure_decoupled_master(self.__group_3, self.__server_5)
group_4 = Group("GROUPID4", "4TH description.")
Group.add(group_4)
group_5 = Group("GROUPID5", "5TH description.")
Group.add(group_5)
group_6 = Group("GROUPID6", "6TH description.")
Group.add(group_6)
group_7 = Group("GROUPID7", "7TH description.")
Group.add(group_7)
group_8 = Group("GROUPID8", "8TH description.")
Group.add(group_8)
group_9 = Group("GROUPID9", "9TH description.")
Group.add(group_9)
group_10 = Group("GROUPID10", "10TH description.")
Group.add(group_10)
group_11 = Group("GROUPID11", "11TH description.")
Group.add(group_11)
#.........这里部分代码省略.........
示例11: test_privileges
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def test_privileges(self):
"""Test whether user's have the appropriate privileges.
"""
# Some privileges
MINIMUM_PRIVILEGES = [
"REPLICATION SLAVE", "REPLICATION CLIENT", "SUPER",
"SHOW DATABASES", "RELOAD"
]
# Connect to server as root and create temporary user.
uuid = MySQLServer.discover_uuid(OPTIONS["address"])
server = MySQLServer(
_uuid.UUID(uuid), OPTIONS["address"],
tests.utils.MySQLInstances().root_user,
tests.utils.MySQLInstances().root_passwd
)
ConnectionPool().purge_connections(_uuid.UUID(uuid))
server.connect()
server.set_session_binlog(False)
server.exec_stmt(
"CREATE USER 'jeffrey'@'%%' IDENTIFIED BY 'mypass'"
)
# Check if jeffrey (temporary user) has the appropriate privileges.
# There is not privilege associate to jeffrey.
new_server = MySQLServer(
_uuid.UUID(uuid), OPTIONS["address"], "jeffrey", "mypass"
)
new_server.connect()
self.assertFalse(
new_server.has_privileges(MINIMUM_PRIVILEGES)
)
# Check if jeffrey (temporary user) has the appropriate privileges.
# Grant required privileges except RELOAD
# There is no RELOAD on a global level.
privileges=", ".join([priv for priv in MINIMUM_PRIVILEGES
if priv != "RELOAD"]
)
server.exec_stmt(
"GRANT {privileges} ON *.* TO 'jeffrey'@'%%'".format(
privileges=privileges)
)
server.exec_stmt("FLUSH PRIVILEGES")
self.assertFalse(
new_server.has_privileges(MINIMUM_PRIVILEGES)
)
# Check if jeffrey (temporary user) has the appropriate privileges.
# The RELOAD on a global level was granted.
server.exec_stmt("GRANT RELOAD ON *.* TO 'jeffrey'@'%%'")
server.exec_stmt("FLUSH PRIVILEGES")
self.assertTrue(
new_server.has_privileges(MINIMUM_PRIVILEGES)
)
# Check if jeffrey (temporary user) has the appropriate privileges.
# Revoke privilegs from temporary user.
# There is no ALL on a global level.
server.exec_stmt("REVOKE ALL PRIVILEGES, GRANT OPTION FROM "
"'jeffrey'@'%%'"
)
server.exec_stmt("GRANT ALL ON fabric.* TO 'jeffrey'@'%%'")
server.exec_stmt("FLUSH PRIVILEGES")
self.assertFalse(
new_server.has_privileges(MINIMUM_PRIVILEGES)
)
# Check if jeffrey (temporary user) has the appropriate privileges.
# The ALL on a global level was granted.
server.exec_stmt("GRANT ALL ON *.* TO 'jeffrey'@'%%'")
server.exec_stmt("FLUSH PRIVILEGES")
self.assertTrue(
new_server.has_privileges(MINIMUM_PRIVILEGES)
)
# Drop temporary user.
server.exec_stmt("DROP USER 'jeffrey'@'%%'")
server.set_session_binlog(True)
server.disconnect()
new_server.disconnect()
ConnectionPool().purge_connections(_uuid.UUID(uuid))
示例12: setUp
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def setUp(self):
"""Create the setup for performing the testing of the server clone
command.
"""
from __main__ import mysqldump_path, mysqlclient_path
self.manager, self.proxy = tests.utils.setup_xmlrpc()
self.__options_1 = {
"uuid" : _uuid.UUID("{aa75b12b-98d1-414c-96af-9e9d4b179678}"),
"address": MySQLInstances().get_address(0),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server1 = MySQLServer.discover_uuid(self.__options_1["address"])
self.__options_1["uuid"] = _uuid.UUID(uuid_server1)
self.__server_1 = MySQLServer(**self.__options_1)
MySQLServer.add(self.__server_1)
self.__server_1.connect()
self.__options_2 = {
"uuid" : _uuid.UUID("{aa45b12b-98d1-414c-96af-9e9d4b179678}"),
"address":MySQLInstances().get_address(1),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server2 = MySQLServer.discover_uuid(self.__options_2["address"])
self.__options_2["uuid"] = _uuid.UUID(uuid_server2)
self.__server_2 = MySQLServer(**self.__options_2)
MySQLServer.add(self.__server_2)
self.__server_2.connect()
self.__options_3 = {
"uuid" : _uuid.UUID("{aa45b12b-98d1-414c-96af-9e9d4b179678}"),
"address":MySQLInstances().get_address(2),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server3 = MySQLServer.discover_uuid(self.__options_3["address"])
self.__options_3["uuid"] = _uuid.UUID(uuid_server3)
self.__server_3 = MySQLServer(**self.__options_3)
MySQLServer.add(self.__server_3)
self.__server_3.connect()
#Insert data into Server 1
self.__server_1.exec_stmt("DROP DATABASE IF EXISTS db1")
self.__server_1.exec_stmt("CREATE DATABASE db1")
self.__server_1.exec_stmt("CREATE TABLE db1.t1"
"(userID INT, name VARCHAR(30))")
self.__server_1.exec_stmt("INSERT INTO db1.t1 "
"VALUES(101, 'TEST 1')")
self.__server_1.exec_stmt("INSERT INTO db1.t1 "
"VALUES(202, 'TEST 2')")
self.__server_1.exec_stmt("DROP DATABASE IF EXISTS db2")
self.__server_1.exec_stmt("CREATE DATABASE db2")
self.__server_1.exec_stmt("CREATE TABLE db2.t1"
"(userID INT, name VARCHAR(30))")
self.__server_1.exec_stmt("INSERT INTO db2.t1 "
"VALUES(101, 'TEST 1')")
self.__server_1.exec_stmt("INSERT INTO db2.t1 "
"VALUES(202, 'TEST 2')")
示例13: setUp
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def setUp(self):
"""Configure the existing environment
"""
self.manager, self.proxy = tests.utils.setup_xmlrpc()
self.__options_1 = {
"uuid" : _uuid.UUID("{aa75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(0),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server1 = MySQLServer.discover_uuid(self.__options_1["address"])
self.__options_1["uuid"] = _uuid.UUID(uuid_server1)
self.__server_1 = MySQLServer(**self.__options_1)
MySQLServer.add(self.__server_1)
self.__options_2 = {
"uuid" : _uuid.UUID("{aa45b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(1),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server2 = MySQLServer.discover_uuid(self.__options_2["address"])
self.__options_2["uuid"] = _uuid.UUID(uuid_server2)
self.__server_2 = MySQLServer(**self.__options_2)
MySQLServer.add(self.__server_2)
self.__group_1 = Group("GROUPID1", "First description.")
Group.add(self.__group_1)
self.__group_1.add_server(self.__server_1)
self.__group_1.add_server(self.__server_2)
tests.utils.configure_decoupled_master(self.__group_1, self.__server_1)
self.__options_3 = {
"uuid" : _uuid.UUID("{bb75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(2),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server3 = MySQLServer.discover_uuid(self.__options_3["address"])
self.__options_3["uuid"] = _uuid.UUID(uuid_server3)
self.__server_3 = MySQLServer(**self.__options_3)
MySQLServer.add( self.__server_3)
self.__options_4 = {
"uuid" : _uuid.UUID("{bb45b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(3),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server4 = MySQLServer.discover_uuid(self.__options_4["address"])
self.__options_4["uuid"] = _uuid.UUID(uuid_server4)
self.__server_4 = MySQLServer(**self.__options_4)
MySQLServer.add(self.__server_4)
self.__group_2 = Group("GROUPID2", "Second description.")
Group.add(self.__group_2)
self.__group_2.add_server(self.__server_3)
self.__group_2.add_server(self.__server_4)
tests.utils.configure_decoupled_master(self.__group_2, self.__server_3)
self.__options_5 = {
"uuid" : _uuid.UUID("{cc75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(4),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server5 = MySQLServer.discover_uuid(self.__options_5["address"])
self.__options_5["uuid"] = _uuid.UUID(uuid_server5)
self.__server_5 = MySQLServer(**self.__options_5)
MySQLServer.add(self.__server_5)
self.__options_6 = {
"uuid" : _uuid.UUID("{cc45b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(5),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server6 = MySQLServer.discover_uuid(self.__options_6["address"])
self.__options_6["uuid"] = _uuid.UUID(uuid_server6)
self.__server_6 = MySQLServer(**self.__options_6)
MySQLServer.add(self.__server_6)
self.__group_3 = Group("GROUPID3", "Third description.")
Group.add( self.__group_3)
self.__group_3.add_server(self.__server_5)
self.__group_3.add_server(self.__server_6)
tests.utils.configure_decoupled_master(self.__group_3, self.__server_5)
status = self.proxy.sharding.create_definition("RANGE", "GROUPID1")
self.assertStatus(status, _executor.Job.SUCCESS)
self.assertEqual(status[1][-1]["state"], _executor.Job.COMPLETE)
self.assertEqual(status[1][-1]["description"],
"Executed action (_define_shard_mapping).")
#.........这里部分代码省略.........
示例14: setUp
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def setUp(self):
"""Creates the following topology for testing,
GROUPID1 - localhost:13001, localhost:13002 - Global Group
GROUPID2 - localhost:13003, localhost:13004 - shard 1
GROUPID3 - localhost:13005, localhost:13006 - shard 2
"""
self.manager, self.proxy = tests.utils.setup_xmlrpc()
self.__options_1 = {
"uuid" : _uuid.UUID("{aa75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(0),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd
}
uuid_server1 = MySQLServer.discover_uuid(self.__options_1["address"])
self.__options_1["uuid"] = _uuid.UUID(uuid_server1)
self.__server_1 = MySQLServer(**self.__options_1)
MySQLServer.add(self.__server_1)
self.__group_1 = Group("GROUPID1", "First description.")
Group.add(self.__group_1)
self.__group_1.add_server(self.__server_1)
tests.utils.configure_decoupled_master(self.__group_1, self.__server_1)
self.__options_2 = {
"uuid" : _uuid.UUID("{aa45b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(1),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd
}
uuid_server2 = MySQLServer.discover_uuid(self.__options_2["address"])
self.__options_2["uuid"] = _uuid.UUID(uuid_server2)
self.__server_2 = MySQLServer(**self.__options_2)
MySQLServer.add(self.__server_2)
self.__server_2.connect()
self.__server_2.exec_stmt("DROP DATABASE IF EXISTS db1")
self.__server_2.exec_stmt("CREATE DATABASE db1")
self.__server_2.exec_stmt("CREATE TABLE db1.t1"
"(userID INT, name VARCHAR(30))")
for i in range(1, 601):
self.__server_2.exec_stmt("INSERT INTO db1.t1 "
"VALUES(%s, 'TEST %s')" % (i, i))
self.__group_2 = Group("GROUPID2", "Second description.")
Group.add(self.__group_2)
self.__group_2.add_server(self.__server_2)
tests.utils.configure_decoupled_master(self.__group_2, self.__server_2)
self.__options_3 = {
"uuid" : _uuid.UUID("{bb75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(2),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd
}
uuid_server3 = MySQLServer.discover_uuid(self.__options_3["address"])
self.__options_3["uuid"] = _uuid.UUID(uuid_server3)
self.__server_3 = MySQLServer(**self.__options_3)
MySQLServer.add( self.__server_3)
self.__server_3.connect()
self.__server_3.exec_stmt("DROP DATABASE IF EXISTS db1")
self.__server_3.exec_stmt("CREATE DATABASE db1")
self.__server_3.exec_stmt("CREATE TABLE db1.t1"
"(userID INT, name VARCHAR(30))")
for i in range(1, 601):
self.__server_3.exec_stmt("INSERT INTO db1.t1 "
"VALUES(%s, 'TEST %s')" % (i, i))
self.__group_3 = Group("GROUPID3", "Third description.")
Group.add( self.__group_3)
self.__group_3.add_server(self.__server_3)
tests.utils.configure_decoupled_master(self.__group_3, self.__server_3)
self.__options_4 = {
"uuid" : _uuid.UUID("{bb45b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(3),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd
}
uuid_server4 = MySQLServer.discover_uuid(self.__options_4["address"])
self.__options_4["uuid"] = _uuid.UUID(uuid_server4)
self.__server_4 = MySQLServer(**self.__options_4)
MySQLServer.add(self.__server_4)
self.__server_4.connect()
self.__server_4.exec_stmt("DROP DATABASE IF EXISTS db1")
self.__server_4.exec_stmt("CREATE DATABASE db1")
self.__server_4.exec_stmt("CREATE TABLE db1.t1"
"(userID INT, name VARCHAR(30))")
for i in range(1, 601):
self.__server_4.exec_stmt("INSERT INTO db1.t1 "
"VALUES(%s, 'TEST %s')" % (i, i))
self.__group_4 = Group("GROUPID4", "Fourth description.")
Group.add( self.__group_4)
self.__group_4.add_server(self.__server_4)
#.........这里部分代码省略.........
示例15: setUp
# 需要导入模块: from mysql.fabric.server import MySQLServer [as 别名]
# 或者: from mysql.fabric.server.MySQLServer import discover_uuid [as 别名]
def setUp(self):
"""Configure the existing environment
"""
tests.utils.cleanup_environment()
self.manager, self.proxy = tests.utils.setup_xmlrpc()
self.__options_1 = {
"uuid" : _uuid.UUID("{aa75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(0),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server1 = MySQLServer.discover_uuid(self.__options_1["address"])
self.__options_1["uuid"] = _uuid.UUID(uuid_server1)
self.__server_1 = MySQLServer(**self.__options_1)
MySQLServer.add(self.__server_1)
self.__server_1.connect()
self.__group_1 = Group("GROUPID1", "First description.")
Group.add(self.__group_1)
self.__group_1.add_server(self.__server_1)
tests.utils.configure_decoupled_master(self.__group_1, self.__server_1)
self.__options_2 = {
"uuid" : _uuid.UUID("{aa45b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(1),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server2 = MySQLServer.discover_uuid(self.__options_2["address"])
self.__options_2["uuid"] = _uuid.UUID(uuid_server2)
self.__server_2 = MySQLServer(**self.__options_2)
MySQLServer.add(self.__server_2)
self.__server_2.connect()
self.__server_2.exec_stmt("DROP DATABASE IF EXISTS db1")
self.__server_2.exec_stmt("CREATE DATABASE db1")
self.__server_2.exec_stmt("CREATE TABLE db1.t1"
"(userID INT PRIMARY KEY, name VARCHAR(30))")
for i in range(1, 1001):
self.__server_2.exec_stmt("INSERT INTO db1.t1 "
"VALUES(%s, 'TEST %s')" % (i, i))
self.__server_2.exec_stmt("DROP DATABASE IF EXISTS db2")
self.__server_2.exec_stmt("CREATE DATABASE db2")
self.__server_2.exec_stmt("CREATE TABLE db2.t2"
"(userID INT, salary INT, "
"CONSTRAINT FOREIGN KEY(userID) "
"REFERENCES db1.t1(userID))")
for i in range(1, 1001):
self.__server_2.exec_stmt("INSERT INTO db2.t2 "
"VALUES(%s, %s)" % (i, i))
self.__group_2 = Group("GROUPID2", "Second description.")
Group.add(self.__group_2)
self.__group_2.add_server(self.__server_2)
tests.utils.configure_decoupled_master(self.__group_2, self.__server_2)
self.__options_3 = {
"uuid" : _uuid.UUID("{bb75b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(2),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server3 = MySQLServer.discover_uuid(self.__options_3["address"])
self.__options_3["uuid"] = _uuid.UUID(uuid_server3)
self.__server_3 = MySQLServer(**self.__options_3)
MySQLServer.add( self.__server_3)
self.__server_3.connect()
self.__server_3.exec_stmt("DROP DATABASE IF EXISTS db1")
self.__server_3.exec_stmt("CREATE DATABASE db1")
self.__server_3.exec_stmt("CREATE TABLE db1.t1"
"(userID INT PRIMARY KEY, name VARCHAR(30))")
for i in range(1, 1001):
self.__server_3.exec_stmt("INSERT INTO db1.t1 "
"VALUES(%s, 'TEST %s')" % (i, i))
self.__server_3.exec_stmt("DROP DATABASE IF EXISTS db2")
self.__server_3.exec_stmt("CREATE DATABASE db2")
self.__server_3.exec_stmt("CREATE TABLE db2.t2"
"(userID INT, salary INT, "
"CONSTRAINT FOREIGN KEY(userID) "
"REFERENCES db1.t1(userID))")
for i in range(1, 1001):
self.__server_3.exec_stmt("INSERT INTO db2.t2 "
"VALUES(%s, %s)" % (i, i))
self.__group_3 = Group("GROUPID3", "Third description.")
Group.add( self.__group_3)
self.__group_3.add_server(self.__server_3)
tests.utils.configure_decoupled_master(self.__group_3, self.__server_3)
self.__options_4 = {
"uuid" : _uuid.UUID("{bb45b12b-98d1-414c-96af-9e9d4b179678}"),
"address" : MySQLInstances().get_address(3),
"user" : MySQLInstances().user,
"passwd" : MySQLInstances().passwd,
}
uuid_server4 = MySQLServer.discover_uuid(self.__options_4["address"])
#.........这里部分代码省略.........