diff --git a/configure.ac b/configure.ac index 6a87226c..6987c405 100644 --- a/configure.ac +++ b/configure.ac @@ -61,7 +61,18 @@ AC_TYPE_SIZE_T AC_CONFIG_FILES([Makefile src/Makefile]) - +AC_ARG_ENABLE([L2support], + AS_HELP_STRING([--enable-L2support],[enable L2support (default is no)]), + [ + case "${enableval}" in + yes) L2_SUPPORT_ENABLE=true + L2_SUPPORT_FLAG="-DUSE_L2_SUPPORT" + m4_if(m4_sysval,[0],[SUBDIRS_L2_SUPPORT="src"]) ;; + no) L2_SUPPORT_ENABLE=false AC_MSG_ERROR([L2_SUPPORT is disabled]) ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-L2support]) ;; + esac + ], + [echo "L2support is disabled"]) # IARMBus Support AC_ARG_ENABLE([iarmbusSupport], [ --enable-iarmbusSupport Turn on iarmbus support], diff --git a/cov_build.sh b/cov_build.sh index 0cee692d..68a2b75d 100644 --- a/cov_build.sh +++ b/cov_build.sh @@ -78,6 +78,6 @@ cp libIARM.h /usr/local/include cd $WORKDIR autoreconf -i autoupdate -./configure --prefix=${INSTALL_DIR} --enable-iarmbusSupport=yes -make remotedebugger_CFLAGS="-I/usr/include/cjson -I/usr/local/include/wdmp-c -I/usr/local/include/rbus -I/usr/local/include -I/usr/local/include/trower-base64 -DIARMBUS_SUPPORT" remotedebugger_LDFLAGS="-L/usr/local/lib -lrdkloggers -lcjson -lrfcapi -lrbus -lmsgpackc -lsecure_wrapper -lwebconfig_framework -lIARMBus -ltr181api -L/usr/local/lib/x86_64-linux-gnu -ltrower-base64 -L/usr/lib/x86_64-linux-gnu" +./configure --prefix=${INSTALL_DIR} --enable-iarmbusSupport=yes --enable-L2support=yes +make remotedebugger_CFLAGS="-I/usr/include/cjson -I/usr/local/include/wdmp-c -I/usr/local/include/rbus -I/usr/local/include -I/usr/local/include/trower-base64 -DIARMBUS_SUPPORT -DUSE_L2_SUPPORT" remotedebugger_LDFLAGS="-L/usr/local/lib -lrdkloggers -lcjson -lrfcapi -lrbus -lmsgpackc -lsecure_wrapper -lwebconfig_framework -lIARMBus -ltr181api -L/usr/local/lib/x86_64-linux-gnu -ltrower-base64 -L/usr/lib/x86_64-linux-gnu" make install diff --git a/run_l2.sh b/run_l2.sh index 2da98029..871129ce 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -59,8 +59,11 @@ rm -rf /tmp/rrd/* rm -rf /opt/logs/remotedebugger.log* # Run L2 Test cases +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_neg.json test/functional-tests/tests/test_rrd_negative.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dynamic_profile_missing_report.json test/functional-tests/tests/test_rrd_dynamic_profile_missing_report.py +pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_append.json test/functional-tests/tests/test_append.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dynamic_profile_harmful_report.json test/functional-tests/tests/test_rrd_dynamic_profile_harmful_report.py +cp remote_debugger.json /etc/rrd/ pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_dynamic_profile_report.json test/functional-tests/tests/test_rrd_dynamic_profile_report.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_append_dynamic_profile_static_notfound.json test/functional-tests/tests/test_rrd_append_dynamic_profile_static_notfound.py pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_single_instance.json test/functional-tests/tests/test_rrd_single_instance.py diff --git a/src/rrdInterface.c b/src/rrdInterface.c index e34d0eb7..e203d582 100644 --- a/src/rrdInterface.c +++ b/src/rrdInterface.c @@ -74,16 +74,24 @@ int RRD_subscribe() subscriptions[1].handler = _remoteDebuggerWebCfgDataEventHandler; subscriptions[1].userData = NULL; -#ifndef IARMBUS_SUPPORT - subscriptions[2].eventName = RDM_DOWNLOAD_EVENT; - subscriptions[2].filter = NULL; - subscriptions[2].duration = 0; - subscriptions[2].handler = _rdmDownloadEventHandler; - subscriptions[2].userData = NULL; - - ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 3, 60); +#ifdef IARMBUS_SUPPORT +#ifdef USE_L2_SUPPORT + subscriptions[2].eventName = RDM_DOWNLOAD_EVENT1; + subscriptions[2].filter = NULL; + subscriptions[2].duration = 0; + subscriptions[2].handler = _rdmDownloadEventHandler; + subscriptions[2].userData = NULL; + ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 3, 60); +#else + ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 2, 60); +#endif #else - ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 2, 60); + subscriptions[2].eventName = RDM_DOWNLOAD_EVENT; + subscriptions[2].filter = NULL; + subscriptions[2].duration = 0; + subscriptions[2].handler = _rdmDownloadEventHandler; + subscriptions[2].userData = NULL; + ret = rbusEvent_SubscribeEx(rrdRbusHandle, subscriptions, 3, 60); #endif #endif if(ret != 0) @@ -250,7 +258,11 @@ void _rdmDownloadEventHandler(rbusHandle_t handle, rbusEvent_t const* event, rbu (void)(handle); (void)(subscription); +#ifdef USE_L2_SUPPORT + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Received event for RDM_DOWNLOAD_EVENT %s \n", __FUNCTION__, __LINE__, RDM_DOWNLOAD_EVENT1); +#else RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Received event for RDM_DOWNLOAD_EVENT %s \n", __FUNCTION__, __LINE__, RDM_DOWNLOAD_EVENT); +#endif cache = findPresentInCache(pkg_name); if (cache != NULL) { diff --git a/src/rrdInterface.h b/src/rrdInterface.h index 1fa52609..3639c7a5 100644 --- a/src/rrdInterface.h +++ b/src/rrdInterface.h @@ -42,6 +42,7 @@ extern "C" #define RRD_SET_ISSUE_EVENT "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" #define RRD_WEBCFG_ISSUE_EVENT "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.WebCfgData" #define RDM_DOWNLOAD_EVENT "Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.DownloadStatus" +#define RDM_DOWNLOAD_EVENT1 "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus" #define RRD_PROCESS_NAME "remotedebugger" #define RRD_RBUS_TIMEOUT 60 diff --git a/test/functional-tests/features/rrd_append_report.feature b/test/functional-tests/features/rrd_append_report.feature new file mode 100644 index 00000000..0f690d0c --- /dev/null +++ b/test/functional-tests/features/rrd_append_report.feature @@ -0,0 +1,45 @@ +########################################################################## +# 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 Append Request Missing Issuetype + + 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 WebPA event for Issuetype Test.TestRun4_apnd and verify logs + Given the remote debugger is running + When I trigger the event "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" + Then the logs should contain "SUCCESS: Message sending Done" + Then the logs should be seen with "SUCCESS: Message Reception Done" + And the issuetype request should match between Send and Receive + + Scenario: Verify the Issuetype is found in dynamic profile + Given the remote debugger received the message from RBUS command + When the remotedebugger read the json file form the dynamic path + Then remotedebugger json read and parse should be success in dynamic path + + Scenario: Verify the Issuetype is found in static profile + Given the remote debugger received the message from RBUS command + When the remotedebugger static json profile is present + Then remotedebugger should read the Json file + And remotedebugger logs should contain the Json File Parse Success + And remotedebugger should log as the Issue requested found in the profile + And Update the command after appending data from both the dynamic and static profiles, then execute the commands diff --git a/test/functional-tests/features/rrd_dynamic_profile_missing_report.feature b/test/functional-tests/features/rrd_dynamic_profile_missing_report.feature index 0b8f2667..edbc9475 100644 --- a/test/functional-tests/features/rrd_dynamic_profile_missing_report.feature +++ b/test/functional-tests/features/rrd_dynamic_profile_missing_report.feature @@ -43,3 +43,10 @@ Feature: Remote Debugger Missing Issuetype When the remotedebugger read the json file form the dynamic path Then remotedebugger json read and parse should be failed And remotedebugger should request RDM to download the package + + Scenario: Verify the Issuetype is found in downloaded package + Given downloaded package from RDM successfully + When the remotedebugger read the json file form the downloaded dynamic path + Then remotedebugger json read and parse should be success + And remotedebugger should execute the command + diff --git a/test/functional-tests/tests/create_json.sh b/test/functional-tests/tests/create_json.sh index 3c71b688..436996d8 100644 --- a/test/functional-tests/tests/create_json.sh +++ b/test/functional-tests/tests/create_json.sh @@ -23,17 +23,27 @@ json_file="/media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" echo '{ "Test": { + "TestRun1": { + "Commands": "cat /version.txt;uptime;cat /proc/buddyinfo;cat /proc/meminfo;cat /tmp/.deviceDetails.cache", + "Timeout": 10 + }, + "TestRun5": { + "Commands": "cat /version.txt;uptime;cat /tmp/.deviceDetails.cache", + "Timeout": 10 + }, + "TestRun4": { + "Commands": "cat /version.txt;uptime;cat /tmp/.deviceDetails.cache", + "Timeout": 10 + }, "TestRun3": { "Commands": "cat /version.txt;uptime;rm -rf;cat /tmp/.deviceDetails.cache", "Timeout": 10 - }, + }, "TestRun2": { "Commands": "cat /version.txt;uptime;/proc/version;cat /proc/buddyinfo;cat /proc/meminfo;cat /tmp/.deviceDetails.cache", "Timeout": 10 - }, - "TestRun1": { - "Commands": "cat /version.txt;uptime;cat /proc/buddyinfo;cat /proc/meminfo;cat /tmp/.deviceDetails.cache", - "Timeout": 10 } } }' > $json_file +mkdir -p /tmp/RDK-RRD-Test/etc/rrd/ +cp $json_file /tmp/RDK-RRD-Test/etc/rrd/ diff --git a/test/functional-tests/tests/test_append.py b/test/functional-tests/tests/test_append.py new file mode 100644 index 00000000..72e28e0f --- /dev/null +++ b/test/functional-tests/tests/test_append.py @@ -0,0 +1,134 @@ +import json +from helper_functions import * + +# Path to the existing JSON file +file_path = "/etc/rrd/remote_debugger.json" + +# Read the existing JSON data +with open(file_path, "r") as json_file: + data = json.load(json_file) + +# New entry to add +new_entry = { + "Test": { + "TestRun4": { + "Commands": "cat /version.txt;cat /tmp/.deviceDetails.cache", + "Timeout": 10 + } + } +} + +# Update the JSON data with the new entry +data.update(new_entry) + +# Write the updated data back to the JSON file +with open(file_path, "w") as json_file: + json.dump(data, json_file, indent=4) + +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 test_check_dynamic_config_file(): + config_file_path = APPEND_JSON_FILE + assert check_file_exists(config_file_path), f"Configuration file '{config_file_path}' does not exist." + +def test_check_dynamic_directory_exists(): + dir_path = DYNAMIC_DIR + assert check_directory_exists(dir_path), f"Directory '{dir_path}' does not exist." + +def test_check_and_start_remotedebugger(): + kill_rrd() + remove_logfile() + test_check_dynamic_directory_exists() + test_check_dynamic_config_file() + 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 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_remote_debugger_trigger_event(): + APPEND_STRING1 = "Test.TestRun4_apnd" + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', APPEND_STRING1 + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + 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) + +def test_check_issue_in_dynamic_profile(): + APPEND_MSG = "Received append request to process static and dynamic profiles" + assert APPEND_MSG in grep_rrdlogs(APPEND_MSG) + + DYNAMIC_JSONFILE = "Reading json config file /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert DYNAMIC_JSONFILE in grep_rrdlogs(DYNAMIC_JSONFILE) + + JSON_READ_SUCCESS = "Reading json file Success" + assert JSON_READ_SUCCESS in grep_rrdlogs(JSON_READ_SUCCESS) + + JSON_PARSE_SUCCESS = "Json File parse Success" + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + JSON_SUCCESS = "Dynamic Profile Parse And Read Success... /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert JSON_SUCCESS in grep_rrdlogs(JSON_SUCCESS) + + CHECKING_DYNAMIC_JSON = "Check if Issue in Parsed Dynamic JSON... /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert CHECKING_DYNAMIC_JSON in grep_rrdlogs(CHECKING_DYNAMIC_JSON) + + STATIC_READ = "Reading static profile command info..." + assert STATIC_READ in grep_rrdlogs(STATIC_READ) + + READING_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READING_JSON in grep_rrdlogs(READING_JSON) + + JSON_STATIC_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_STATIC_SUCCESS in grep_rrdlogs(JSON_STATIC_SUCCESS) + + JSON_PARSE_STATIC_SUCCESS = "Json File parse Success... /etc/rrd/remote_debugger.json" + assert JSON_PARSE_STATIC_SUCCESS in grep_rrdlogs(JSON_PARSE_STATIC_SUCCESS) + + SUCCESS_STATIC = "Static Profile Parse And Read Success... /etc/rrd/remote_debugger.json" + assert SUCCESS_STATIC in grep_rrdlogs(SUCCESS_STATIC) + + CHECKING_STATIC_JSON = "Check if Issue in Parsed Static JSON... /etc/rrd/remote_debugger.json" + assert CHECKING_STATIC_JSON in grep_rrdlogs(CHECKING_STATIC_JSON) + + READ_COMPLETE_STATIC = "Read complete for Static Profile: RFCValue: Test.TestRun4, Command: " + assert READ_COMPLETE_STATIC in grep_rrdlogs(READ_COMPLETE_STATIC) + + APPEND_UPDATE = "Updated command after append from dynamic and static profile: " + assert APPEND_UPDATE in grep_rrdlogs(APPEND_UPDATE) + + EXECUTE_SERVICE = "Executing Commands in Runtime Service..." + assert EXECUTE_SERVICE in grep_rrdlogs(EXECUTE_SERVICE) + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() diff --git a/test/functional-tests/tests/test_rrd_dynamic_missing_report.py b/test/functional-tests/tests/test_rrd_dynamic_missing_report.py new file mode 100644 index 00000000..884eb95d --- /dev/null +++ b/test/functional-tests/tests/test_rrd_dynamic_missing_report.py @@ -0,0 +1,173 @@ +########################################################################## +# 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. +########################################################################## + +import json +import subprocess +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 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 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_remote_debugger_trigger_event(): + MISSING_STRING1 = "Test.TestRun5" + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', MISSING_STRING1 + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + 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) + +def test_check_issue_in_static_profile(): + READ_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READ_JSON in grep_rrdlogs(READ_JSON) + + PARSE_JSON = "Static Profile Parse And Read Success" + assert PARSE_JSON in grep_rrdlogs(PARSE_JSON) + + MISSING_MSG = "Issue Data Not found in Static JSON File" + assert MISSING_MSG in grep_rrdlogs(MISSING_MSG) + +def test_check_issue_in_dynamic_profile(): + DYNAMIC_READ = "Checking Dynamic Profile..." + assert DYNAMIC_READ in grep_rrdlogs(DYNAMIC_READ) + + DYNAMIC_JSONFILE = "Reading json config file /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert DYNAMIC_JSONFILE in grep_rrdlogs(DYNAMIC_JSONFILE) + + PARSE_FAILED = "Dynamic Profile Parse/Read failed" + assert PARSE_FAILED in grep_rrdlogs(PARSE_FAILED) + + RDM_MSG = "Request RDM Manager Download for a new Issue Type" + assert RDM_MSG in grep_rrdlogs(RDM_MSG) + + RDM_PACKAGE = "Request RDM Manager Download for... RDK-RRD-Test:1.0" + assert RDM_PACKAGE in grep_rrdlogs(RDM_PACKAGE) + + script_path="./test/functional-tests/tests/create_json.sh" + # Run the shell script + try: + result = subprocess.run(['bash', script_path], check=True, text=True, capture_output=True) + print("Script output:") + print(result.stdout) + except subprocess.CalledProcessError as e: + print("Error while executing the script:") + print(e.stderr) +def test_rdm_trigger_event(): + INSTALL_PACKAGE ="RDK-RRD-Test:1.0" + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.InstallPackage', + 'string', INSTALL_PACKAGE + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 +def test_rdm_rrd_trigger_event(): + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus', + 'bool', 'true' + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + +def test_rdm_rrd_dwnld_status(): + PACKAGE_FOUND = "Package found in Cache...Test.TestRun5" + assert PACKAGE_FOUND in grep_rrdlogs(PACKAGE_FOUND) + + PACKAGE_DETAIL = "Package Details jsonPath: /tmp/RDK-RRD-Test" + assert PACKAGE_DETAIL in grep_rrdlogs(PACKAGE_DETAIL) + + COPY_MSG = "Copying Message Received to the queue.." + assert COPY_MSG in grep_rrdlogs(COPY_MSG) + + SUCCESS_MSG_SEND = "Message sending Done, ID=0 MSG=Test.TestRun5 Size=13 Type=1 AppendMode=0!" + assert SUCCESS_MSG_SEND in grep_rrdlogs(SUCCESS_MSG_SEND) + + SUCCESS_MSG_RECEIVE = "Message Reception Done for ID=0 MSG=Test.TestRun5 TYPE=1..." + assert SUCCESS_MSG_RECEIVE in grep_rrdlogs(SUCCESS_MSG_RECEIVE) + + ISSUE_CMD_INFO = "Getting Issue command Information for : Test.TestRun5" + assert ISSUE_CMD_INFO in grep_rrdlogs(ISSUE_CMD_INFO) + + CHECK_IN_DYNAMIC = "Checking if Issue marked inDynamic..." + assert CHECK_IN_DYNAMIC in grep_rrdlogs(CHECK_IN_DYNAMIC) + + ISSUE_MARKED_DYNAMIC = "Issue Marked as inDynamic..." + assert ISSUE_MARKED_DYNAMIC in grep_rrdlogs(ISSUE_MARKED_DYNAMIC) + + START_JSON_READ = "Start Reading JSON File... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert START_JSON_READ in grep_rrdlogs(START_JSON_READ) + + JSON_READ_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_READ_SUCCESS in grep_rrdlogs(JSON_READ_SUCCESS) + + JSON_PARSE_SUCCESS = "Json File parse Success... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + READ_ISSUE_CATEGORY = "Reading Issue Category:Test..." + assert READ_ISSUE_CATEGORY in grep_rrdlogs(READ_ISSUE_CATEGORY) + + RUN_DEBUG_CMD = "Run Debug Commands for Test:TestRun5" + assert RUN_DEBUG_CMD in grep_rrdlogs(RUN_DEBUG_CMD) + + EXEC_RUNTIME_SERVICE = "Executing Commands in Runtime Service..." + assert EXEC_RUNTIME_SERVICE in grep_rrdlogs(EXEC_RUNTIME_SERVICE) + + START_REMOTE_DEBUGGER = "Starting remote_debugger_Test.TestRun5 service success..." + assert START_REMOTE_DEBUGGER in grep_rrdlogs(START_REMOTE_DEBUGGER) + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() 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 5d837920..151b2b89 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 @@ -45,12 +45,13 @@ def reset_issuetype_rfc(): assert result.returncode == 0 def test_remote_debugger_trigger_event(): + MISSING_STRING1 = "Test.TestRun5" reset_issuetype_rfc() sleep(10) command = [ 'rbuscli', 'set', 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', - 'string', MISSING_STRING + 'string', MISSING_STRING1 ] result = subprocess.run(command, capture_output=True, text=True) assert result.returncode == 0 @@ -95,7 +96,7 @@ def test_check_issue_in_dynamic_profile(): assert RDM_PACKAGE in grep_rrdlogs(RDM_PACKAGE) script_path="./test/functional-tests/tests/create_json.sh" -# Run the shell script + # Run the shell script try: result = subprocess.run(['bash', script_path], check=True, text=True, capture_output=True) print("Script output:") @@ -103,10 +104,7 @@ def test_check_issue_in_dynamic_profile(): except subprocess.CalledProcessError as e: print("Error while executing the script:") print(e.stderr) - remove_logfile() - remove_outdir_contents(OUTPUT_DIR) - kill_rrd() - + def test_rdm_trigger_event(): INSTALL_PACKAGE ="RDK-RRD-Test:1.0" command = [ @@ -116,3 +114,68 @@ def test_rdm_trigger_event(): ] result = subprocess.run(command, capture_output=True, text=True) assert result.returncode == 0 + + RBUS_SETTING_SUCCESS = "Setting Parameters using rbus success..." + assert RBUS_SETTING_SUCCESS in grep_rrdlogs(RBUS_SETTING_SUCCESS) + + CACHE_UPDATE_SUCCESS = "Setting Parameters Success and Cache Updated ...RDK-RRD-Test" + assert CACHE_UPDATE_SUCCESS in grep_rrdlogs(CACHE_UPDATE_SUCCESS) + +def test_rdm_rrd_trigger_event(): + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus', + 'bool', 'true' + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + +def test_rdm_rrd_dwnld_status(): + PACKAGE_FOUND = "Package found in Cache...Test.TestRun5" + assert PACKAGE_FOUND in grep_rrdlogs(PACKAGE_FOUND) + + PACKAGE_DETAIL = "Package Details jsonPath: /tmp/RDK-RRD-Test" + assert PACKAGE_DETAIL in grep_rrdlogs(PACKAGE_DETAIL) + + COPY_MSG = "Copying Message Received to the queue.." + assert COPY_MSG in grep_rrdlogs(COPY_MSG) + + SUCCESS_MSG_SEND = "Message sending Done, ID=0 MSG=Test.TestRun5 Size=13 Type=1 AppendMode=0!" + assert SUCCESS_MSG_SEND in grep_rrdlogs(SUCCESS_MSG_SEND) + + SUCCESS_MSG_RECEIVE = "Message Reception Done for ID=0 MSG=Test.TestRun5 TYPE=1..." + assert SUCCESS_MSG_RECEIVE in grep_rrdlogs(SUCCESS_MSG_RECEIVE) + + ISSUE_CMD_INFO = "Getting Issue command Information for : Test.TestRun5" + assert ISSUE_CMD_INFO in grep_rrdlogs(ISSUE_CMD_INFO) + + CHECK_IN_DYNAMIC = "Checking if Issue marked inDynamic..." + assert CHECK_IN_DYNAMIC in grep_rrdlogs(CHECK_IN_DYNAMIC) + + ISSUE_MARKED_DYNAMIC = "Issue Marked as inDynamic..." + assert ISSUE_MARKED_DYNAMIC in grep_rrdlogs(ISSUE_MARKED_DYNAMIC) + + START_JSON_READ = "Start Reading JSON File... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert START_JSON_READ in grep_rrdlogs(START_JSON_READ) + + JSON_READ_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_READ_SUCCESS in grep_rrdlogs(JSON_READ_SUCCESS) + + JSON_PARSE_SUCCESS = "Json File parse Success... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + READ_ISSUE_CATEGORY = "Reading Issue Category:Test..." + assert READ_ISSUE_CATEGORY in grep_rrdlogs(READ_ISSUE_CATEGORY) + + RUN_DEBUG_CMD = "Run Debug Commands for Test:TestRun5" + assert RUN_DEBUG_CMD in grep_rrdlogs(RUN_DEBUG_CMD) + + EXEC_RUNTIME_SERVICE = "Executing Commands in Runtime Service..." + assert EXEC_RUNTIME_SERVICE in grep_rrdlogs(EXEC_RUNTIME_SERVICE) + + START_REMOTE_DEBUGGER = "Starting remote_debugger_Test.TestRun5 service success..." + assert START_REMOTE_DEBUGGER in grep_rrdlogs(START_REMOTE_DEBUGGER) + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd() diff --git a/test/functional-tests/tests/test_rrd_negative.py b/test/functional-tests/tests/test_rrd_negative.py new file mode 100644 index 00000000..0fa927ed --- /dev/null +++ b/test/functional-tests/tests/test_rrd_negative.py @@ -0,0 +1,149 @@ +########################################################################## +# 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. +########################################################################## + +import json +import subprocess +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 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 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_remote_debugger_trigger_event(): + MISSING_STRING_NEG = "Test.TestRun7" + reset_issuetype_rfc() + sleep(10) + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', + 'string', MISSING_STRING_NEG + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + 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) + +def test_check_issue_in_static_profile(): + READ_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READ_JSON in grep_rrdlogs(READ_JSON) + + PARSE_JSON = "Static Profile Parse And Read Success" + assert PARSE_JSON in grep_rrdlogs(PARSE_JSON) + + MISSING_MSG = "Issue Data Not found in Static JSON File" + assert MISSING_MSG in grep_rrdlogs(MISSING_MSG) + +def test_check_issue_in_dynamic_profile(): + DYNAMIC_READ = "Checking Dynamic Profile..." + assert DYNAMIC_READ in grep_rrdlogs(DYNAMIC_READ) + + DYNAMIC_JSONFILE = "Reading json config file /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert DYNAMIC_JSONFILE in grep_rrdlogs(DYNAMIC_JSONFILE) + + PARSE_FAILED = "Dynamic Profile Parse/Read failed" + assert PARSE_FAILED in grep_rrdlogs(PARSE_FAILED) + + RDM_MSG = "Request RDM Manager Download for a new Issue Type" + assert RDM_MSG in grep_rrdlogs(RDM_MSG) + + RDM_PACKAGE = "Request RDM Manager Download for... RDK-RRD-Test:1.0" + assert RDM_PACKAGE in grep_rrdlogs(RDM_PACKAGE) + +def test_rdm_trigger_event(): + INSTALL_PACKAGE ="RDK-RRD-Test:1.0" + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RDKDownloadManager.InstallPackage', + 'string', INSTALL_PACKAGE + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + RBUS_SETTING_SUCCESS = "Setting Parameters using rbus success..." + assert RBUS_SETTING_SUCCESS in grep_rrdlogs(RBUS_SETTING_SUCCESS) + + CACHE_UPDATE_SUCCESS = "Setting Parameters Success and Cache Updated ...RDK-RRD-Test" + assert CACHE_UPDATE_SUCCESS in grep_rrdlogs(CACHE_UPDATE_SUCCESS) + +def test_rdm_download_event(): + command = [ + 'rbuscli', 'set', + 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus', + 'bool', 'true' + ] + result = subprocess.run(command, capture_output=True, text=True) + assert result.returncode == 0 + + RDM_DOWNLOAD_EVENT = "Received event for RDM_DOWNLOAD_EVENT Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus" + assert RDM_DOWNLOAD_EVENT in grep_rrdlogs(RDM_DOWNLOAD_EVENT) + + PACKAGE_FOUND = "Package found in Cache...Test.TestRun7" + assert PACKAGE_FOUND in grep_rrdlogs(PACKAGE_FOUND) + + MESSAGE_SUCCESS = "SUCCESS: Message sending Done, ID=0 MSG=Test.TestRun7 Size=13 Type=1 AppendMode=0!" + assert MESSAGE_SUCCESS in grep_rrdlogs(MESSAGE_SUCCESS) + + ISSUE_TYPE_LIST = "IssueType List [Test.TestRun7]..." + assert ISSUE_TYPE_LIST in grep_rrdlogs(ISSUE_TYPE_LIST) + + CHECKING_DYNAMIC = "Checking if Issue marked inDynamic..." + assert CHECKING_DYNAMIC in grep_rrdlogs(CHECKING_DYNAMIC) + + READING_JSON_CONFIG = "Reading json config file /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert READING_JSON_CONFIG in grep_rrdlogs(READING_JSON_CONFIG) + + JSON_PARSE_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + + DYNAMIC_JSON_PARSE_FAILED = "Dynamic JSON Parse/Read failed... /tmp/RDK-RRD-Test/etc/rrd/remote_debugger.json" + assert DYNAMIC_JSON_PARSE_FAILED in grep_rrdlogs(DYNAMIC_JSON_PARSE_FAILED) + + remove_logfile() + remove_outdir_contents(OUTPUT_DIR) + kill_rrd()