Skip to content

[RDKE] L2 Tests And Integration With CI for Remote Debugger Dynamic Updates #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions cov_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions run_l2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 21 additions & 9 deletions src/rrdInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/rrdInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
45 changes: 45 additions & 0 deletions test/functional-tests/features/rrd_append_report.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
##########################################################################

Check failure on line 1 in test/functional-tests/features/rrd_append_report.feature

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'test/functional-tests/features/rrd_append_report.feature' (Match: lgirdk/ccsp-wifi-agent/cf04a1c4000061c1f52d9a6dbd9f44ac1f612edb, 17 lines, url: https://github.com/lgirdk/ccsp-wifi-agent/archive/cf04a1c4000061c1f52d9a6dbd9f44ac1f612edb.tar.gz, file: scripts/mesh_status.sh)
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -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

20 changes: 15 additions & 5 deletions test/functional-tests/tests/create_json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
134 changes: 134 additions & 0 deletions test/functional-tests/tests/test_append.py
Original file line number Diff line number Diff line change
@@ -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()
Loading
Loading