Some checks failed
Compile apt-layer (v2) / compile (push) Failing after 3h9m6s
- D-Bus methods, properties, and signals all working correctly - Shell integration tests pass 16/19 tests - Core daemon fully decoupled from D-Bus dependencies - Clean architecture with thin D-Bus wrappers established - Signal emission using correct dbus-next pattern - Updated test scripts for apt-ostreed service name - Fixed dbus-next signal definitions and emission patterns - Updated TODO and CHANGELOG for Phase 3 completion
196 lines
No EOL
7.5 KiB
Bash
Executable file
196 lines
No EOL
7.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# D-Bus Method Testing Script (Updated for apt-ostreed)
|
|
# Tests all available D-Bus methods in the apt-ostreed daemon
|
|
|
|
set -e
|
|
|
|
echo "=== apt-ostreed D-Bus Method Testing ==="
|
|
echo "Testing all available D-Bus methods..."
|
|
echo
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Test counter
|
|
TOTAL_TESTS=0
|
|
PASSED_TESTS=0
|
|
FAILED_TESTS=0
|
|
|
|
# Function to run a test
|
|
run_test() {
|
|
local test_name="$1"
|
|
local cmd="$2"
|
|
local expected_success="${3:-true}"
|
|
|
|
TOTAL_TESTS=$((TOTAL_TESTS + 1))
|
|
|
|
echo -e "${BLUE}Testing: $test_name${NC}"
|
|
echo "Command: $cmd"
|
|
|
|
if eval "$cmd" >/dev/null 2>&1; then
|
|
if [ "$expected_success" = "true" ]; then
|
|
echo -e "${GREEN}✅ PASS${NC}"
|
|
PASSED_TESTS=$((PASSED_TESTS + 1))
|
|
else
|
|
echo -e "${RED}❌ FAIL (expected to fail but succeeded)${NC}"
|
|
FAILED_TESTS=$((FAILED_TESTS + 1))
|
|
fi
|
|
else
|
|
if [ "$expected_success" = "false" ]; then
|
|
echo -e "${GREEN}✅ PASS (expected failure)${NC}"
|
|
PASSED_TESTS=$((PASSED_TESTS + 1))
|
|
else
|
|
echo -e "${RED}❌ FAIL${NC}"
|
|
FAILED_TESTS=$((FAILED_TESTS + 1))
|
|
fi
|
|
fi
|
|
echo
|
|
}
|
|
|
|
# Function to test with output capture
|
|
run_test_with_output() {
|
|
local test_name="$1"
|
|
local cmd="$2"
|
|
local expected_success="${3:-true}"
|
|
|
|
TOTAL_TESTS=$((TOTAL_TESTS + 1))
|
|
|
|
echo -e "${BLUE}Testing: $test_name${NC}"
|
|
echo "Command: $cmd"
|
|
|
|
if output=$(eval "$cmd" 2>&1); then
|
|
if [ "$expected_success" = "true" ]; then
|
|
echo -e "${GREEN}✅ PASS${NC}"
|
|
echo "Output: $output" | head -c 200
|
|
if [ ${#output} -gt 200 ]; then
|
|
echo "..."
|
|
fi
|
|
PASSED_TESTS=$((PASSED_TESTS + 1))
|
|
else
|
|
echo -e "${RED}❌ FAIL (expected to fail but succeeded)${NC}"
|
|
FAILED_TESTS=$((FAILED_TESTS + 1))
|
|
fi
|
|
else
|
|
if [ "$expected_success" = "false" ]; then
|
|
echo -e "${GREEN}✅ PASS (expected failure)${NC}"
|
|
PASSED_TESTS=$((PASSED_TESTS + 1))
|
|
else
|
|
echo -e "${RED}❌ FAIL${NC}"
|
|
echo "Error: $output"
|
|
FAILED_TESTS=$((FAILED_TESTS + 1))
|
|
fi
|
|
fi
|
|
echo
|
|
}
|
|
|
|
# Use the correct service/object/interface names for apt-ostreed
|
|
echo "=== Sysroot Interface Tests ==="
|
|
|
|
run_test_with_output "GetStatus" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.GetStatus"
|
|
|
|
run_test_with_output "InstallPackages (test package)" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.InstallPackages array:string:\"test-package\" boolean:false"
|
|
|
|
run_test_with_output "RemovePackages (test package)" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.RemovePackages array:string:\"test-package\" boolean:false"
|
|
|
|
run_test_with_output "Deploy (test deployment)" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.Deploy string:\"test-deployment\""
|
|
|
|
run_test_with_output "Upgrade" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.Upgrade"
|
|
|
|
run_test_with_output "Rollback" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.Rollback"
|
|
|
|
# CreateComposeFSLayer, RegisterClient, UnregisterClient not in current interface
|
|
|
|
run_test_with_output "Reload" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.Reload"
|
|
|
|
run_test_with_output "ReloadConfig" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.ReloadConfig"
|
|
|
|
run_test_with_output "GetOS" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.GetOS"
|
|
|
|
echo "=== OS Interface Tests ==="
|
|
|
|
run_test_with_output "GetBootedDeployment" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/OS/default org.debian.aptostree1.OS.GetBootedDeployment"
|
|
|
|
run_test_with_output "GetDefaultDeployment" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/OS/default org.debian.aptostree1.OS.GetDefaultDeployment"
|
|
|
|
run_test_with_output "ListDeployments" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/OS/default org.debian.aptostree1.OS.ListDeployments"
|
|
|
|
echo "=== D-Bus Properties Tests ==="
|
|
|
|
run_test_with_output "GetAll Properties (Sysroot)" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.freedesktop.DBus.Properties.GetAll string:org.debian.aptostree1.Sysroot"
|
|
|
|
run_test_with_output "GetAll Properties (OS)" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/OS/default org.freedesktop.DBus.Properties.GetAll string:org.debian.aptostree1.OS"
|
|
|
|
echo "=== Error Handling Tests ==="
|
|
|
|
run_test "Invalid Method (should fail)" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.InvalidMethod" \
|
|
"false"
|
|
|
|
run_test "Invalid Interface (should fail)" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.InvalidInterface.GetStatus" \
|
|
"false"
|
|
|
|
run_test "Invalid Path (should fail)" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/InvalidPath org.debian.aptostree1.Sysroot.GetStatus" \
|
|
"false"
|
|
|
|
echo "=== D-Bus Introspection Tests ==="
|
|
|
|
run_test_with_output "Introspect Sysroot" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.freedesktop.DBus.Introspectable.Introspect"
|
|
|
|
run_test_with_output "Introspect OS" \
|
|
"dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/OS/default org.freedesktop.DBus.Introspectable.Introspect"
|
|
|
|
# Signal emission test: monitor for TransactionProgress signal during Deploy
|
|
# This will run dbus-monitor in the background, trigger Deploy, and check for signal output
|
|
|
|
echo "=== Signal Emission Test (TransactionProgress) ==="
|
|
|
|
dbus-monitor --system "interface='org.debian.aptostree1.Sysroot',member='TransactionProgress'" > /tmp/dbus_signal_test.log &
|
|
MON_PID=$!
|
|
sleep 1
|
|
|
|
dbus-send --system --dest=org.debian.aptostree1 --print-reply /org/debian/aptostree1/Sysroot org.debian.aptostree1.Sysroot.Deploy string:"signal-test"
|
|
sleep 2
|
|
kill $MON_PID
|
|
|
|
if grep -q TransactionProgress /tmp/dbus_signal_test.log; then
|
|
echo -e "${GREEN}TransactionProgress signal received during Deploy${NC}"
|
|
else
|
|
echo -e "${RED}TransactionProgress signal NOT received during Deploy${NC}"
|
|
FAILED_TESTS=$((FAILED_TESTS + 1))
|
|
fi
|
|
rm -f /tmp/dbus_signal_test.log
|
|
|
|
echo "=== Summary ==="
|
|
echo "Total tests: $TOTAL_TESTS"
|
|
echo -e "${GREEN}Passed: $PASSED_TESTS${NC}"
|
|
echo -e "${RED}Failed: $FAILED_TESTS${NC}"
|
|
|
|
if [ $FAILED_TESTS -eq 0 ]; then
|
|
echo -e "${GREEN}🎉 All D-Bus method tests passed!${NC}"
|
|
exit 0
|
|
else
|
|
echo -e "${RED}⚠️ $FAILED_TESTS tests failed.${NC}"
|
|
exit 1
|
|
fi |