Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression testing bugs #324

Merged
merged 8 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion diag_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def _do_command(self, obdiag):
class ObdiagAnalyzeSQLReviewCommand(ObdiagOriginCommand):

def __init__(self):
super(ObdiagAnalyzeSQLReviewCommand, self).__init__('sql_review', 'Analyze oceanbase sql from sql_audit ')
super(ObdiagAnalyzeSQLReviewCommand, self).__init__('sql_review', 'Analyze oceanbase sql from file')
self.parser.add_option('--host', type='string', help="tenant connection host")
self.parser.add_option('--port', type='string', help="tenant connection port")
self.parser.add_option('--password', type='string', help="tenant connection user password", default='')
Expand Down
3 changes: 2 additions & 1 deletion handler/analyzer/analyze_flt_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def check_filename(filename):
log_full_path = "{gather_path}/{log_name}".format(log_name=self.flt_trace_id, gather_path=gather_path)
download_file(ssh_client, log_full_path, local_store_path, self.stdio)

def __get_offline_log_file(self, ssh_client, log_full_path, local_store_dir):
def __get_offline_log_file(self, ssh_client, log_path, local_store_dir):
"""
:param ssh_client, log_name
:return:
Expand All @@ -202,6 +202,7 @@ def __get_offline_log_file(self, ssh_client, log_full_path, local_store_dir):
if self.flt_trace_id is not None and (len(log_name_list) > 0):
grep_cmd = "grep -e '{grep_args}' {log_file} > {local_store_path} ".format(grep_args=self.flt_trace_id, log_file=' '.join(log_name_list), local_store_path=local_store_path)
LocalClient(self.stdio).run(grep_cmd)
log_full_path = "{gather_path}/{log_name}".format(gather_path=log_path, log_name=self.flt_trace_id)
download_file(ssh_client, log_full_path, local_store_path, self.stdio)

def __get_log_name_list_offline(self):
Expand Down
2 changes: 1 addition & 1 deletion handler/analyzer/analyze_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def init_option(self):
self.stdio.print('analyze log from_time: {0}, to_time: {1}'.format(self.from_time_str, self.to_time_str))
if store_dir_option is not None:
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('Error: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.gather_pack_dir = os.path.abspath(store_dir_option)
if grep_option is not None:
Expand Down
8 changes: 4 additions & 4 deletions handler/analyzer/analyze_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def get_version(self):
try:
observer_version = get_observer_version_by_sql(self.ob_cluster, self.stdio)
except Exception as e:
self.stdio.warn("AnalyzeHandler Failed to get observer version:{0}".format(e))
self.stdio.verbose("AnalyzeHandler.init get observer version: {0}".format(observer_version))
self.stdio.warn("failed to get observer version:{0}".format(e))
self.stdio.verbose("get observer version: {0}".format(observer_version))
return observer_version

def handle(self):
Expand All @@ -82,7 +82,7 @@ def init_option_non_default(self):
offline_file_option = Util.get_option(options, 'file')
if store_dir_option and store_dir_option != "./":
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.export_report_path = os.path.abspath(store_dir_option)
else:
Expand All @@ -105,7 +105,7 @@ def init_option_diff(self):
offline_file_option = Util.get_option(options, 'file')
if store_dir_option and store_dir_option != "./":
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.export_report_path = os.path.abspath(store_dir_option)
else:
Expand Down
2 changes: 1 addition & 1 deletion handler/analyzer/analyze_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def init_option(self):
store_dir_option = Util.get_option(options, 'store_dir')
if store_dir_option is not None:
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('Error: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.local_stored_parrent_path = os.path.abspath(store_dir_option)
output_option = Util.get_option(options, 'output')
Expand Down
2 changes: 1 addition & 1 deletion handler/analyzer/analyze_sql_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def init_option(self):
store_dir_option = Util.get_option(options, 'store_dir')
if store_dir_option is not None:
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('Error: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.local_stored_parrent_path = os.path.abspath(store_dir_option)
output_option = Util.get_option(options, 'output')
Expand Down
6 changes: 3 additions & 3 deletions handler/analyzer/analyze_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def __init__(self, context):
database="oceanbase",
)
except Exception as e:
self.stdio.error("Failed to connect to database: {0}".format(e))
raise OBDIAGFormatException("Failed to connect to database: {0}".format(e))
self.stdio.error("failed to connect to database: {0}".format(e))
raise OBDIAGFormatException("failed to connect to database: {0}".format(e))

def handle(self):
if not self.init_option():
Expand All @@ -75,7 +75,7 @@ def init_option(self):

if store_dir_option and store_dir_option != "./":
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.export_report_path = os.path.abspath(store_dir_option)
else:
Expand Down
2 changes: 1 addition & 1 deletion handler/gather/gather_ash_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def init_option(self):
self.stdio.print('gather from_time: {0}, to_time: {1}'.format(self.from_time_str, self.to_time_str))
if store_dir_option:
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.gather_pack_dir = os.path.abspath(store_dir_option)
if sql_id_option:
Expand Down
2 changes: 1 addition & 1 deletion handler/gather/gather_awr.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def init_option(self):
self.stdio.print('gather log from_time: {0}, to_time: {1}'.format(self.from_time_str, self.to_time_str))
if store_dir_option and store_dir_option != "./":
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.gather_pack_dir = os.path.abspath(store_dir_option)
return True
Expand Down
2 changes: 1 addition & 1 deletion handler/gather/gather_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def init_option(self):
self.stdio.print('gather log from_time: {0}, to_time: {1}'.format(self.from_time_str, self.to_time_str))
if store_dir_option is not None and store_dir_option != './':
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.gather_pack_dir = os.path.abspath(store_dir_option)
if scope_option:
Expand Down
2 changes: 1 addition & 1 deletion handler/gather/gather_obadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def init_option(self):
self.stdio.print('gather from_time: {0}, to_time: {1}'.format(self.from_time_str, self.to_time_str))
if store_dir_option and store_dir_option != './':
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('Error: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.local_stored_path = os.path.abspath(store_dir_option)
if encrypt_option == "true":
Expand Down
2 changes: 1 addition & 1 deletion handler/gather/gather_obproxy_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def init_option(self):
self.stdio.print('gather from_time: {0}, to_time: {1}'.format(self.from_time_str, self.to_time_str))
if store_dir_option and store_dir_option != './':
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.gather_pack_dir = os.path.abspath(store_dir_option)
if scope_option:
Expand Down
3 changes: 1 addition & 2 deletions handler/gather/gather_obstack2.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def init_option(self):
store_dir_option = Util.get_option(options, 'store_dir')
if store_dir_option and store_dir_option != './':
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.local_stored_path = os.path.abspath(store_dir_option)
return True
Expand Down Expand Up @@ -224,7 +224,6 @@ def __gather_obstack2_info(self, ssh_client, user, observer_pid, remote_gather_d
ssh_client.exec_cmd(chown_cmd)
self.stdio.verbose("gather obstack info on server {0}, run cmd = [su {1}, {2}]".format(ssh_client.get_name(), user, cmd))
ssh_client.ssh_invoke_shell_switch_user(user, cmd, 10)
ssh_client.exec_cmd("rm -rf /tmp/{0}".format(remote_gather_dir))

@staticmethod
def __get_overall_summary(node_summary_tuple):
Expand Down
16 changes: 8 additions & 8 deletions handler/gather/gather_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def __init__(self, context, gather_pack_dir='./'):
database="oceanbase",
)
except Exception as e:
self.stdio.error("Failed to connect to database: {0}".format(e))
raise OBDIAGFormatException("Failed to connect to database: {0}".format(e))
self.stdio.error("failed to connect to database: {0}".format(e))
raise OBDIAGFormatException("failed to connect to database: {0}".format(e))

def handle(self):
if not self.init_option():
Expand All @@ -66,7 +66,7 @@ def init_option(self):
store_dir_option = Util.get_option(options, 'store_dir')
if store_dir_option and store_dir_option != "./":
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.gather_pack_dir = os.path.abspath(store_dir_option)
return True
Expand All @@ -76,8 +76,8 @@ def get_version(self):
try:
observer_version = get_observer_version_by_sql(self.ob_cluster, self.stdio)
except Exception as e:
self.stdio.warn("GatherHandler Failed to get observer version:{0}".format(e))
self.stdio.verbose("GatherHandler.init get observer version: {0}".format(observer_version))
self.stdio.warn("failed to get observer version:{0}".format(e))
self.stdio.verbose("get observer version: {0}".format(observer_version))
return observer_version

def get_cluster_name(self):
Expand All @@ -87,8 +87,8 @@ def get_cluster_name(self):
cluster_info = self.obconn.execute_sql(sql)
cluster_name = cluster_info[0][0]
except Exception as e:
self.stdio.warn("RCAHandler Failed to get oceanbase cluster name:{0}".format(e))
self.stdio.verbose("RCAHandler.init get oceanbase cluster name {0}".format(cluster_name))
self.stdio.warn("failed to get oceanbase cluster name:{0}".format(e))
self.stdio.verbose("get oceanbase cluster name {0}".format(cluster_name))
return cluster_name

def get_parameters_info(self):
Expand Down Expand Up @@ -121,7 +121,7 @@ def get_parameters_info(self):
writer.writerow(row)
self.stdio.print("Gather parameters finished. For more details, please run cmd '" + Fore.YELLOW + "cat {0}".format(self.parameter_file_name) + Style.RESET_ALL + "'")
else:
self.stdio.warn("Failed to retrieve the database version. Please check if the database connection is normal.")
self.stdio.warn("failed to retrieve the database version. Please check if the database connection is normal.")

def execute(self):
try:
Expand Down
11 changes: 6 additions & 5 deletions handler/gather/gather_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import tabulate

from common.command import get_observer_pid, mkdir, zip_dir, get_file_size, download_file, delete_file_force
from common.command import LocalClient, SshClient
from common.command import SshClient
from common.constant import const
from handler.base_shell_handler import BaseShellHandler
from common.tool import Util
Expand Down Expand Up @@ -70,7 +70,7 @@ def init_option(self):
store_dir_option = Util.get_option(options, 'store_dir')
if store_dir_option and store_dir_option != './':
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.local_stored_path = os.path.abspath(store_dir_option)
self.scope_option = Util.get_option(options, 'scope')
Expand Down Expand Up @@ -118,9 +118,6 @@ def __handle_from_node(self, node, local_stored_path):
resp = {"skip": False, "error": "", "gather_pack_path": ""}
remote_ip = node.get("ip") if self.is_ssh else NetUtils.get_inner_ip(self.stdio)
remote_user = node.get("ssh_username")
remote_password = node.get("ssh_password")
remote_port = node.get("ssh_port")
remote_private_key = node.get("ssh_key_file")
self.stdio.verbose("Sending Collect Shell Command to node {0} ...".format(remote_ip))
DirectoryUtil.mkdir(path=local_stored_path, stdio=self.stdio)
now_time = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
Expand Down Expand Up @@ -167,24 +164,28 @@ def __handle_from_node(self, node, local_stored_path):

def __gather_perf_sample(self, ssh_client, gather_path, pid_observer):
try:
self.stdio.start_loading('gather perf sample')
cmd = "cd {gather_path} && perf record -o sample.data -e cycles -c 100000000 -p {pid} -g -- sleep 20".format(gather_path=gather_path, pid=pid_observer)
self.stdio.verbose("gather perf sample, run cmd = [{0}]".format(cmd))
ssh_client.exec_cmd(cmd)
generate_data = "cd {gather_path} && perf script -i sample.data -F ip,sym -f > sample.viz".format(gather_path=gather_path)
self.stdio.verbose("generate perf sample data, run cmd = [{0}]".format(generate_data))
ssh_client.exec_cmd(generate_data)
self.stdio.stop_loading('gather perf sample')
except:
self.stdio.error("generate perf sample data on server [{0}] failed".format(ssh_client.get_name()))

def __gather_perf_flame(self, ssh_client, gather_path, pid_observer):
try:
self.stdio.start_loading('gather perf flame')
perf_cmd = "cd {gather_path} && perf record -o flame.data -F 99 -p {pid} -g -- sleep 20".format(gather_path=gather_path, pid=pid_observer)
self.stdio.verbose("gather perf, run cmd = [{0}]".format(perf_cmd))
ssh_client.exec_cmd(perf_cmd)

generate_data = "cd {gather_path} && perf script -i flame.data > flame.viz".format(gather_path=gather_path)
self.stdio.verbose("generate perf data, run cmd = [{0}]".format(generate_data))
ssh_client.exec_cmd(generate_data)
self.stdio.stop_loading('gather perf flame')
except:
self.stdio.error("generate perf data on server [{0}] failed".format(ssh_client.get_name()))

Expand Down
2 changes: 1 addition & 1 deletion handler/gather/gather_plan_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def get_table_info(self, file_path):
data = f.read()
return data
except Exception as e:
self.stdio.error(e)
self.stdio.warn(e)
return None

def report_schema(self, sql, tenant_name):
Expand Down
2 changes: 1 addition & 1 deletion handler/gather/gather_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def init_option(self):
self.stdio.print('gather from_time: {0}, to_time: {1}'.format(self.from_time_str, self.to_time_str))
if store_dir_option:
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.gather_pack_dir = os.path.abspath(store_dir_option)
if scene_option:
Expand Down
2 changes: 1 addition & 1 deletion handler/gather/gather_sysstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def init_option(self):
store_dir_option = Util.get_option(options, 'store_dir')
if store_dir_option and store_dir_option != './':
if not os.path.exists(os.path.abspath(store_dir_option)):
self.stdio.warn('warn: args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
self.stdio.warn('args --store_dir [{0}] incorrect: No such directory, Now create it'.format(os.path.abspath(store_dir_option)))
os.makedirs(os.path.abspath(store_dir_option))
self.local_stored_path = os.path.abspath(store_dir_option)
self.scope_option = Util.get_option(options, 'scope')
Expand Down
Loading
Loading