本文整理汇总了Python中membase.api.rest_client.RestConnection.force_eject_node方法的典型用法代码示例。如果您正苦于以下问题:Python RestConnection.force_eject_node方法的具体用法?Python RestConnection.force_eject_node怎么用?Python RestConnection.force_eject_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类membase.api.rest_client.RestConnection
的用法示例。
在下文中一共展示了RestConnection.force_eject_node方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testClusterInitNegative
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def testClusterInitNegative(self):
cluster_init_username = self.input.param("cluster_init_username", None)
cluster_init_password = self.input.param("cluster_init_password", None)
cluster_init_port = self.input.param("cluster_init_port", None)
cluster_init_ramsize = self.input.param("cluster_init_ramsize", None)
command_init = self.input.param("command_init", "cluster-init")
server = self.servers[-1]
remote_client = RemoteMachineShellConnection(server)
rest = RestConnection(server)
rest.force_eject_node()
self.sleep(5)
try:
cli_command = command_init
options = ""
if cluster_init_username is not None:
options += "--cluster-init-username={0} ".format(cluster_init_username)
if cluster_init_password is not None:
options += "--cluster-init-password={0} ".format(cluster_init_password)
if cluster_init_port is not None:
options += "--cluster-init-port={0} ".format(cluster_init_port)
if cluster_init_ramsize is None:
options += "--cluster-init-ramsize={0} ".format(cluster_init_ramsize)
output, error = remote_client.execute_couchbase_cli(cli_command=cli_command, options=options, cluster_host="localhost", user=None, password=None)
self.assertEqual(output[0], 'ERROR: unable to init localhost (400) Bad Request')
self.assertTrue(output[1] == "[u'Username and password are required.']" or output[1] == "[u'The password must be at least six characters.']")
remote_client.disconnect()
finally:
rest = RestConnection(server)
rest.force_eject_node()
self.sleep(5)
rest.init_cluster()
示例2: testClusterInit
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def testClusterInit(self):
cluster_init_username = self.input.param("cluster_init_username", "Administrator")
cluster_init_password = self.input.param("cluster_init_password", "password")
cluster_init_port = self.input.param("cluster_init_port", 8091)
cluster_init_ramsize = self.input.param("cluster_init_ramsize", 300)
command_init = self.input.param("command_init", "cluster-init")
param_prefix = self.input.param("param_prefix", "--cluster-init")
server = self.servers[-1]
remote_client = RemoteMachineShellConnection(server)
rest = RestConnection(server)
rest.force_eject_node()
self.sleep(5)
try:
cli_command = command_init
options = "--cluster-init-username={0} {1}-password={2} {3}-port={4} {5}-ramsize={6}".\
format(cluster_init_username, param_prefix, cluster_init_password, param_prefix, cluster_init_port, param_prefix, cluster_init_ramsize)
output, error = remote_client.execute_couchbase_cli(cli_command=cli_command, options=options, cluster_host="localhost", user="Administrator", password="password")
self.assertEqual(output[0], "SUCCESS: init localhost")
options = "{0}-username={1} {2}-password={3} {4}-port={5}".\
format(param_prefix, cluster_init_username + "1", param_prefix, cluster_init_password + "1", param_prefix, str(cluster_init_port)[:-1] + "9")
output, error = remote_client.execute_couchbase_cli(cli_command=cli_command, options=options, cluster_host="localhost", user=cluster_init_username, password=cluster_init_password)
# MB-8202 cluster-init/edit doesn't provide status
self.assertTrue(output == [])
server.rest_username = cluster_init_username + "1"
server.rest_password = cluster_init_password + "1"
server.port = str(cluster_init_port)[:-1] + "9"
cli_command = "server-list"
output, error = remote_client.execute_couchbase_cli(cli_command=cli_command, cluster_host="localhost", cluster_port=str(cluster_init_port)[:-1] + "9", user=cluster_init_username + "1", password=cluster_init_password + "1")
self.assertTrue("{0} healthy active".format(str(cluster_init_port)[:-1] + "9") in output[0])
server_info = self._get_cluster_info(remote_client, cluster_port=server.port, user=server.rest_username, password=server.rest_password)
result = server_info["otpNode"] + " " + server_info["hostname"] + " " + server_info["status"] + " " + server_info["clusterMembership"]
self.assertTrue("{0} healthy active".format(str(cluster_init_port)[:-1] + "9") in result)
cli_command = command_init
options = "{0}-username={1} {2}-password={3} {4}-port={5}".\
format(param_prefix, cluster_init_username, param_prefix, cluster_init_password, param_prefix, cluster_init_port)
output, error = remote_client.execute_couchbase_cli(cli_command=cli_command, options=options, cluster_host="localhost", cluster_port=str(cluster_init_port)[:-1] + "9", user=(cluster_init_username + "1"), password=cluster_init_password + "1")
# MB-8202 cluster-init/edit doesn't provide status
self.assertTrue(output == [])
server.rest_username = cluster_init_username
server.rest_password = cluster_init_password
server.port = cluster_init_port
remote_client = RemoteMachineShellConnection(server)
cli_command = "server-list"
output, error = remote_client.execute_couchbase_cli(cli_command=cli_command, cluster_host="localhost", user=cluster_init_username, password=cluster_init_password)
self.assertTrue("{0} healthy active".format(str(cluster_init_port)) in output[0])
server_info = self._get_cluster_info(remote_client, cluster_port=server.port, user=server.rest_username, password=server.rest_password)
result = server_info["otpNode"] + " " + server_info["hostname"] + " " + server_info["status"] + " " + server_info["clusterMembership"]
self.assertTrue("{0} healthy active".format(str(cluster_init_port)) in result)
remote_client.disconnect()
finally:
rest = RestConnection(server)
rest.force_eject_node()
self.sleep(5)
rest.init_cluster()
示例3: _deinitialize_api
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def _deinitialize_api(self):
for server in self.servers:
try:
rest = RestConnection(server)
rest.force_eject_node()
time.sleep(10)
except BaseException, e:
self.fail(e)
示例4: _deinitialize_api
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def _deinitialize_api(self):
for server in self.servers:
try:
rest = RestConnection(server)
rest.force_eject_node()
self.driver.refresh()
except BaseException, e:
self.fail(e)
示例5: cleanup_cluster
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def cleanup_cluster(servers, wait_for_rebalance=True, master = None):
log = logger.Logger.get_logger()
if master == None:
master = servers[0]
rest = RestConnection(master)
helper = RestHelper(rest)
helper.is_ns_server_running(timeout_in_seconds=testconstants.NS_SERVER_TIMEOUT)
nodes = rest.node_statuses()
master_id = rest.get_nodes_self().id
for node in nodes:
if int(node.port) in xrange(9091, 9991):
rest.eject_node(node)
nodes.remove(node)
if len(nodes) > 1:
log.info("rebalancing all nodes in order to remove nodes")
rest.log_client_error("Starting rebalance from test, ejected nodes %s" % \
[node.id for node in nodes if node.id != master_id])
removed = helper.remove_nodes(knownNodes=[node.id for node in nodes],
ejectedNodes=[node.id for node in nodes if node.id != master_id],
wait_for_rebalance=wait_for_rebalance)
success_cleaned = []
for removed in [node for node in nodes if (node.id != master_id)]:
removed.rest_password = servers[0].rest_password
removed.rest_username = servers[0].rest_username
try:
rest = RestConnection(removed)
except Exception as ex:
log.error("can't create rest connection after rebalance out for ejected nodes,\
will retry after 10 seconds according to MB-8430: {0} ".format(ex))
time.sleep(10)
rest = RestConnection(removed)
start = time.time()
while time.time() - start < 30:
if len(rest.get_pools_info()["pools"]) == 0:
success_cleaned.append(removed)
break
else:
time.sleep(0.1)
if time.time() - start > 10:
log.error("'pools' on node {0}:{1} - {2}".format(
removed.ip, removed.port, rest.get_pools_info()["pools"]))
for node in set([node for node in nodes if (node.id != master_id)]) - set(success_cleaned):
log.error("node {0}:{1} was not cleaned after removing from cluster".format(
removed.ip, removed.port))
try:
rest = RestConnection(node)
rest.force_eject_node()
except Exception as ex:
log.error("force_eject_node {0}:{1} failed: {2}".format(removed.ip, removed.port, ex))
if len(set([node for node in nodes if (node.id != master_id)])\
- set(success_cleaned)) != 0:
raise Exception("not all ejected nodes were cleaned successfully")
log.info("removed all the nodes from cluster associated with {0} ? {1}".format(servers[0], \
[(node.id, node.port) for node in nodes if (node.id != master_id)]))
示例6: tearDown
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def tearDown(self):
try:
if hasattr(self, 'skip_buckets_handle') and self.skip_buckets_handle:
return
test_failed = (hasattr(self, '_resultForDoCleanups') and len(self._resultForDoCleanups.failures or self._resultForDoCleanups.errors)) \
or (hasattr(self, '_exc_info') and self._exc_info()[1] is not None)
if test_failed and TestInputSingleton.input.param("stop-on-failure", False)\
or self.input.param("skip_cleanup", False):
self.log.warn("CLEANUP WAS SKIPPED")
else:
if test_failed and TestInputSingleton.input.param('get_trace', None):
for server in self.servers:
try:
shell = RemoteMachineShellConnection(server)
output, _ = shell.execute_command("ps -aef|grep %s" %
TestInputSingleton.input.param('get_trace', None))
output = shell.execute_command("pstack %s" % output[0].split()[1].strip())
print output[0]
except:
pass
if test_failed and self.input.param('BUGS', False):
self.log.warn("Test failed. Possible reason is: {0}".format(self.input.param('BUGS', False)))
self.log.info("============== basetestcase cleanup was started for test #{0} {1} =============="\
.format(self.case_number, self._testMethodName))
rest = RestConnection(self.master)
alerts = rest.get_alerts()
if alerts is not None and len(alerts) != 0:
self.log.warn("Alerts were found: {0}".format(alerts))
if rest._rebalance_progress_status() == 'running':
self.log.warning("rebalancing is still running, test should be verified")
stopped = rest.stop_rebalance()
self.assertTrue(stopped, msg="unable to stop rebalance")
BucketOperationHelper.delete_all_buckets_or_assert(self.servers, self)
if self.input.param("forceEject", False):
for server in self.servers:
if server != self.servers[0]:
try:
rest = RestConnection(server)
rest.force_eject_node()
except BaseException, e:
self.log.error(e)
ClusterOperationHelper.cleanup_cluster(self.servers)
self.sleep(10)
ClusterOperationHelper.wait_for_ns_servers_or_assert(self.servers, self)
self.log.info("============== basetestcase cleanup was finished for test #{0} {1} =============="\
.format(self.case_number, self._testMethodName))
except BaseException:
# increase case_number to retry tearDown in setup for the next test
self.case_number += 1000
finally:
# stop all existing task manager threads
self.cluster.shutdown(force=True)
self._log_finish(self)
示例7: tearDown
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def tearDown(self):
try:
test_failed = (
hasattr(self, "_resultForDoCleanups")
and len(self._resultForDoCleanups.failures or self._resultForDoCleanups.errors)
) or (hasattr(self, "_exc_info") and self._exc_info()[1] is not None)
if (
test_failed
and TestInputSingleton.input.param("stop-on-failure", False)
or self.input.param("skip_cleanup", False)
):
self.log.warn("CLEANUP WAS SKIPPED")
else:
if test_failed and self.input.param("BUGS", False):
self.log.warn("Test failed. Possible reason is: {0}".format(self.input.param("BUGS", False)))
self.log.info(
"============== basetestcase cleanup was started for test #{0} {1} ==============".format(
self.case_number, self._testMethodName
)
)
rest = RestConnection(self.master)
alerts = rest.get_alerts()
if alerts is not None and len(alerts) != 0:
self.log.warn("Alerts were found: {0}".format(alerts))
if rest._rebalance_progress_status() == "running":
self.log.warning("rebalancing is still running, test should be verified")
stopped = rest.stop_rebalance()
self.assertTrue(stopped, msg="unable to stop rebalance")
BucketOperationHelper.delete_all_buckets_or_assert(self.servers, self)
if self.input.param("forceEject", False):
for server in self.servers:
if server != self.servers[0]:
try:
rest = RestConnection(server)
rest.force_eject_node()
except BaseException, e:
self.log.error(e)
ClusterOperationHelper.cleanup_cluster(self.servers)
self.sleep(10)
ClusterOperationHelper.wait_for_ns_servers_or_assert(self.servers, self)
self.log.info(
"============== basetestcase cleanup was finished for test #{0} {1} ==============".format(
self.case_number, self._testMethodName
)
)
except BaseException:
# increase case_number to retry tearDown in setup for the next test
self.case_number += 1000
finally:
# stop all existing task manager threads
self.cluster.shutdown()
self._log_finish(self)
示例8: test_multiple_backups_merges
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def test_multiple_backups_merges(self):
self.log.info("*** start to load items to all buckets")
self.expected_error = self.input.param("expected_error", None)
if int(self.active_resident_threshold) > 0:
self.log.info("Disable compaction to speed up dgm")
RestConnection(self.master).disable_auto_compaction()
if self.expires:
for bucket in self.buckets:
cb = self._get_python_sdk_client(self.master.ip, bucket, self.backupset.cluster_host)
for i in range(1, self.num_items + 1):
cb.upsert("doc" + str(i), {"key":"value"})
else:
self._load_all_buckets(self.master, self.initial_load_gen,
"create", self.expires)
self.log.info("*** done to load items to all buckets")
self.backup_create_validate()
for i in range(1, self.number_of_repeats + 1):
self.do_backup_merge_actions()
start = self.number_of_backups_taken
end = self.number_of_backups_taken
if self.reset_restore_cluster:
self.log.info("*** start to reset cluster")
self.backup_reset_clusters(self.cluster_to_restore)
if self.same_cluster:
self._initialize_nodes(Cluster(),
self.servers[:self.nodes_init])
else:
rest = RestConnection(self.input.clusters[0][0])
rest.force_eject_node()
master_services = self.get_services([self.backupset.cluster_host],
self.services_init, start_node=0)
info = rest.get_nodes_self()
if info.memoryQuota and int(info.memoryQuota) > 0:
self.quota = info.memoryQuota
rest.init_node()
self.log.info("Done reset cluster")
self.sleep(10)
""" Add built-in user cbadminbucket to second cluster """
self.add_built_in_server_user(
node=self.input.clusters[0][:self.nodes_init][0])
self.backupset.start = start
self.backupset.end = end
self.log.info("*** start restore validation")
self.backup_restore_validate(compare_uuid=False,
seqno_compare_function=">=",
expected_error=self.expected_error)
示例9: _add_service_node
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def _add_service_node(self, cwc_servers, serices_add, services="kv"):
if serices_add == 1:
total_servers = cwc_servers[:3]
elif services_add > 1:
total_servers = cwc_servers[:len(nodes) + 1]
add_node_rest = RestConnection(cwc_servers[len(nodes)])
try:
add_node_rest.force_eject_node()
status = add_node_rest.init_node_services(
hostname=cwc_servers[len(nodes)].ip,
services=services)
init_node = self.cluster.async_init_node(cwc_servers[len(nodes)])
self.log.info("===== add node %s with service %s =====" \
% (cwc_servers[len(nodes)].ip,
services))
self.cluster.rebalance(total_servers, [cwc_servers[len(nodes)]], \
[], services=services)
except Exception, e:
if e:
print e
示例10: testNodeInit
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def testNodeInit(self):
server = self.servers[-1]
remote_client = RemoteMachineShellConnection(server)
prefix = ''
type = remote_client.extract_remote_info().distribution_type
if type.lower() == 'windows':
prefix_path = "C:"
data_path = self.input.param("data_path", None)
index_path = self.input.param("index_path", None)
if data_path is not None:
data_path = prefix + data_path.replace('|', "/")
if index_path is not None:
index_path = prefix + index_path.replace('|', "/")
server_info = self._get_cluster_info(remote_client, cluster_port=server.port, user=server.rest_username, password=server.rest_password)
data_path_before = server_info["storage"]["hdd"][0]["path"]
index_path_before = server_info["storage"]["hdd"][0]["index_path"]
try:
rest = RestConnection(server)
rest.force_eject_node()
self.sleep(5)
cli_command = "node-init"
options = ""
options += ("--node-init-data-path={0} ".format(data_path), "")[data_path is None]
options += ("--node-init-index-path={0} ".format(index_path), "")[index_path is None]
output, error = remote_client.execute_couchbase_cli(cli_command=cli_command, options=options, cluster_host="localhost", user="Administrator", password="password")
self.assertEqual(output[0], "SUCCESS: init localhost")
rest.init_cluster()
server_info = self._get_cluster_info(remote_client, cluster_port=server.port, user=server.rest_username, password=server.rest_password)
data_path_after = server_info["storage"]["hdd"][0]["path"]
index_path_after = server_info["storage"]["hdd"][0]["index_path"]
self.assertEqual((data_path, data_path_before)[data_path is None], data_path_after)
self.assertEqual((index_path, index_path_before)[index_path is None], index_path_after)
finally:
rest = RestConnection(server)
rest.force_eject_node()
self.sleep(5)
rest.init_cluster()
示例11: tearDown
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def tearDown(self):
rest = RestConnection(self.master)
if rest._rebalance_progress_status() == 'running':
self.log.warning("rebalancing is still running, test should be verified")
stopped = rest.stop_rebalance()
self.assertTrue(stopped, msg="unable to stop rebalance")
try:
super(QueriesOpsTests, self).tearDown()
except:
pass
try:
ClusterOperationHelper.cleanup_cluster(self.servers, master=self.master)
self.sleep(1)
except:
for server in set(self.servers) - set([self.master]):
try:
rest = RestConnection(server)
rest.force_eject_node()
time.sleep(1)
except BaseException, e:
self.fail(e)
示例12: CreateBucketTests
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
#.........这里部分代码省略.........
self.log.info("message {0} is not in log".format(self.log_message))
elif output:
raise Exception("The message %s is in log." % self.log_message)
else:
raise Exception("No thing to test. You need to put log_message=something_to_test")
""" check for if there is a curly bracket { in the first 10 lines in diag log.
If there is a {, possibly it is from erlang dump """
def test_log_output_on_top(self):
self._load_doc_data_all_buckets(data_op="create", batch_size=5000)
serverInfo = self.servers[0]
shell = RemoteMachineShellConnection(serverInfo)
self.log.info("download diag into local server {0}".format(serverInfo.ip))
ot = shell.execute_command("curl -v -u Administrator:password \
http://{0}:8091/diag > diag".format(serverInfo.ip))
r_path = shell.execute_command("pwd")
file_path = r_path[0][0] + "/diag"
sftp = shell._ssh_client.open_sftp()
f = sftp.open(file_path, 'r')
# check first 10 lines in diag file, looking for this '{'
self.log.info("check if there is any curly bracket in first 10 lines")
count = 0
for line in f:
print line
if "{" in line:
raise Exception("Curly bracket '{' is in first 10 lines at %s diag log" % serverInfo.ip)
count += 1
if count == 10:
break
""" delete diag file after create """
sftp.remove(file_path)
sftp.close()
def test_travel_sample_bucket(self):
sample = "travel-sample"
""" reset node to set services correctly: index,kv,n1ql """
self.rest.force_eject_node()
status = False
try:
status = self.rest.init_node_services(hostname=self.master.ip,
services= ["index,kv,n1ql"])
init_node = self.cluster.async_init_node(self.master,
services = ["index,kv,n1ql"])
except Exception, e:
if e:
print e
if status:
if self.node_version[:5] in COUCHBASE_FROM_WATSON:
self.rest.set_indexer_storage_mode(storageMode="memory_optimized")
shell = RemoteMachineShellConnection(self.master)
shell.execute_command("""curl -v -u Administrator:password \
-X POST http://{0}:8091/sampleBuckets/install \
-d '["travel-sample"]'""".format(self.master.ip))
shell.disconnect()
buckets = RestConnection(self.master).get_buckets()
for bucket in buckets:
if bucket.name != "travel-sample":
self.fail("travel-sample bucket did not create")
""" check for load data into travel-sample bucket """
end_time = time.time() + 120
while time.time() < end_time:
self.sleep(10)
num_actual = self.get_item_count(self.master,"travel-sample")
if int(num_actual) == self.total_items_travel_sample:
break
self.assertTrue(int(num_actual) == self.total_items_travel_sample,
"Items number expected %s, actual %s" % (
self.total_items_travel_sample, num_actual))
""" check all indexes are completed """
index_name = []
result = self.rest.index_tool_stats()
end_time_i = time.time() + 60
while time.time() < end_time_i and len(index_name) < 8:
for map in result:
if result["indexes"]:
for x in result["indexes"]:
if x["bucket"] == "travel-sample":
if x["progress"] < 100:
self.sleep(7, "waiting for indexing {0} complete"
.format(x["index"]))
result = self.rest.index_tool_stats()
elif x["progress"] == 100:
if x["index"] not in index_name:
index_name.append(x["index"])
self.sleep(7, "waiting for other indexing complete")
result = self.rest.index_tool_stats()
else:
self.sleep(7, "waiting for indexing start")
result = self.rest.index_tool_stats()
if time.time() >= end_time_i and len(index_name) < 8:
self.log.info("index list {0}".format(index_name))
self.fail("some indexing may not complete")
elif len(index_name) == 8:
self.log.info("travel-sample bucket is created and complete indexing")
self.log.info("index list in travel-sample bucket: {0}"
.format(index_name))
示例13: _deinitialize_servers
# 需要导入模块: from membase.api.rest_client import RestConnection [as 别名]
# 或者: from membase.api.rest_client.RestConnection import force_eject_node [as 别名]
def _deinitialize_servers(self, servers):
for server in servers:
rest = RestConnection(server)
rest.force_eject_node()
self.sleep(3, "Sleep to wait deinitialize")