-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: sssd-be tends to run out of system resources, hitting the maxi…
…mum number of open files sssd-be tends to run out of system resources, hitting the maximum number of open files Reviewed-by: Shridhar Gadekar <[email protected]> Reviewed-by: Sumit Bose <[email protected]>
- Loading branch information
1 parent
2487c99
commit fe99271
Showing
2 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/tests/multihost/sssd/testlib/common/helper_functions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import re | ||
|
||
|
||
def find_logs(multihost, log_name, string_name): | ||
"""This function will find strings in a log file | ||
log_name: Absolute path of log where the search will happen. | ||
string_name: String to search in the log file. | ||
""" | ||
log_str = multihost.client[0].get_file_contents(log_name).decode('utf-8') | ||
assert string_name in log_str | ||
|
||
|
||
def count_pattern_logs(multihost, log_name, string_name): | ||
"""This function will find strings in a log file | ||
log_name: Absolute path of log where the search will happen. | ||
string_name: String to search in the log file. | ||
""" | ||
return len(re.findall(string_name, multihost.client[0].get_file_contents(log_name).decode('utf-8'))) | ||
|
||
|
||
def client_backup_file(multihost, file_path): | ||
"""This function will backup file in client machine | ||
file_path: String, Absolute path of file. | ||
""" | ||
client = multihost.client[0] | ||
file_content = client.get_file_contents(file_path) | ||
client.put_file_contents(file_path+'_bkp', file_content) | ||
|
||
|
||
def client_restore_file(multihost, file_path): | ||
"""This function will restore file in client machine | ||
file_path: String, Absolute path of file. | ||
""" | ||
client = multihost.client[0] | ||
file_content = client.get_file_contents(file_path) | ||
client.put_file_contents(file_path.split("_bkp")[0], file_content) | ||
|
||
|
||
def client_remove_file(multihost, file_path): | ||
"""This function will remove file in client machine | ||
file_path: String, Absolute path of file. | ||
""" | ||
client = multihost.client[0] | ||
client.run_command(f"rm -vf {file_path}") | ||
|
||
|
||
def count_lines(multihost, log_name): | ||
"""This function will count no of lines of a file | ||
file_path: String, Absolute path of file. | ||
""" | ||
return len(multihost.client[0].get_file_contents(log_name).decode('utf-8').split('\n')) - 1 | ||
|
||
|
||
def search_string_in_file(multihost, start_line, search_string, file_path): | ||
"""This function will find strings in a log file | ||
file_path: String, Absolute path of file. | ||
search_string: String, to find in the log. | ||
start_line: int, number of line from where search will start | ||
""" | ||
file = multihost.client[0].get_file_contents(file_path).decode('utf-8').split('\n') | ||
current_line = 1 | ||
finding_list = [] | ||
for line in file: | ||
if current_line >= start_line and search_string in line: | ||
finding_list.append(f"Found '{search_string}' in {file_path} at line {current_line}: {line.strip()}") | ||
current_line += 1 | ||
return finding_list |