-
Notifications
You must be signed in to change notification settings - Fork 259
fix server session unbound error #4295
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -480,10 +480,10 @@ def get_time(session, time_command, time_filter_re, time_format): | |
| msg += "'%s', output: %s" % (time_command, output) | ||
| raise exceptions.TestError(msg) | ||
| if re.search("PM|AM", guest_time): | ||
| hour = re.findall("\d+ (\d+):", guest_time)[0] | ||
| hour = re.findall(r"\d+ (\d+):", guest_time)[0] | ||
| fix = 12 if re.search("PM", guest_time) else 0 | ||
| hour = str(int(hour) % 12 + fix) | ||
| guest_time = re.sub("\s\d+:", " %s:" % hour, guest_time)[:-3] | ||
| guest_time = re.sub(r"\s\d+:", " %s:" % hour, guest_time)[:-3] | ||
| else: | ||
| guest_time = guest_time[:-3] | ||
| guest_time = time.mktime(time.strptime(guest_time, time_format)) | ||
|
|
@@ -873,7 +873,7 @@ def transfer_data(session, host_cmd, guest_cmd, n_time, timeout, md5_check, acti | |
| else: | ||
| LOG.warning(err) | ||
| else: | ||
| md5_re = "md5_sum = (\w{32})" | ||
| md5_re = r"md5_sum = (\w{32})" | ||
| try: | ||
| md5_guest = re.findall(md5_re, g_output)[0] | ||
| except Exception: | ||
|
|
@@ -893,7 +893,7 @@ def transfer_data(session, host_cmd, guest_cmd, n_time, timeout, md5_check, acti | |
| else: | ||
| LOG.warning(err) | ||
| else: | ||
| md5_re = "md5_sum = (\w{32})" | ||
| md5_re = r"md5_sum = (\w{32})" | ||
| try: | ||
| md5_host = re.findall(md5_re, output)[0] | ||
| except Exception: | ||
|
|
@@ -1504,10 +1504,10 @@ def extract(vm, remote_path, dest_dir): | |
| def get_last_guest_results_index(): | ||
| res_index = 0 | ||
| for subpath in os.listdir(outputdir): | ||
| if re.search("guest_autotest_results\d+", subpath): | ||
| if re.search(r"guest_autotest_results\d+", subpath): | ||
| res_index = max( | ||
| res_index, | ||
| int(re.search("guest_autotest_results(\d+)", subpath).group(1)), | ||
| int(re.search(r"guest_autotest_results(\d+)", subpath).group(1)), | ||
| ) | ||
| return res_index | ||
|
|
||
|
|
@@ -2063,7 +2063,7 @@ def summary_up_result(result_file, ignore, row_head, column_mark): | |
| if len(re.findall(column_mark, eachLine)) != 0 and not head_flag: | ||
| column = 0 | ||
| _, row, eachLine = re.split(row_head, eachLine) | ||
| for i in re.split("\s+", eachLine): | ||
| for i in re.split(r"\s+", eachLine): | ||
| if i: | ||
| result_dict[i] = {} | ||
| column_list[column] = i | ||
|
|
@@ -2080,7 +2080,7 @@ def summary_up_result(result_file, ignore, row_head, column_mark): | |
| row_list.append(row) | ||
| for i in result_dict: | ||
| result_dict[i][row] = [] | ||
| for i in re.split("\s+", eachLine): | ||
| for i in re.split(r"\s+", eachLine): | ||
| if i: | ||
| result_dict[column_list[column]][row].append(i) | ||
| column += 1 | ||
|
|
@@ -2327,6 +2327,7 @@ def __init__( | |
| self.stress_wait_for_timeout = int( | ||
| self.params.get("stress_wait_for_timeout", 60) | ||
| ) | ||
| stress_type = stress_type.split('_')[0] | ||
| self.stress_type = stress_type | ||
| stress_cmds = stress_cmds or stress_type | ||
| self.stress_cmds = self.params.get("stress_cmds_%s" % stress_type, stress_cmds) | ||
|
|
@@ -2401,6 +2402,45 @@ def load_stress_tool(self): | |
| ): | ||
| raise exceptions.TestError("Stress app does not " "running as expected") | ||
|
|
||
| @session_handler | ||
| def load_htxstress_tool(self): | ||
| """ | ||
| load stress tool in guest | ||
| """ | ||
| # install htx strss tool | ||
| remove_old_package = "cd " + self.dst_path + " && rm -rf " + self.base_name | ||
| get_stress = "cd " + self.dst_path + " && wget " + self.download_url | ||
| if "rpm" in self.base_name: | ||
| install_stress = "cd " + self.dst_path + " && rpm -i " + self.base_name | ||
| elif "deb" in self.base_name: | ||
| install_stress = "cd " + self.dst_path + " && dpkg -i " + self.base_name | ||
| else: | ||
| raise exceptions.TestError("Could not install htx stress tool") | ||
| LOG.info("Installing htx rpm/deb in the guest") | ||
| self.cmd(remove_old_package) | ||
| self.cmd(get_stress) | ||
| self.cmd(install_stress) | ||
|
Comment on lines
+2419
to
+2422
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing error handling for critical installation steps. The 🔎 Proposed fix with error handling LOG.info("Installing htx rpm/deb in the guest")
- self.cmd(remove_old_package)
- self.cmd(get_stress)
- self.cmd(install_stress)
+ self.cmd(remove_old_package)
+
+ status, output = self.cmd_status_output(get_stress, timeout=self.stress_shell_timeout)
+ if status != 0:
+ raise exceptions.TestError("Failed to download HTX stress tool: %s" % output)
+
+ status, output = self.cmd_status_output(install_stress, timeout=self.stress_shell_timeout)
+ if status != 0:
+ raise exceptions.TestError("Failed to install HTX stress tool: %s" % output)
|
||
|
|
||
| # start htx stress | ||
| launch_cmds = "nohup %s %s > /dev/null &" % (self.stress_cmds, self.stress_args) | ||
| LOG.info("Launch stress with command: %s", launch_cmds) | ||
| try: | ||
| self.cmd_launch(launch_cmds) | ||
| # The background process sometimes does not return to | ||
| # terminate, if timeout, send a blank line afterward | ||
| except aexpect.ShellTimeoutError: | ||
| self.cmd_launch("") | ||
|
|
||
| # wait for stress to start and then check, if not raise TestError | ||
| if not utils_misc.wait_for( | ||
| self.app_running, | ||
| self.stress_wait_for_timeout, | ||
| first=2.0, | ||
| text="wait for stress app to start", | ||
| step=1.0, | ||
| ): | ||
| raise exceptions.TestError("Stress app does not " "running as expected") | ||
|
|
||
| @session_handler | ||
| def unload_stress(self): | ||
| """ | ||
|
|
@@ -2791,25 +2831,50 @@ def load_stress( | |
| :param download_type: currently support "git" or "file" download | ||
| """ | ||
| fail_info = [] | ||
| # Add stress/iozone tool in vms | ||
| if stress_type in ["stress_in_vms", "iozone_in_vms"]: | ||
| default_stress_type = stress_type | ||
| if stress_type in ["stress_in_vms", "iozone_in_vms", "htxcmdline_in_vms"]: | ||
| for vm in vms: | ||
| try: | ||
| vstress = VMStress( | ||
| vm, | ||
| stress_type.split("_")[0], | ||
| params, | ||
| download_url, | ||
| make_cmds, | ||
| stress_cmds, | ||
| stress_args, | ||
| work_path, | ||
| uninstall_cmds, | ||
| download_type=download_type, | ||
| ) | ||
| vstress.load_stress_tool() | ||
| except StressError as detail: | ||
| fail_info.append("Launch stress in %s failed: %s" % (vm.name, detail)) | ||
| stress_type = params.get("stress_type_%s" % vm.name, default_stress_type) | ||
| if stress_type == "htxcmdline_in_vms": | ||
| # Add htx stress tool in vms | ||
| try: | ||
| vstress = VMStress( | ||
| vm, | ||
| stress_type.split("_")[0], | ||
| params, | ||
| download_url, | ||
| make_cmds, | ||
| stress_cmds, | ||
| stress_args, | ||
| work_path, | ||
| uninstall_cmds, | ||
| download_type=download_type, | ||
| ) | ||
| vstress.load_htxstress_tool() | ||
| except StressError as detail: | ||
| fail_info.append( | ||
| "Launch htxstress in %s failed: %s" % (vm.name, detail) | ||
| ) | ||
| else: | ||
| # Add stress/iozone tool in vms | ||
| try: | ||
| vstress = VMStress( | ||
| vm, | ||
| stress_type.split("_")[0], | ||
| params, | ||
| download_url, | ||
| make_cmds, | ||
| stress_cmds, | ||
| stress_args, | ||
| work_path, | ||
| uninstall_cmds, | ||
| download_type=download_type, | ||
| ) | ||
| vstress.load_stress_tool() | ||
| except StressError as detail: | ||
| fail_info.append( | ||
| "Launch stress in %s failed: %s" % (vm.name, detail) | ||
| ) | ||
| # Add stress for host | ||
| elif stress_type == "stress_on_host" or stress_type == "stress_on_remote_host": | ||
| try: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pipeline failure: Black formatting required.
The pre-commit hook indicates this file needs reformatting. The single quotes here may need to be double quotes for consistency with the codebase style.
📝 Committable suggestion
🤖 Prompt for AI Agents