diff --git a/run_l2.sh b/run_l2.sh index 6ddf7d8ec..b29d2f956 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -72,6 +72,8 @@ pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_s pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_start_control.json test/functional-tests/tests/test_rrd_start_control.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_start_subscribe_and_wait.json test/functional-tests/tests/test_rrd_start_subscribe_and_wait.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_static_profile_report.json test/functional-tests/tests/test_rrd_static_profile_report.py +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_static_profile_report_with_suffix.json test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_static_profile_report_with_suffix_negative.json test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_corrupted_static_profile_report.json test/functional-tests/tests/test_rrd_corrupted_static_profile_report.py cp remote_debugger.json /etc/rrd/ pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_harmfull_static_profile_report.json test/functional-tests/tests/test_rrd_harmful_command_static_report.py @@ -86,3 +88,5 @@ pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_c_ cp remote_debugger.json /etc/rrd/ pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_profile_data.json test/functional-tests/tests/test_rrd_profile_data.py + + diff --git a/test/functional-tests/features/test_rrd_static_profile_report_with_suffix.feature b/test/functional-tests/features/test_rrd_static_profile_report_with_suffix.feature new file mode 100644 index 000000000..ec8b88e15 --- /dev/null +++ b/test/functional-tests/features/test_rrd_static_profile_report_with_suffix.feature @@ -0,0 +1,48 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2018 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +Feature: Remote Debugger Static Profile Report With Suffix + + Scenario: Verify remote debugger process is running + Given the remote debugger process is not running + When I start the remote debugger process + Then the remote debugger process should be running + + Scenario: Send RFC event with valid suffixed issue type + Given the remote debugger is running + When I trigger the event "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" with value "Device.Info_ab1bghjh" + Then the event for RRD_SET_ISSUE_EVENT should be received + And the logs should contain "SUCCESS: Message sending Done" + And the logs should be seen with "SUCCESS: Message Reception Done" + And the remotedebugger request payload should include "MSG=Device.Info_ab1bghjh" + + Scenario: Validate static-profile command execution and upload flow for suffixed issue type + Given the remotedebugger received the suffixed issue type + When remotedebugger parses "/etc/rrd/remote_debugger.json" + Then remotedebugger should execute debug commands for static profile issue "Device.Info" + And the timestamped runtime service should start successfully + And the timestamped runtime journalctl collection should succeed + And the timestamped runtime service should stop successfully + And remotedebugger should generate upload archive filename for the suffixed issue type + And remotedebugger should invoke upload with the generated archive + + Scenario: Verify upload result for suffixed issue type report + When I check the upload status in the logs + Then the upload script execution should be successful + And the debug information report upload should be successful diff --git a/test/functional-tests/features/test_rrd_static_profile_report_with_suffix_negative_case.feature b/test/functional-tests/features/test_rrd_static_profile_report_with_suffix_negative_case.feature new file mode 100644 index 000000000..b8b36d2fd --- /dev/null +++ b/test/functional-tests/features/test_rrd_static_profile_report_with_suffix_negative_case.feature @@ -0,0 +1,49 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2018 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +Feature: Remote Debugger Static Profile Report With Overlength Suffix + + Scenario: Verify remote debugger process is running + Given the remote debugger process is not running + When I start the remote debugger process + Then the remote debugger process should be running + + Scenario: Send RFC event with overlength suffixed issue type + Given the remote debugger is running + When I trigger the event "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" with value "Device.Info_ab1bghjhfhk" + Then the event for RRD_SET_ISSUE_EVENT should be received + And the logs should contain "SUCCESS: Message sending Done" + And the logs should be seen with "SUCCESS: Message Reception Done" + And the remotedebugger request payload should include "MSG=Device.Info_ab1bghjhfhk" + + Scenario: Validate suffix discard and upload flow for overlength suffix + Given the remotedebugger received the overlength suffixed issue type + When remotedebugger parses "/etc/rrd/remote_debugger.json" + Then remotedebugger should execute debug commands for static profile issue "Device.Info" + And remotedebugger should log suffix-length discard with configured max length + And the timestamped runtime service should start successfully + And the timestamped runtime journalctl collection should succeed + And the timestamped runtime service should stop successfully + And remotedebugger should generate archive filename with discarded suffix + And remotedebugger should invoke upload with the generated archive + + Scenario: Verify upload result for overlength suffix report + When I check the upload status in the logs + Then the upload script execution should be successful + And the debug information report upload should be successful diff --git a/test/functional-tests/tests/helper_functions.py b/test/functional-tests/tests/helper_functions.py index 33ddd3e02..a6157e0f9 100644 --- a/test/functional-tests/tests/helper_functions.py +++ b/test/functional-tests/tests/helper_functions.py @@ -73,6 +73,21 @@ def grep_rrdlogs(search: str): print(f"Could not read file {LOG_FILE}: {e}") return search_result +def check_service_start_success(issue_type: str): + """Check that service-start logs include a success marker. + + Args: + issue_type: Issue type used in the runtime service name. + + Raises: + AssertionError: If matching service-start logs are missing or do not + include the "service success..." message. + """ + service_start = f"Starting remote_debugger_{issue_type}" + start_logs = grep_rrdlogs(service_start) + assert service_start in start_logs, f"Service start message not found for issue type '{issue_type}'" + assert "service success..." in start_logs, f"Service success marker not found for issue type '{issue_type}'" + def check_file_exists(file_path): return os.path.isfile(file_path) diff --git a/test/functional-tests/tests/test_rrd_background_cmd_static_profile_report.py b/test/functional-tests/tests/test_rrd_background_cmd_static_profile_report.py index 622128519..662ed66ab 100644 --- a/test/functional-tests/tests/test_rrd_background_cmd_static_profile_report.py +++ b/test/functional-tests/tests/test_rrd_background_cmd_static_profile_report.py @@ -108,17 +108,16 @@ def test_remote_debugger_trigger_event(): DEBUG_FILE = "Adding Details of Debug commands to Output File" assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) - SERVICE_START = f"Starting remote_debugger_{BACKGROUND_STRING} service success" - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success(BACKGROUND_STRING) - JOURNAL_START = f"journalctl remote_debugger_{BACKGROUND_STRING} service success" + JOURNAL_START = f"journalctl remote_debugger_{BACKGROUND_STRING}" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_{BACKGROUND_STRING} service" + SERVICE_STOP = f"Stopping remote_debugger_{BACKGROUND_STRING}" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) result = check_output_dir() diff --git a/test/functional-tests/tests/test_rrd_c_api_upload.py b/test/functional-tests/tests/test_rrd_c_api_upload.py index dc7f895dc..da72812d5 100644 --- a/test/functional-tests/tests/test_rrd_c_api_upload.py +++ b/test/functional-tests/tests/test_rrd_c_api_upload.py @@ -93,17 +93,16 @@ def test_remote_debugger_trigger_event(): DEBUG_FILE = "Adding Details of Debug commands to Output File" assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) - SERVICE_START = f"Starting remote_debugger_{ISSUE_STRING} service success" - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success(ISSUE_STRING) - JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING} service success" + JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING}" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING} service" + SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING}" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) result = check_output_dir() diff --git a/test/functional-tests/tests/test_rrd_debug_report_upload.py b/test/functional-tests/tests/test_rrd_debug_report_upload.py index f6d798c36..51c83085c 100644 --- a/test/functional-tests/tests/test_rrd_debug_report_upload.py +++ b/test/functional-tests/tests/test_rrd_debug_report_upload.py @@ -126,17 +126,16 @@ def test_remote_debugger_trigger_event(): DEBUG_FILE = "Adding Details of Debug commands to Output File" assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) - SERVICE_START = f"Starting remote_debugger_{ISSUE_STRING} service success" - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success(ISSUE_STRING) - JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING} service success" + JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING}" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING} service" + SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING}" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) result = check_output_dir() diff --git a/test/functional-tests/tests/test_rrd_deepsleep_static_report.py b/test/functional-tests/tests/test_rrd_deepsleep_static_report.py index af006e23b..a82fb3fa5 100644 --- a/test/functional-tests/tests/test_rrd_deepsleep_static_report.py +++ b/test/functional-tests/tests/test_rrd_deepsleep_static_report.py @@ -98,17 +98,16 @@ def test_remote_debugger_trigger_event(): assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) issue_string = "DEEPSLEEP" - SERVICE_START = f"Starting remote_debugger_Audio.Audio service success..." - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success("Audio.Audio") - JOURNAL_START = "journalctl remote_debugger_Audio.Audio service success..." + JOURNAL_START = "journalctl remote_debugger_Audio.Audio" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_Audio.Audio service..." + SERVICE_STOP = f"Stopping remote_debugger_Audio.Audio" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) SANITY_CHECK = "Found valid Commands" @@ -117,17 +116,16 @@ def test_remote_debugger_trigger_event(): DEBUG_FILE = "Adding Details of Debug commands to Output File" assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) - SERVICE_START = f"Starting remote_debugger_Video.Video service success" - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success("Video.Video") - JOURNAL_START = f"journalctl remote_debugger_Video.Video service success" + JOURNAL_START = f"journalctl remote_debugger_Video.Video" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_Video.Video service" + SERVICE_STOP = f"Stopping remote_debugger_Video.Video" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) result = check_output_dir() diff --git a/test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py b/test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py index 5d8379204..aa3f3d296 100644 --- a/test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py +++ b/test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py @@ -21,6 +21,9 @@ import subprocess from helper_functions import * +MAX_START_PID_RETRIES = 5 +START_PID_RETRY_INTERVAL_SECONDS = 1 + def test_check_remote_debugger_config_file(): config_file_path = JSON_FILE assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." @@ -32,12 +35,18 @@ def test_check_rrd_directory_exists(): def test_check_and_start_remotedebugger(): kill_rrd() remove_logfile() + remove_upload_lock() print("Starting remotedebugger process") command_to_start = "nohup /usr/local/bin/remotedebugger > /dev/null 2>&1 &" run_shell_silent(command_to_start) command_to_get_pid = "pidof remotedebugger" - pid = run_shell_command(command_to_get_pid) - assert pid != "", "remotedebugger process did not start" + pid = None + for _ in range(MAX_START_PID_RETRIES): + pid = run_shell_command(command_to_get_pid) + if pid: + break + sleep(START_PID_RETRY_INTERVAL_SECONDS) + assert pid, "remotedebugger process did not start" def reset_issuetype_rfc(): command = 'rbuscli set Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType string ""' diff --git a/test/functional-tests/tests/test_rrd_dynamic_profile_report.py b/test/functional-tests/tests/test_rrd_dynamic_profile_report.py index 7cd806795..bca831ea9 100644 --- a/test/functional-tests/tests/test_rrd_dynamic_profile_report.py +++ b/test/functional-tests/tests/test_rrd_dynamic_profile_report.py @@ -141,17 +141,16 @@ def test_check_issue_in_dynamic_profile(): assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) testrun1_string = "Test.TestRun1" - SERVICE_START = f"Starting remote_debugger_{testrun1_string} service success" - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success(testrun1_string) - JOURNAL_START = f"journalctl remote_debugger_{testrun1_string} service success" + JOURNAL_START = f"journalctl remote_debugger_{testrun1_string}" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_{testrun1_string} service" + SERVICE_STOP = f"Stopping remote_debugger_{testrun1_string}" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) TESTRUN2_MSG = "Reading Issue Type Test:TestRun2" @@ -164,17 +163,16 @@ def test_check_issue_in_dynamic_profile(): assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) testrun2_string = "Test.TestRun2" - SERVICE_START = f"Starting remote_debugger_{testrun2_string} service success" - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success(testrun2_string) - JOURNAL_START = f"journalctl remote_debugger_{testrun2_string} service success" + JOURNAL_START = f"journalctl remote_debugger_{testrun2_string}" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_{testrun2_string} service" + SERVICE_STOP = f"Stopping remote_debugger_{testrun2_string}" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) result = check_output_dir() diff --git a/test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py b/test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py index efec81641..389f51391 100644 --- a/test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py +++ b/test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py @@ -129,16 +129,15 @@ def test_check_issue_in_dynamic_profile(): EXEC_COMMANDS = 'Executing Debug Commands: ""cat /version.txt;uptime;cat /proc/buddyinfo;cat /proc/meminfo;cat /tmp/.deviceDetails.cache""' assert EXEC_COMMANDS in grep_rrdlogs(EXEC_COMMANDS) - START_SERVICE = "Starting remote_debugger_Test.TestRun1 service success..." - assert START_SERVICE in grep_rrdlogs(START_SERVICE) + check_service_start_success("Test.TestRun1") USE_JOURNALCTL = "Using journalctl to log command output..." assert USE_JOURNALCTL in grep_rrdlogs(USE_JOURNALCTL) - JOURNALCTL_SUCCESS = "journalctl remote_debugger_Test.TestRun1 service success..." + JOURNALCTL_SUCCESS = "journalctl remote_debugger_Test.TestRun1" assert JOURNALCTL_SUCCESS in grep_rrdlogs(JOURNALCTL_SUCCESS) - STOP_SERVICE = "Stopping remote_debugger_Test.TestRun1 service..." + STOP_SERVICE = "Stopping remote_debugger_Test.TestRun1" assert STOP_SERVICE in grep_rrdlogs(STOP_SERVICE) UPLOAD_START = "Starting Upload Debug output via API..." diff --git a/test/functional-tests/tests/test_rrd_static_profile_category_report.py b/test/functional-tests/tests/test_rrd_static_profile_category_report.py index 827c8770b..b0fa8abd5 100644 --- a/test/functional-tests/tests/test_rrd_static_profile_category_report.py +++ b/test/functional-tests/tests/test_rrd_static_profile_category_report.py @@ -97,17 +97,16 @@ def test_remote_debugger_trigger_event(): assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) issue_string = "Device.Info" - SERVICE_START = f"Starting remote_debugger_{issue_string} service success" - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success(issue_string) - JOURNAL_START = f"journalctl remote_debugger_{issue_string} service success" + JOURNAL_START = f"journalctl remote_debugger_{issue_string}" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_{issue_string} service" + SERVICE_STOP = f"Stopping remote_debugger_{issue_string}" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) SANITY_CHECK = "Found valid Commands" @@ -117,17 +116,16 @@ def test_remote_debugger_trigger_event(): assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) issue_string = "Device.Uptime" - SERVICE_START = f"Starting remote_debugger_{issue_string} service success" - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success(issue_string) - JOURNAL_START = f"journalctl remote_debugger_{issue_string} service success" + JOURNAL_START = f"journalctl remote_debugger_{issue_string}" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_{issue_string} service" + SERVICE_STOP = f"Stopping remote_debugger_{issue_string}" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) result = check_output_dir() diff --git a/test/functional-tests/tests/test_rrd_static_profile_report.py b/test/functional-tests/tests/test_rrd_static_profile_report.py index b6309a52e..66f336d54 100644 --- a/test/functional-tests/tests/test_rrd_static_profile_report.py +++ b/test/functional-tests/tests/test_rrd_static_profile_report.py @@ -93,17 +93,16 @@ def test_remote_debugger_trigger_event(): DEBUG_FILE = "Adding Details of Debug commands to Output File" assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) - SERVICE_START = f"Starting remote_debugger_{ISSUE_STRING} service success" - assert SERVICE_START in grep_rrdlogs(SERVICE_START) + check_service_start_success(ISSUE_STRING) - JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING} service success" + JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING}" assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) SLEEP_TIME = "Sleeping with timeout" assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) sleep(20) - SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING} service" + SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING}" assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) result = check_output_dir() diff --git a/test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py b/test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py new file mode 100644 index 000000000..ab9887eff --- /dev/null +++ b/test/functional-tests/tests/test_rrd_static_profile_report_with_suffix.py @@ -0,0 +1,140 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2018 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +from helper_functions import * + +def test_check_remote_debugger_config_file(): + config_file_path = JSON_FILE + assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." + +def test_check_rrd_directory_exists(): + dir_path = OUTPUT_DIR + assert check_directory_exists(dir_path), f"Directory '{dir_path}' does not exist." + +def reset_issuetype_rfc(): + command = 'rbuscli set Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType string ""' + result = subprocess.run(command, shell=True, capture_output=True, text=True) + assert result.returncode == 0 + +def test_check_and_start_remotedebugger(): + kill_rrd() + remove_logfile() + print("Starting remotedebugger process") + command_to_start = "nohup /usr/local/bin/remotedebugger > /dev/null 2>&1 &" + run_shell_silent(command_to_start) + command_to_get_pid = "pidof remotedebugger" + pid = run_shell_command(command_to_get_pid) + assert pid != "", "remotedebugger process did not start" + +def test_remote_debugger_trigger_event(): + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', 'Device.Info_ab1bghjh' + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + sleep(15) + + QUERY_MSG = "Received event for RRD_SET_ISSUE_EVENT" + assert QUERY_MSG in grep_rrdlogs(QUERY_MSG) + + MSG_SEND = "SUCCESS: Message sending Done" + sleep(2) + assert MSG_SEND in grep_rrdlogs(MSG_SEND) + + MSG_RECEIVE = "SUCCESS: Message Reception Done" + sleep(2) + assert MSG_RECEIVE in grep_rrdlogs(MSG_RECEIVE) + + ISSUE_MSG = f'MSG={ISSUE_STRING}' + assert ISSUE_MSG in grep_rrdlogs(ISSUE_MSG) + print("Sent and received messages are found and match in the logfile") + + READ_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READ_JSON in grep_rrdlogs(READ_JSON) + + PARSE_JSON = "Json File parse Success... /etc/rrd/remote_debugger.json" + assert PARSE_JSON in grep_rrdlogs(PARSE_JSON) + + if '.' in ISSUE_STRING: + ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.') + else: + node = ISSUE_STRING + subnode = None + + ISSUE_FOUND = f"Issue Data Node: {ISSUE_NODE} and Sub-Node: {ISSUE_SUBNODE} found in Static JSON File /etc/rrd/remote_debugger.json" + + DIR_CREATION = "Creating Directory" + assert DIR_CREATION in grep_rrdlogs(DIR_CREATION) + + SANITY_CHECK = "Found valid Commands" + assert SANITY_CHECK in grep_rrdlogs(SANITY_CHECK) + + DEBUG_FILE = "Adding Details of Debug commands to Output File" + assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) + + check_service_start_success(ISSUE_STRING) + + JOURNAL_START = f"journalctl remote_debugger_{ISSUE_STRING}" + assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) + + SLEEP_TIME = "Sleeping with timeout" + assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) + sleep(20) + + SERVICE_STOP = f"Stopping remote_debugger_{ISSUE_STRING}" + assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) + + GENERATE_FILE = f"Generated filename: AABBCCDDEEFF_DEVICE_INFO_AB1BGHJH" + assert GENERATE_FILE in grep_rrdlogs(GENERATE_FILE) + + START_UPLOAD = f"Starting upload - server: mockxconf, protocol: HTTP, file: AABBCCDDEEFF_DEVICE_INFO_AB1BGHJH" + assert START_UPLOAD in grep_rrdlogs(START_UPLOAD) + result = check_output_dir() + print(result) + + UPLOAD_LOGS = "Starting Upload Debug output via API" + assert UPLOAD_LOGS in grep_rrdlogs(UPLOAD_LOGS) + +def test_remotedebugger_upload_report(): + UPLOAD_SUCCESS = "RRD Upload Script Execution Success" + UPLOAD_FAILURE = "RRD Upload Script Execution Failure" + if UPLOAD_SUCCESS in grep_rrdlogs(UPLOAD_SUCCESS): + print("Upload success") + elif UPLOAD_FAILURE in grep_rrdlogs(UPLOAD_FAILURE): + print("Upload failed") + else: + print("Upload status not found in logs") + + SCRIPT_SUCCESS = "Debug Information Report upload Failed" + SCRIPT_FAILURE = "Debug Information Report upload Success" + if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS): + print("Script execution success") + elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE): + print("Script execution failed") + else: + print("Script execution not found in logs") + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() diff --git a/test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py b/test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py new file mode 100644 index 000000000..8366dd4e0 --- /dev/null +++ b/test/functional-tests/tests/test_rrd_static_profile_report_with_suffix_negative_case.py @@ -0,0 +1,144 @@ +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2018 RDK Management +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################## + +from helper_functions import * + +def test_check_remote_debugger_config_file(): + config_file_path = JSON_FILE + assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." + +def test_check_rrd_directory_exists(): + dir_path = OUTPUT_DIR + assert check_directory_exists(dir_path), f"Directory '{dir_path}' does not exist." + +def reset_issuetype_rfc(): + command = 'rbuscli set Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType string ""' + result = subprocess.run(command, shell=True, capture_output=True, text=True) + assert result.returncode == 0 + +def test_check_and_start_remotedebugger(): + kill_rrd() + remove_logfile() + print("Starting remotedebugger process") + command_to_start = "nohup /usr/local/bin/remotedebugger > /dev/null 2>&1 &" + run_shell_silent(command_to_start) + command_to_get_pid = "pidof remotedebugger" + pid = run_shell_command(command_to_get_pid) + assert pid != "", "remotedebugger process did not start" + +def test_remote_debugger_trigger_event(): + reset_issuetype_rfc() + sleep(10) + ISSUE_STRING = "Device.Info_ab1bghjhfhk" + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', ISSUE_STRING + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0, f"Command failed with error: {result.stderr}" + + sleep(15) + + QUERY_MSG = "Received event for RRD_SET_ISSUE_EVENT" + assert QUERY_MSG in grep_rrdlogs(QUERY_MSG) + + MSG_SEND = "SUCCESS: Message sending Done" + sleep(2) + assert MSG_SEND in grep_rrdlogs(MSG_SEND) + + MSG_RECEIVE = "SUCCESS: Message Reception Done" + sleep(2) + assert MSG_RECEIVE in grep_rrdlogs(MSG_RECEIVE) + + ISSUE_MSG = f'MSG={ISSUE_STRING}' + assert ISSUE_MSG in grep_rrdlogs(ISSUE_MSG) + print("Sent and received messages are found and match in the logfile") + + READ_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READ_JSON in grep_rrdlogs(READ_JSON) + + PARSE_JSON = "Json File parse Success... /etc/rrd/remote_debugger.json" + assert PARSE_JSON in grep_rrdlogs(PARSE_JSON) + + if '.' in ISSUE_STRING: + ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.') + else: + node = ISSUE_STRING + subnode = None + + ISSUE_FOUND = f"Issue Data Node: {ISSUE_NODE} and Sub-Node: {ISSUE_SUBNODE} found in Static JSON File /etc/rrd/remote_debugger.json" + + DIR_CREATION = "Creating Directory" + assert DIR_CREATION in grep_rrdlogs(DIR_CREATION) + + SANITY_CHECK = "Found valid Commands" + assert SANITY_CHECK in grep_rrdlogs(SANITY_CHECK) + + DEBUG_FILE = "Adding Details of Debug commands to Output File" + assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) + + check_service_start_success("Device.Info") + + JOURNAL_START = f"journalctl remote_debugger_Device.Info" + assert JOURNAL_START in grep_rrdlogs(JOURNAL_START) + + SLEEP_TIME = "Sleeping with timeout" + assert SLEEP_TIME in grep_rrdlogs(SLEEP_TIME) + sleep(20) + + SERVICE_STOP = f"Stopping remote_debugger_Device.Info" + assert SERVICE_STOP in grep_rrdlogs(SERVICE_STOP) + + SUFFIX_EXCEEDS = f"Suffix after 'Device.Info' exceeds max length (12 > 9); discarding" + assert SUFFIX_EXCEEDS in grep_rrdlogs(SUFFIX_EXCEEDS) + + GENERATE_FILE = f"Generated filename: AABBCCDDEEFF_DEVICE_INFO_" + assert GENERATE_FILE in grep_rrdlogs(GENERATE_FILE) + + START_UPLOAD = f"Starting upload - server: mockxconf, protocol: HTTP, file: AABBCCDDEEFF_DEVICE_INFO_" + assert START_UPLOAD in grep_rrdlogs(START_UPLOAD) + result = check_output_dir() + print(result) + + UPLOAD_LOGS = "Starting Upload Debug output via API" + assert UPLOAD_LOGS in grep_rrdlogs(UPLOAD_LOGS) + +def test_remotedebugger_upload_report(): + UPLOAD_SUCCESS = "RRD Upload Script Execution Success" + UPLOAD_FAILURE = "RRD Upload Script Execution Failure" + if UPLOAD_SUCCESS in grep_rrdlogs(UPLOAD_SUCCESS): + print("Upload success") + elif UPLOAD_FAILURE in grep_rrdlogs(UPLOAD_FAILURE): + print("Upload failed") + else: + print("Upload status not found in logs") + + SCRIPT_SUCCESS = "Debug Information Report upload Success" + SCRIPT_FAILURE = "Debug Information Report upload Failed" + if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS): + print("Script execution success") + elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE): + print("Script execution failed") + else: + print("Script execution not found in logs") + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd()