From 9a7203220422ec4c0a371a0873d34afb94811916 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 11 Apr 2025 21:44:25 +0530 Subject: [PATCH 01/22] Create test_rrd_dynamic_missing_report.py --- .../tests/test_rrd_dynamic_missing_report.py | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 test/functional-tests/tests/test_rrd_dynamic_missing_report.py 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..1a6895f9 --- /dev/null +++ b/test/functional-tests/tests/test_rrd_dynamic_missing_report.py @@ -0,0 +1,174 @@ +########################################################################## +# 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) + #remove_logfile() + #remove_outdir_contents(OUTPUT_DIR) + #kill_rrd() + +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(): +# INSTALL_PACKAGE ="RDK-RRD-Test:1.0" + 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) From ca78c0262d6fc9f72471d0d52f54ba70ce0a29f4 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 11 Apr 2025 21:45:10 +0530 Subject: [PATCH 02/22] Update create_json.sh --- test/functional-tests/tests/create_json.sh | 27 +++++++--------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/test/functional-tests/tests/create_json.sh b/test/functional-tests/tests/create_json.sh index 3c71b688..0977407f 100644 --- a/test/functional-tests/tests/create_json.sh +++ b/test/functional-tests/tests/create_json.sh @@ -1,28 +1,15 @@ -########################################################################## -# 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. -########################################################################## - #!/bin/bash # Step 1: Create a JSON file json_file="/media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json" echo '{ "Test": { + "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 @@ -37,3 +24,5 @@ echo '{ } } }' > $json_file +mkdir -p /tmp/RDK-RRD-Test/etc/rrd/ +cp $json_file /tmp/RDK-RRD-Test/etc/rrd/ From c7afdc3b2ab94204bc70081dcf8d2d702cd146e7 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:05:11 +0530 Subject: [PATCH 03/22] Update configure.ac --- configure.ac | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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], From af7e9a6787842b1bbd0495257e72cb9932e0db0e Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:14:35 +0530 Subject: [PATCH 04/22] Update cov_build.sh --- cov_build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 52d4fca98282fce0ac75ab408680d97228cc6174 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:21:19 +0530 Subject: [PATCH 05/22] Update rrdInterface.h --- src/rrdInterface.h | 1 + 1 file changed, 1 insertion(+) 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 From 2649f8cc72e18b90a91e6ea11c7bb433458064f3 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:28:11 +0530 Subject: [PATCH 06/22] Update rrdInterface.c --- src/rrdInterface.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) 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) { From f98868daf60054f183a760f28493d3ebfc0213b3 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:30:31 +0530 Subject: [PATCH 07/22] Update create_json.sh --- test/functional-tests/tests/create_json.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/functional-tests/tests/create_json.sh b/test/functional-tests/tests/create_json.sh index 0977407f..d7760eb8 100644 --- a/test/functional-tests/tests/create_json.sh +++ b/test/functional-tests/tests/create_json.sh @@ -1,3 +1,22 @@ +########################################################################## +# 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. +########################################################################## + #!/bin/bash # Step 1: Create a JSON file From 3b2838efb1b3c9647b970fb44c2f4a985c12bcea Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 14:54:35 +0530 Subject: [PATCH 08/22] Update create_json.sh --- test/functional-tests/tests/create_json.sh | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/test/functional-tests/tests/create_json.sh b/test/functional-tests/tests/create_json.sh index d7760eb8..0977407f 100644 --- a/test/functional-tests/tests/create_json.sh +++ b/test/functional-tests/tests/create_json.sh @@ -1,22 +1,3 @@ -########################################################################## -# 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. -########################################################################## - #!/bin/bash # Step 1: Create a JSON file From b761a6762137ca5c92d94e43a20c968af69a1d1a Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 14:56:43 +0530 Subject: [PATCH 09/22] Update create_json.sh From 7c1fba966d0abe6dc0e3a20c1fd445700a837374 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 14:57:15 +0530 Subject: [PATCH 10/22] Update create_json.sh --- test/functional-tests/tests/create_json.sh | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/test/functional-tests/tests/create_json.sh b/test/functional-tests/tests/create_json.sh index 0977407f..43e130f0 100644 --- a/test/functional-tests/tests/create_json.sh +++ b/test/functional-tests/tests/create_json.sh @@ -1,9 +1,32 @@ +########################################################################## +# 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. +########################################################################## + #!/bin/bash # Step 1: Create a JSON file 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 }, @@ -17,10 +40,6 @@ echo '{ "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 From e658ac760410e61b636c1f292adfe2aad1211309 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 15:00:14 +0530 Subject: [PATCH 11/22] Update create_json.sh --- test/functional-tests/tests/create_json.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/functional-tests/tests/create_json.sh b/test/functional-tests/tests/create_json.sh index 43e130f0..436996d8 100644 --- a/test/functional-tests/tests/create_json.sh +++ b/test/functional-tests/tests/create_json.sh @@ -29,14 +29,16 @@ echo '{ }, "TestRun5": { "Commands": "cat /version.txt;uptime;cat /tmp/.deviceDetails.cache", - "Timeout": 10 }, + "Timeout": 10 + }, "TestRun4": { "Commands": "cat /version.txt;uptime;cat /tmp/.deviceDetails.cache", - "Timeout": 10 }, + "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 From fd30f236fb4f1259c154c354a6f135dacadb67a4 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 16:15:36 +0530 Subject: [PATCH 12/22] Create test_rrd_negative.py --- .../tests/test_rrd_negative.py | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 test/functional-tests/tests/test_rrd_negative.py 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..9fb78863 --- /dev/null +++ b/test/functional-tests/tests/test_rrd_negative.py @@ -0,0 +1,159 @@ +########################################################################## +# 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) + + 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 + + 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() From b45d324b74f7e0fcd67f4b0b700871f963b336d1 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Tue, 15 Apr 2025 16:16:49 +0530 Subject: [PATCH 13/22] Create test_append.py --- test/functional-tests/tests/test_append.py | 159 +++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 test/functional-tests/tests/test_append.py diff --git a/test/functional-tests/tests/test_append.py b/test/functional-tests/tests/test_append.py new file mode 100644 index 00000000..9fb78863 --- /dev/null +++ b/test/functional-tests/tests/test_append.py @@ -0,0 +1,159 @@ +########################################################################## +# 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) + + 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 + + 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() From dda79a886012361d88cd344ef0dbfde529cc198b Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Wed, 16 Apr 2025 11:28:48 +0530 Subject: [PATCH 14/22] Update run_l2.sh --- run_l2.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run_l2.sh b/run_l2.sh index 2da98029..8956494d 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_neg.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 From 238bde78ac6b346689c782f1444445aeaf62ca48 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Wed, 16 Apr 2025 11:38:33 +0530 Subject: [PATCH 15/22] Update test_rrd_dynamic_missing_report.py --- .../tests/test_rrd_dynamic_missing_report.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/functional-tests/tests/test_rrd_dynamic_missing_report.py b/test/functional-tests/tests/test_rrd_dynamic_missing_report.py index 1a6895f9..884eb95d 100644 --- a/test/functional-tests/tests/test_rrd_dynamic_missing_report.py +++ b/test/functional-tests/tests/test_rrd_dynamic_missing_report.py @@ -96,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:") @@ -104,10 +104,6 @@ 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 = [ @@ -118,7 +114,6 @@ def test_rdm_trigger_event(): result = subprocess.run(command, capture_output=True, text=True) assert result.returncode == 0 def test_rdm_rrd_trigger_event(): -# INSTALL_PACKAGE ="RDK-RRD-Test:1.0" command = [ 'rbuscli', 'set', 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.DownloadStatus', @@ -172,3 +167,7 @@ def test_rdm_rrd_dwnld_status(): 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() From 9988e63cdf94662dfddef3aefc378355efafe6ec Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:09:21 +0530 Subject: [PATCH 16/22] Update run_l2.sh --- run_l2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_l2.sh b/run_l2.sh index 8956494d..871129ce 100644 --- a/run_l2.sh +++ b/run_l2.sh @@ -59,7 +59,7 @@ 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_neg.py +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 From 64e92cb5ef5208f5dba5caddcdfb4e6ae2d3e1cb Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:45:33 +0530 Subject: [PATCH 17/22] Update test_append.py --- test/functional-tests/tests/test_append.py | 153 +++++++++------------ 1 file changed, 64 insertions(+), 89 deletions(-) diff --git a/test/functional-tests/tests/test_append.py b/test/functional-tests/tests/test_append.py index 9fb78863..72e28e0f 100644 --- a/test/functional-tests/tests/test_append.py +++ b/test/functional-tests/tests/test_append.py @@ -1,26 +1,30 @@ -########################################################################## -# 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 * +# 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." @@ -29,9 +33,19 @@ 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) @@ -45,13 +59,13 @@ def reset_issuetype_rfc(): assert result.returncode == 0 def test_remote_debugger_trigger_event(): - MISSING_STRING_NEG = "Test.TestRun7" + APPEND_STRING1 = "Test.TestRun4_apnd" reset_issuetype_rfc() sleep(10) command = [ 'rbuscli', 'set', 'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType', - 'string', MISSING_STRING_NEG + 'string', APPEND_STRING1 ] result = subprocess.run(command, capture_output=True, text=True) assert result.returncode == 0 @@ -69,90 +83,51 @@ def test_remote_debugger_trigger_event(): 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) + 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) - 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) + JSON_READ_SUCCESS = "Reading json file Success" + assert JSON_READ_SUCCESS in grep_rrdlogs(JSON_READ_SUCCESS) - 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 + JSON_PARSE_SUCCESS = "Json File parse Success" + assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) - RBUS_SETTING_SUCCESS = "Setting Parameters using rbus success..." - assert RBUS_SETTING_SUCCESS in grep_rrdlogs(RBUS_SETTING_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) - CACHE_UPDATE_SUCCESS = "Setting Parameters Success and Cache Updated ...RDK-RRD-Test" - assert CACHE_UPDATE_SUCCESS in grep_rrdlogs(CACHE_UPDATE_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) -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 + STATIC_READ = "Reading static profile command info..." + assert STATIC_READ in grep_rrdlogs(STATIC_READ) - 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) + READING_JSON = "Start Reading JSON File... /etc/rrd/remote_debugger.json" + assert READING_JSON in grep_rrdlogs(READING_JSON) - PACKAGE_FOUND = "Package found in Cache...Test.TestRun7" - assert PACKAGE_FOUND in grep_rrdlogs(PACKAGE_FOUND) + JSON_STATIC_SUCCESS = "Reading json file Success, Parsing the Content..." + assert JSON_STATIC_SUCCESS in grep_rrdlogs(JSON_STATIC_SUCCESS) - 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) + 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) - ISSUE_TYPE_LIST = "IssueType List [Test.TestRun7]..." - assert ISSUE_TYPE_LIST in grep_rrdlogs(ISSUE_TYPE_LIST) + SUCCESS_STATIC = "Static Profile Parse And Read Success... /etc/rrd/remote_debugger.json" + assert SUCCESS_STATIC in grep_rrdlogs(SUCCESS_STATIC) - CHECKING_DYNAMIC = "Checking if Issue marked inDynamic..." - assert CHECKING_DYNAMIC in grep_rrdlogs(CHECKING_DYNAMIC) + 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) - 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) + READ_COMPLETE_STATIC = "Read complete for Static Profile: RFCValue: Test.TestRun4, Command: " + assert READ_COMPLETE_STATIC in grep_rrdlogs(READ_COMPLETE_STATIC) - JSON_PARSE_SUCCESS = "Reading json file Success, Parsing the Content..." - assert JSON_PARSE_SUCCESS in grep_rrdlogs(JSON_PARSE_SUCCESS) + APPEND_UPDATE = "Updated command after append from dynamic and static profile: " + assert APPEND_UPDATE in grep_rrdlogs(APPEND_UPDATE) - 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) + EXECUTE_SERVICE = "Executing Commands in Runtime Service..." + assert EXECUTE_SERVICE in grep_rrdlogs(EXECUTE_SERVICE) remove_logfile() remove_outdir_contents(OUTPUT_DIR) From 76227e1bcfd2d10b0365b7acf77cee90b466ed00 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:57:21 +0530 Subject: [PATCH 18/22] Update test_rrd_negative.py --- test/functional-tests/tests/test_rrd_negative.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/functional-tests/tests/test_rrd_negative.py b/test/functional-tests/tests/test_rrd_negative.py index 9fb78863..0fa927ed 100644 --- a/test/functional-tests/tests/test_rrd_negative.py +++ b/test/functional-tests/tests/test_rrd_negative.py @@ -95,16 +95,6 @@ def test_check_issue_in_dynamic_profile(): 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 = [ From d062db192efe09d5ccf3f7079d0155485e9db625 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Wed, 16 Apr 2025 13:03:16 +0530 Subject: [PATCH 19/22] Update test_rrd_dynamic_profile_missing_report.py --- ...test_rrd_dynamic_profile_missing_report.py | 68 +++++++++++++++++-- 1 file changed, 62 insertions(+), 6 deletions(-) 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..844e58fc 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,61 @@ def test_rdm_trigger_event(): ] 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() From 20bfe385cf491b2a6632d56c98e7b43e4abd1773 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Wed, 16 Apr 2025 13:21:21 +0530 Subject: [PATCH 20/22] Update test_rrd_dynamic_profile_missing_report.py --- .../tests/test_rrd_dynamic_profile_missing_report.py | 7 +++++++ 1 file changed, 7 insertions(+) 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 844e58fc..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 @@ -114,6 +114,13 @@ 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', From b61bda26cdd4206d1f0c95f6d99b999747ebdb98 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Wed, 16 Apr 2025 15:44:56 +0530 Subject: [PATCH 21/22] Update rrd_dynamic_profile_missing_report.feature --- .../features/rrd_dynamic_profile_missing_report.feature | 7 +++++++ 1 file changed, 7 insertions(+) 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 + From 0d0016124a1b6b829453875b98fafed5afed1a43 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Mon, 21 Apr 2025 11:36:31 +0530 Subject: [PATCH 22/22] Create rrd_append_report.feature --- .../features/rrd_append_report.feature | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/functional-tests/features/rrd_append_report.feature 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