Skip to content
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

L2 test #98

Open
wants to merge 28 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
aca8ccf
Create test_rrd_dynamic_profile_report.py
Abhinavpv28 Mar 14, 2025
19af175
Create rrd_dynamic_profile_report.feature
Abhinavpv28 Mar 14, 2025
04fe87b
Update run_l2.sh
Abhinavpv28 Mar 14, 2025
0167ba1
Update run_l2.sh
Abhinavpv28 Mar 14, 2025
868a111
Update run_l2.sh
Abhinavpv28 Mar 14, 2025
7b2de0c
Update helper_functions.py
Abhinavpv28 Mar 14, 2025
7ea9844
Update test_rrd_dynamic_profile_report.py
Abhinavpv28 Mar 22, 2025
63a7543
Update helper_functions.py
Abhinavpv28 Mar 22, 2025
a56351c
Create test_rrd_dynamic_profile_missing_report.py
Abhinavpv28 Mar 22, 2025
bdd1359
Update run_l2.sh
Abhinavpv28 Mar 22, 2025
f4a8b18
Create create_json.sh
Abhinavpv28 Mar 22, 2025
318d743
Update create_json.sh
Abhinavpv28 Mar 26, 2025
70dea17
Update helper_functions.py
Abhinavpv28 Mar 26, 2025
eb467af
Create test_rrd_dynamic_profile_harmful_report.py
Abhinavpv28 Mar 27, 2025
f6b946b
Update helper_functions.py
Abhinavpv28 Mar 27, 2025
9b29df9
Create test_rrd_append_dynamic_profile_static_notfound.py
Abhinavpv28 Mar 27, 2025
087effd
Merge pull request #107 from rdkcentral/develop
Abhinavpv28 Mar 29, 2025
78d4035
Update helper_functions.py
Abhinavpv28 Mar 29, 2025
e59f42b
Update run_l2.sh
Abhinavpv28 Mar 29, 2025
89abf51
Update run_l2.sh
Abhinavpv28 Mar 29, 2025
3bcd951
Update run_l2.sh
Abhinavpv28 Mar 29, 2025
1b111ab
Update test_rrd_dynamic_profile_missing_report.py
Abhinavpv28 Mar 29, 2025
814029e
Update test_rrd_dynamic_profile_missing_report.py
Abhinavpv28 Apr 1, 2025
c3bcc93
Update run_l2.sh
Abhinavpv28 Apr 1, 2025
dd3730d
Update run_l2.sh
Abhinavpv28 Apr 1, 2025
1245e9c
Update test_rrd_dynamic_profile_report.py
Abhinavpv28 Apr 1, 2025
d37d6ea
Update test_rrd_append_dynamic_profile_static_notfound.py
Abhinavpv28 Apr 1, 2025
246e6bd
Update test_rrd_dynamic_profile_missing_report.py
Abhinavpv28 Apr 1, 2025
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
7 changes: 7 additions & 0 deletions run_l2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ mkdir -p "$RESULT_DIR"
mkdir -p "$OUTPUT_DIR"
mkdir -p "$STATIC_PROFILE_DIR"
mkdir -p "$LIB_DIR"
mkdir -p /media/apps/RDK-RRD-Test/etc/rrd

touch /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json

apt-get remove systemd
apt-get update && apt-get install -y tcpdump
Expand Down Expand Up @@ -56,6 +59,10 @@ 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_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_dynamic_profile_harmful_report.json test/functional-tests/tests/test_rrd_dynamic_profile_harmful_report.py
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
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_start_control.json test/functional-tests/tests/test_rrd_start_control.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rrd_start_subscribe_and_wait.json test/functional-tests/tests/test_rrd_start_subscribe_and_wait.py
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Feature: Remote Debugger Dynamic Issuetype Report

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 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 not 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 is not found in the profile

Scenario: Verify the Issuetype in dynamic path
Given the remote debugger issuetype is missing in static profile
When the remotedebugger read the json file form the dynamic path
Then remotedebugger json read and parse should be success
And remotedebugger should read the Issuetype from dynamic profile
And the issue data node and sub-node should be found in the JSON file
And the directory should be created to store the executed output
And Sanity check to validate the commands should be executed
And Command output shopuld be added to the output file
And the issuetype systemd service should start successfully
And the journalctl service should start successfully
And the process should sleep with timeout
And the issuetype systemd service should stop successfully
And the remotedebugger should call script to upload the debug report

Scenario: Upload remote debugger debug report
Given the remote debugger upload script is present
When I check the upload status in the logs
Then the upload should be successful if upload is success
Or the upload should fail if upload fails
20 changes: 20 additions & 0 deletions test/functional-tests/tests/create_json.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Step 1: Create a JSON file
json_file="/media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json"
echo '{
"Test": {
"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
7 changes: 6 additions & 1 deletion test/functional-tests/tests/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
HARMFULL_STRING = "Command.Harm"
MISSING_STRING = "Test.TestRun"
BACKGROUND_STRING = "Device.Dump"

DYNAMIC_DIR="/media/apps/RDK-RRD-Test/etc/rrd"
DYNAMIC_JSON_FILE = "/media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json"
DYNAMIC_STRING = "Test"
DYNAMIC_HARMFUL_STRING = "Test.TestRun3"
APPEND_STRING ="Test.TestRun2_apnd"
APPEND_JSON_FILE ="/media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json"
def remove_logfile():
try:
if os.path.exists(RRD_LOG_FILE):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import json
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_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():
reset_issuetype_rfc()
sleep(10)
command = [
'rbuscli', 'set',
'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType',
'string', APPEND_STRING
]
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)

JSON_SUCCESS_STATIC = "Static Profile Parse And Read Success... /etc/rrd/remote_debugger.json"
assert JSON_SUCCESS_STATIC in grep_rrdlogs(JSON_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 = "Issue Category:Test not found in JSON File!!!"
assert READ_COMPLETE_STATIC in grep_rrdlogs(READ_COMPLETE_STATIC)

STATIC_NOTFOUND = "Static Command Info not found for IssueType!!!"
assert STATIC_NOTFOUND in grep_rrdlogs(STATIC_NOTFOUND)


remove_logfile()
remove_outdir_contents(OUTPUT_DIR)
kill_rrd()
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import json
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():
reset_issuetype_rfc()
sleep(10)
command = [
'rbuscli', 'set',
'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType',
'string', DYNAMIC_HARMFUL_STRING
]
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_SUCCESS = "Dynamic Profile Parse And Read Success..."


def test_remote_debugger_command_sanity():
VALID_COMMAND = "rm -rf"
assert VALID_COMMAND in grep_rrdlogs(VALID_COMMAND)

SANITY_CHECK = "Found harmful commands"
assert SANITY_CHECK in grep_rrdlogs(SANITY_CHECK)

sleep(5)
ABORT_MSG = "Aborting Command execution due to Harmful commands"
assert ABORT_MSG in grep_rrdlogs(ABORT_MSG)

UPLOAD_MSG = "Skip uploading Debug Report"
assert UPLOAD_MSG in grep_rrdlogs(UPLOAD_MSG)

#remove_logfile()
remove_outdir_contents(OUTPUT_DIR)
kill_rrd()
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
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():
reset_issuetype_rfc()
sleep(10)
command = [
'rbuscli', 'set',
'Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType',
'string', MISSING_STRING
]
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
Loading
Loading