Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
046be19
Add script to test maintenance mode functionality
MohamedSameem97 Dec 16, 2025
ab2948c
Add script to test maintenance mode functionality
MohamedSameem97 Dec 16, 2025
c9ceb3c
Add script to manage maintenance mode in background
MohamedSameem97 Dec 16, 2025
16a963f
Add script to manage maintenance mode in foreground
MohamedSameem97 Dec 16, 2025
a3a1da6
Add maintenance mode opt-out test script
MohamedSameem97 Dec 16, 2025
8439369
Add test script for maintenance mode enforcement
MohamedSameem97 Dec 16, 2025
12e025b
Add script for maintenance mode critical update
MohamedSameem97 Dec 16, 2025
adeb98e
Fix permissions for maintenance.sh script
MohamedSameem97 Dec 16, 2025
b9ff8f9
Fix script formatting and update permissions command
MohamedSameem97 Dec 16, 2025
690173c
Fix script permissions for maintenance.sh
MohamedSameem97 Dec 16, 2025
07d552e
Fix permissions for maintenance.sh script
MohamedSameem97 Dec 16, 2025
e9a8e04
Update test_maintenanceMode_BACKGROUND_NONE.sh
MohamedSameem97 Dec 17, 2025
1040f55
Update test_maintenanceMode_FOREGROUND_NONE.sh
MohamedSameem97 Dec 17, 2025
3586ab6
Update test_maintenanceMode_BACKGROUND_IGNOREUPDATE.sh
MohamedSameem97 Dec 17, 2025
3269fac
Update test_maintenanceMode_FOREGROUND_IGNORE_UPDATE.sh
MohamedSameem97 Dec 17, 2025
11c058e
Update test_maintenanceMode_BACKGROUND_ENFORCE_OPTOUT.sh
MohamedSameem97 Dec 17, 2025
84021da
Update test_maintenanceMode_FOREGROUND_ENFORCE_OPTOUT.sh
MohamedSameem97 Dec 17, 2025
27c629b
Update test_maintenanceMode_criticalUpdate.sh
MohamedSameem97 Dec 17, 2025
7afbbc0
Update test_maintenanceMode_BACKGROUND_ENFORCE_OPTOUT.sh
MohamedSameem97 Dec 17, 2025
8af5c6c
Update test_maintenanceMode_BACKGROUND_IGNOREUPDATE.sh
MohamedSameem97 Dec 17, 2025
d3325c5
Update test_maintenanceMode_BACKGROUND_NONE.sh
MohamedSameem97 Dec 17, 2025
8393a05
Update test_maintenanceMode_FOREGROUND_ENFORCE_OPTOUT.sh
MohamedSameem97 Dec 17, 2025
6f71a05
Update test_maintenanceMode_FOREGROUND_IGNORE_UPDATE.sh
MohamedSameem97 Dec 17, 2025
4416517
Update test_maintenanceMode_FOREGROUND_NONE.sh
MohamedSameem97 Dec 17, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash


URL="http://127.0.0.1:9998/jsonrpc"
AUTH_HEADER="Authorization: Bearer"
LOG_FILE="/opt/logs/maintenance.log"

#Clear log file
> /opt/logs/maintenance.log

EXPECTED_MODE="BACKGROUND"
EXPECTED_OPTOUT="ENFORCE_OPTOUT"

# ---------------------------------------------------------
# 1. Set Maintenance Mode to BACKGROUND
# ---------------------------------------------------------
echo "STEP 1: Setting maintenance mode to BACKGROUND..."

curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d "{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"org.rdk.MaintenanceManager.1.setMaintenanceMode\",\"params\":{\"maintenanceMode\":\"$EXPECTED_MODE\",\"optOut\":\"$EXPECTED_OPTOUT\"}}" \
"$URL"

echo -e "\n"

# ---------------------------------------------------------
# 2. Get & Verify Maintenance Mode
# ---------------------------------------------------------
echo "STEP 2: Getting maintenance mode..."

GET_RESPONSE=$(curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d '{"jsonrpc":"2.0","id":"3","method":"org.rdk.MaintenanceManager.1.getMaintenanceMode","params":{}}' \
"$URL")

echo "Response: $GET_RESPONSE"
echo -e "\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assert of the response has the EXPECTED_MODE here too?


# ---------------------------------------------------------
# 2A Verify GET_RESPONSE matches EXPECTED_MODE and EXPECTED_OPTOUT
# ---------------------------------------------------------

# Extract values from JSON response
REPORTED_MODE=$(echo "$GET_RESPONSE" | grep -o '"maintenanceMode":"[^"]*"' | cut -d':' -f2 | tr -d '"')
REPORTED_OPTOUT=$(echo "$GET_RESPONSE" | grep -o '"optOut":"[^"]*"' | cut -d':' -f2 | tr -d '"')

echo "Extracted maintenanceMode: $REPORTED_MODE"
echo "Extracted optOut: $REPORTED_OPTOUT"

# Compare both values
if [[ "$REPORTED_MODE" == "$EXPECTED_MODE" ]] && [[ "$REPORTED_OPTOUT" == "$EXPECTED_OPTOUT" ]]; then
echo "Verification: PASS — maintenanceMode and optOut match expected values."
else
echo "Verification: FAIL"
echo "Expected maintenanceMode: $EXPECTED_MODE, Got: $REPORTED_MODE"
echo "Expected optOut: $EXPECTED_OPTOUT, Got: $REPORTED_OPTOUT"
fi

echo -e "\n"

# ---------------------------------------------------------
# 3. Trigger Maintenance Mode
# Maintenance should not be running
# ---------------------------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do add a comment that a running Maintenance is not a pre-condition of just add a pre-condition step and call stopMaintenance if needed

echo "STEP 3: Triggering startMaintenance..."

curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d '{"jsonrpc":"2.0","id":"3","method":"org.rdk.MaintenanceManager.1.startMaintenance","params":{}}' \
"$URL"

echo -e "\n"

# ---------------------------------------------------------
# 4. Verify Maintenance Mode in Log
# ---------------------------------------------------------
echo "STEP 4: Checking maintenance.log for maintenance entries"

if [[ -f "$LOG_FILE" ]]; then
sleep 5

LOG_MODE=$(grep -o '"maintenanceMode":"[^"]*"' "$LOG_FILE" | tail -1 | cut -d':' -f2 | tr -d '"')
LOG_OPTOUT=$(grep -o '"optOut":"[^"]*"' "$LOG_FILE" | tail -1 | cut -d':' -f2 | tr -d '"')

echo "Log maintenanceMode: $LOG_MODE"
echo "Log optOut: $LOG_OPTOUT"

if [[ "$LOG_MODE" == "$EXPECTED_MODE" ]] && [[ "$LOG_OPTOUT" == "$EXPECTED_OPTOUT" ]]; then
echo "RESULT: PASS"
else
echo "RESULT: FAIL"
fi
else
echo "ERROR: Log file not found at $LOG_FILE"
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash


URL="http://127.0.0.1:9998/jsonrpc"
AUTH_HEADER="Authorization: Bearer"
LOG_FILE="/opt/logs/maintenance.log"

#Clear log file
> /opt/logs/maintenance.log

EXPECTED_MODE="BACKGROUND"
EXPECTED_OPTOUT="IGNORE_UPDATE"

# ---------------------------------------------------------
# 1. Set Maintenance Mode to BACKGROUND
# ---------------------------------------------------------
echo "STEP 1: Setting maintenance mode to BACKGROUND..."

curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d "{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"org.rdk.MaintenanceManager.1.setMaintenanceMode\",\"params\":{\"maintenanceMode\":\"$EXPECTED_MODE\",\"optOut\":\"$EXPECTED_OPTOUT\"}}" \
"$URL"

echo -e "\n"

# ---------------------------------------------------------
# 2. Get & Verify Maintenance Mode
# ---------------------------------------------------------
echo "STEP 2: Getting maintenance mode..."

GET_RESPONSE=$(curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d '{"jsonrpc":"2.0","id":"3","method":"org.rdk.MaintenanceManager.1.getMaintenanceMode","params":{}}' \
"$URL")

echo "Response: $GET_RESPONSE"
echo -e "\n"

# ---------------------------------------------------------
# 2A Verify GET_RESPONSE matches EXPECTED_MODE and EXPECTED_OPTOUT
# ---------------------------------------------------------

# Extract values from JSON response
REPORTED_MODE=$(echo "$GET_RESPONSE" | grep -o '"maintenanceMode":"[^"]*"' | cut -d':' -f2 | tr -d '"')
REPORTED_OPTOUT=$(echo "$GET_RESPONSE" | grep -o '"optOut":"[^"]*"' | cut -d':' -f2 | tr -d '"')

echo "Extracted maintenanceMode: $REPORTED_MODE"
echo "Extracted optOut: $REPORTED_OPTOUT"

# Compare both values
if [[ "$REPORTED_MODE" == "$EXPECTED_MODE" ]] && [[ "$REPORTED_OPTOUT" == "$EXPECTED_OPTOUT" ]]; then
echo "Verification: PASS — maintenanceMode and optOut match expected values."
else
echo "Verification: FAIL"
echo "Expected maintenanceMode: $EXPECTED_MODE, Got: $REPORTED_MODE"
echo "Expected optOut: $EXPECTED_OPTOUT, Got: $REPORTED_OPTOUT"
fi

echo -e "\n"

# ---------------------------------------------------------
# 3. Trigger Maintenance Mode
# Maintenance should not be running
# ---------------------------------------------------------
echo "STEP 3: Triggering startMaintenance..."

curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d '{"jsonrpc":"2.0","id":"3","method":"org.rdk.MaintenanceManager.1.startMaintenance","params":{}}' \
"$URL"

echo -e "\n"

# ---------------------------------------------------------
# 4. Verify Maintenance Mode in Log
# ---------------------------------------------------------
echo "STEP 4: Checking maintenance.log for maintenance entries"

if [[ -f "$LOG_FILE" ]]; then
sleep 5

LOG_MODE=$(grep -o '"maintenanceMode":"[^"]*"' "$LOG_FILE" | tail -1 | cut -d':' -f2 | tr -d '"')
LOG_OPTOUT=$(grep -o '"optOut":"[^"]*"' "$LOG_FILE" | tail -1 | cut -d':' -f2 | tr -d '"')

echo "Log maintenanceMode: $LOG_MODE"
echo "Log optOut: $LOG_OPTOUT"

if [[ "$LOG_MODE" == "$EXPECTED_MODE" ]] && [[ "$LOG_OPTOUT" == "$EXPECTED_OPTOUT" ]]; then
echo "RESULT: PASS"
else
echo "RESULT: FAIL"
fi
else
echo "ERROR: Log file not found at $LOG_FILE"
fi
98 changes: 98 additions & 0 deletions Tests/TestScripts/test_maintenanceMode_BACKGROUND_NONE.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash


URL="http://127.0.0.1:9998/jsonrpc"
AUTH_HEADER="Authorization: Bearer"
LOG_FILE="/opt/logs/maintenance.log"

#Clear log file
> /opt/logs/maintenance.log

EXPECTED_MODE="BACKGROUND"
EXPECTED_OPTOUT="NONE"

# ---------------------------------------------------------
# 1. Set Maintenance Mode to BACKGROUND
# ---------------------------------------------------------
echo "STEP 1: Setting maintenance mode to BACKGROUND..."

curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d "{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"org.rdk.MaintenanceManager.1.setMaintenanceMode\",\"params\":{\"maintenanceMode\":\"$EXPECTED_MODE\",\"optOut\":\"$EXPECTED_OPTOUT\"}}" \
"$URL"

echo -e "\n"

# ---------------------------------------------------------
# 2. Get & Verify Maintenance Mode
# ---------------------------------------------------------
echo "STEP 2: Getting maintenance mode..."

GET_RESPONSE=$(curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d '{"jsonrpc":"2.0","id":"3","method":"org.rdk.MaintenanceManager.1.getMaintenanceMode","params":{}}' \
"$URL")

echo "Response: $GET_RESPONSE"
echo -e "\n"

# ---------------------------------------------------------
# 2A Verify GET_RESPONSE matches EXPECTED_MODE and EXPECTED_OPTOUT
# ---------------------------------------------------------

# Extract values from JSON response
REPORTED_MODE=$(echo "$GET_RESPONSE" | grep -o '"maintenanceMode":"[^"]*"' | cut -d':' -f2 | tr -d '"')
REPORTED_OPTOUT=$(echo "$GET_RESPONSE" | grep -o '"optOut":"[^"]*"' | cut -d':' -f2 | tr -d '"')

echo "Extracted maintenanceMode: $REPORTED_MODE"
echo "Extracted optOut: $REPORTED_OPTOUT"

# Compare both values
if [[ "$REPORTED_MODE" == "$EXPECTED_MODE" ]] && [[ "$REPORTED_OPTOUT" == "$EXPECTED_OPTOUT" ]]; then
echo "Verification: PASS — maintenanceMode and optOut match expected values."
else
echo "Verification: FAIL"
echo "Expected maintenanceMode: $EXPECTED_MODE, Got: $REPORTED_MODE"
echo "Expected optOut: $EXPECTED_OPTOUT, Got: $REPORTED_OPTOUT"
fi

echo -e "\n"

# ---------------------------------------------------------
# 3. Trigger Maintenance Mode
# Maintenance should not be running
# ---------------------------------------------------------
echo "STEP 3: Triggering startMaintenance..."

curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d '{"jsonrpc":"2.0","id":"3","method":"org.rdk.MaintenanceManager.1.startMaintenance","params":{}}' \
"$URL"

echo -e "\n"

# ---------------------------------------------------------
# 4. Verify Maintenance Mode in Log
# ---------------------------------------------------------
echo "STEP 4: Checking maintenance.log for maintenance entries"

if [[ -f "$LOG_FILE" ]]; then
sleep 5

LOG_MODE=$(grep -o '"maintenanceMode":"[^"]*"' "$LOG_FILE" | tail -1 | cut -d':' -f2 | tr -d '"')
LOG_OPTOUT=$(grep -o '"optOut":"[^"]*"' "$LOG_FILE" | tail -1 | cut -d':' -f2 | tr -d '"')

echo "Log maintenanceMode: $LOG_MODE"
echo "Log optOut: $LOG_OPTOUT"

if [[ "$LOG_MODE" == "$EXPECTED_MODE" ]] && [[ "$LOG_OPTOUT" == "$EXPECTED_OPTOUT" ]]; then
echo "RESULT: PASS"
else
echo "RESULT: FAIL"
fi
else
echo "ERROR: Log file not found at $LOG_FILE"
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash


URL="http://127.0.0.1:9998/jsonrpc"
AUTH_HEADER="Authorization: Bearer"
LOG_FILE="/opt/logs/maintenance.log"

#Clear log file
> /opt/logs/maintenance.log

EXPECTED_MODE="FOREGROUND"
EXPECTED_OPTOUT="ENFORCE_OPTOUT"

# ---------------------------------------------------------
# 1. Set Maintenance Mode to FOREGROUND
# ---------------------------------------------------------
echo "STEP 1: Setting maintenance mode to FOREGROUND..."

curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d "{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"org.rdk.MaintenanceManager.1.setMaintenanceMode\",\"params\":{\"maintenanceMode\":\"$EXPECTED_MODE\",\"optOut\":\"$EXPECTED_OPTOUT\"}}" \
"$URL"

echo -e "\n"

# ---------------------------------------------------------
# 2. Get & Verify Maintenance Mode
# ---------------------------------------------------------
echo "STEP 2: Getting maintenance mode..."

GET_RESPONSE=$(curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d '{"jsonrpc":"2.0","id":"3","method":"org.rdk.MaintenanceManager.1.getMaintenanceMode","params":{}}' \
"$URL")

echo "Response: $GET_RESPONSE"
echo -e "\n"

# ---------------------------------------------------------
# 2A Verify GET_RESPONSE matches EXPECTED_MODE and EXPECTED_OPTOUT
# ---------------------------------------------------------

# Extract values from JSON response
REPORTED_MODE=$(echo "$GET_RESPONSE" | grep -o '"maintenanceMode":"[^"]*"' | cut -d':' -f2 | tr -d '"')
REPORTED_OPTOUT=$(echo "$GET_RESPONSE" | grep -o '"optOut":"[^"]*"' | cut -d':' -f2 | tr -d '"')

echo "Extracted maintenanceMode: $REPORTED_MODE"
echo "Extracted optOut: $REPORTED_OPTOUT"

# Compare both values
if [[ "$REPORTED_MODE" == "$EXPECTED_MODE" ]] && [[ "$REPORTED_OPTOUT" == "$EXPECTED_OPTOUT" ]]; then
echo "Verification: PASS — maintenanceMode and optOut match expected values."
else
echo "Verification: FAIL"
echo "Expected maintenanceMode: $EXPECTED_MODE, Got: $REPORTED_MODE"
echo "Expected optOut: $EXPECTED_OPTOUT, Got: $REPORTED_OPTOUT"
fi

echo -e "\n"

# ---------------------------------------------------------
# 3. Trigger Maintenance Mode
# Maintenance should not be running
# ---------------------------------------------------------
echo "STEP 3: Triggering startMaintenance..."

curl -H "$AUTH_HEADER" \
-H "Content-Type: application/json" \
--request POST --silent \
-d '{"jsonrpc":"2.0","id":"3","method":"org.rdk.MaintenanceManager.1.startMaintenance","params":{}}' \
"$URL"

echo -e "\n"

# ---------------------------------------------------------
# 4. Verify Maintenance Mode in Log
# ---------------------------------------------------------
echo "STEP 4: Checking maintenance.log for maintenance entries"

if [[ -f "$LOG_FILE" ]]; then
sleep 5

LOG_MODE=$(grep -o '"maintenanceMode":"[^"]*"' "$LOG_FILE" | tail -1 | cut -d':' -f2 | tr -d '"')
LOG_OPTOUT=$(grep -o '"optOut":"[^"]*"' "$LOG_FILE" | tail -1 | cut -d':' -f2 | tr -d '"')

echo "Log maintenanceMode: $LOG_MODE"
echo "Log optOut: $LOG_OPTOUT"

if [[ "$LOG_MODE" == "$EXPECTED_MODE" ]] && [[ "$LOG_OPTOUT" == "$EXPECTED_OPTOUT" ]]; then
echo "RESULT: PASS"
else
echo "RESULT: FAIL"
fi
else
echo "ERROR: Log file not found at $LOG_FILE"
fi
Loading
Loading