def _test_multi_get(self, client, howmany): mc_message = "memcached virt memory size {0} : resident memory size : {1}" mx_message = "moxi virt memory size {0} : resident memory size : {1}" shell = RemoteMachineShellConnection(self.master) moxi_pid = RemoteMachineHelper(shell).is_process_running("moxi").pid mc_pid = RemoteMachineHelper(shell).is_process_running("memcached").pid keys = self._insert_data(client, howmany) self.keys_cleanup.extend(keys) self.log.info("printing moxi and memcached stats before running multi-get") moxi_sys_stats = self._extract_proc_info(shell, moxi_pid) memcached_sys_stats = self._extract_proc_info(shell, mc_pid) self.log.info(mc_message.format(int(memcached_sys_stats["rss"]) * 4096, memcached_sys_stats["vsize"])) self.log.info(mx_message.format(int(moxi_sys_stats["rss"]) * 4096, moxi_sys_stats["vsize"])) self.log.info("running multiget to get {0} keys".format(howmany)) gets = client.getMulti(keys) self.log.info("recieved {0} keys".format(len(gets))) self.log.info(gets) self.assertEquals(len(gets), len(keys)) self.log.info("printing moxi and memcached stats after running multi-get") moxi_sys_stats = self._extract_proc_info(shell, moxi_pid) memcached_sys_stats = self._extract_proc_info(shell, mc_pid) self.log.info(mc_message.format(int(memcached_sys_stats["rss"]) * 4096, memcached_sys_stats["vsize"])) self.log.info(mx_message.format(int(moxi_sys_stats["rss"]) * 4096, moxi_sys_stats["vsize"]))
def test_multiple_prompt_enter_correct_1retries(self): try: self.secretmgmt_base_obj.set_password(self.master, self.password) shell = RemoteMachineShellConnection(self.master) shell.execute_command("/opt/couchbase/etc/couchbase_init.d stop") self.secretmgmt_base_obj.start_server_prompt_diff_window( self.master) self.sleep(10) # self.secretmgmt_base_obj.incorrect_password(self.master, cmd="/opt/couchbase/bin/cbmaster_password", # retries_number=1, input_correct_pass=True, correct_pass='******') cmd = "/opt/couchbase/bin/couchbase-cli master-password -c localhost:8091 -u Administrator -p password --send-password" temp_result = self.secretmgmt_base_obj.incorrect_password( self.master, cmd=cmd, retries_number=1, input_correct_pass=True, correct_pass=self.password) self.assertTrue( temp_result, "Issue with incorrect password for 1 times and then correct password" ) finally: for server in self.servers: shell = RemoteMachineShellConnection(server) if (RemoteMachineHelper(shell).is_process_running('memcached') is None): shell.set_environment_variable("CB_MASTER_PASSWORD", self.password)
def system_stats(self, nodes, pnames, frequency, verbosity=False): shells = [] for node in nodes: try: bucket = RestConnection(node).get_buckets()[0].name MemcachedClientHelper.direct_client(node, bucket) shells.append(RemoteMachineShellConnection(node)) except: pass d = {"snapshots": []} # "pname":"x","pid":"y","snapshots":[{"time":time,"value":value}] start_time = str(self._task["time"]) while not self._aborted(): time.sleep(frequency) current_time = time.time() i = 0 for shell in shells: node = nodes[i] unique_id = node.ip + '-' + start_time for pname in pnames: obj = RemoteMachineHelper(shell).is_process_running(pname) if obj and obj.pid: value = self._extract_proc_info(shell, obj.pid) value["name"] = pname value["id"] = obj.pid value["unique_id"] = unique_id value["time"] = current_time value["ip"] = node.ip d["snapshots"].append(value) i += 1 self._task["systemstats"] = d["snapshots"] print " finished system_stats"
def start_sync_gateway(self, shell): self.log.info('=== start_sync_gateway_internal') self.kill_processes_gateway(shell) output, error = shell.execute_command_raw('ps -ef | grep sync_gateway') shell.log_command_output(output, error) if self.config != '': self.config = '/tmp/{0}'.format(self.config) output, error = shell.execute_command('cat {0}'.format(self.config)) shell.log_command_output(output, error) output, error = shell.execute_command( 'nohup /opt/couchbase-sync-gateway/bin/sync_gateway {0} {1} >/tmp/gateway.log 2>&1 &' .format(self.param, self.config)) shell.log_command_output(output, error) if not self.expected_error: obj = RemoteMachineHelper(shell).is_process_running('sync_gateway') if obj and obj.pid: self.log.info('Sync Gateway is running with pid of {0}'.format(obj.pid)) if not shell.file_exists('/tmp/', 'gateway.log'): self.log.info('Fail to find gateway.log') else: return True else: self.log.info('Sync Gateway is NOT running') output, error = shell.execute_command_raw('cat /tmp/gateway.log') shell.log_command_output(output, error) return False else: return self.check_message_in_gatewaylog(shell, self.expected_error)
def is_sync_gateway_process_running(self, shell): self.log.info('=== Check whether Sync Gateway process is running on {0}'.format(self.master)) obj = RemoteMachineHelper(shell).is_process_running('sync_gateway') if obj and obj.pid: self.log.info('Sync Gateway is running with pid of {0}'.format(obj.pid)) return True else: self.log.info('Sync Gateway is NOT running') return False
def _monitor_collect_log_mem_process(self): mem_stat = [] results = [] shell = RemoteMachineShellConnection(self.master) vsz, rss = RemoteMachineHelper(shell).monitor_process_memory('cbcollect_info') vsz_delta = max(abs(x - y) for (x, y) in zip(vsz[1:], vsz[:-1])) rss_delta = max(abs(x - y) for (x, y) in zip(rss[1:], rss[:-1])) self.log.info("The largest delta in VSZ: %s KB " % vsz_delta) self.log.info("The largest delta in RSS: %s KB " % rss_delta) if vsz_delta > 20000: self.fail("cbcollect_info process spikes up to 20 MB")
def test_kill_memcached(self): node_to_kill_mem = self.servers[:self.nodes_init][-1] iterations = self.input.param('iterations', 10) shell = RemoteMachineShellConnection(node_to_kill_mem) timeout = 10 try: for i in xrange(iterations): shell.kill_memcached() self.sleep(timeout, "wait for memcached recovery...") self.assertTrue( RemoteMachineHelper(shell).is_process_running('memcached'), "Memcached wasn't recover during %s seconds" % timeout) finally: shell.disconnect()
def test_multiple_prompt_3times(self): try: self.secretmgmt_base_obj.set_password(self.master, self.password) shell = RemoteMachineShellConnection(self.master) shell.execute_command("/opt/couchbase/etc/couchbase_init.d stop") self.secretmgmt_base_obj.start_server_prompt_diff_window(self.master) self.sleep(10) cmd = "/opt/couchbase/bin/couchbase-cli master-password -c localhost:8091 -u Administrator -p password --send-password" # self.secretmgmt_base_obj.incorrect_password(self.master,cmd="/opt/couchbase/bin/cbmaster_password") temp_result = self.secretmgmt_base_obj.incorrect_password(self.master, cmd=cmd) self.assertTrue(temp_result, "Issue with passing incorrect password 3 times") finally: for server in self.servers: shell = RemoteMachineShellConnection(server) if (RemoteMachineHelper(shell).is_process_running('memcached') is None): print('Process Memcached is not running') # shell.set_environment_variable("CB_MASTER_PASSWORD", self.password) shell.execute_command( "export CB_MASTER_PASSWORD="******"; /opt/couchbase/etc/couchbase_init.d start")
def start_sync_gateway(self, shell, config_filename): self.kill_processes_gateway(shell) self.log.info('=== start_sync_gateway with config file {0}.'.format( config_filename)) output, error = shell.execute_command('cat {0}/tmp/{1}'.format( self.folder_prefix, config_filename)) shell.log_command_output(output, error) type = shell.extract_remote_info().type.lower() if type == 'windows': output, error = shell.execute_command_raw( '{0}/sync_gateway.exe' ' c:/tmp/{1} > {2}/tmp/gateway.log 2>&1 &'.format( self.installed_folder, config_filename, self.folder_prefix)) else: output, error = shell.execute_command_raw( 'nohup /opt/couchbase-sync-gateway/bin/sync_gateway' ' /tmp/{0} >/tmp/gateway.log 2>&1 &'.format(config_filename)) shell.log_command_output(output, error) obj = RemoteMachineHelper(shell).is_process_running('sync_gateway') if obj and obj.pid: self.log.info( 'start_sync_gateway - Sync Gateway is running with pid of {0}'. format(obj.pid)) if not shell.file_exists('{0}/tmp/'.format(self.folder_prefix), 'gateway.log'): self.log.info('start_sync_gateway - Fail to find gateway.log') return False else: return True else: self.log.info('start_sync_gateway - Sync Gateway is NOT running') output, error = shell.execute_command( 'cat {0}/tmp/gateway.log'.format(self.folder_prefix)) shell.log_command_output(output, error) return False