From c6a364638e9391b852b05e01b8da256d92434223 Mon Sep 17 00:00:00 2001 From: scienmind Date: Sat, 24 Jan 2026 13:32:46 -0500 Subject: [PATCH 1/2] add samba service --- config.local.template | 1 + srv-ctl.sh | 4 +- tests/e2e/test-e2e.sh | 1 + tests/integration/test-bitlocker.bats | 1 + tests/integration/test-config-validation.bats | 8 +++ tests/integration/test-ownership.bats | 8 +++ tests/integration/test-services.bats | 56 +++++++++++++++++++ tests/system/test-system.sh | 5 ++ 8 files changed, 83 insertions(+), 1 deletion(-) diff --git a/config.local.template b/config.local.template index 6993374..58f7c49 100644 --- a/config.local.template +++ b/config.local.template @@ -13,6 +13,7 @@ readonly ST_USER_2="none" # Set to username to enable (e.g., "bob") readonly ST_SERVICE_1=$([ "$ST_USER_1" != "none" ] && echo "syncthing@${ST_USER_1}.service" || echo "none") readonly ST_SERVICE_2=$([ "$ST_USER_2" != "none" ] && echo "syncthing@${ST_USER_2}.service" || echo "none") readonly DOCKER_SERVICE="none" # Set to "docker.service" to enable +readonly SAMBA_SERVICE="none" # Set to "smbd.service" to enable (for network shares) # ----------------------------------------------------------------------------- # Primary data device configuration diff --git a/srv-ctl.sh b/srv-ctl.sh index d0679f0..46bedc1 100755 --- a/srv-ctl.sh +++ b/srv-ctl.sh @@ -200,7 +200,7 @@ function close_all_devices() { # ----------------------------------------------------------------------------- function start_all_services() { - if [ "$ST_SERVICE_1" != "none" ] || [ "$ST_SERVICE_2" != "none" ] || [ "$DOCKER_SERVICE" != "none" ]; then + if [ "$ST_SERVICE_1" != "none" ] || [ "$ST_SERVICE_2" != "none" ] || [ "$DOCKER_SERVICE" != "none" ] || [ "$SAMBA_SERVICE" != "none" ]; then echo "Reloading systemd units..." if ! systemctl daemon-reload; then echo "ERROR: Failed to reload systemd units" @@ -215,12 +215,14 @@ function start_all_services() { start_service "$ST_SERVICE_1" || return "$FAILURE" start_service "$ST_SERVICE_2" || return "$FAILURE" start_service "$DOCKER_SERVICE" || return "$FAILURE" + start_service "$SAMBA_SERVICE" || return "$FAILURE" } function stop_all_services() { stop_service "$ST_SERVICE_1" stop_service "$ST_SERVICE_2" stop_service "$DOCKER_SERVICE" + stop_service "$SAMBA_SERVICE" } # ----------------------------------------------------------------------------- diff --git a/tests/e2e/test-e2e.sh b/tests/e2e/test-e2e.sh index 23c24d6..a6e7771 100644 --- a/tests/e2e/test-e2e.sh +++ b/tests/e2e/test-e2e.sh @@ -458,6 +458,7 @@ readonly ST_SERVICE_1="ssh" readonly ST_USER_2="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" # Primary Data Device (uses test environment) readonly PRIMARY_DATA_UUID="$TEST_LOOP_UUID" diff --git a/tests/integration/test-bitlocker.bats b/tests/integration/test-bitlocker.bats index 4018bc0..29e2a8f 100755 --- a/tests/integration/test-bitlocker.bats +++ b/tests/integration/test-bitlocker.bats @@ -210,6 +210,7 @@ readonly ST_SERVICE_1="none" readonly ST_USER_2="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="$TEST_BITLOCKER_UUID" readonly PRIMARY_DATA_KEY_FILE="$TEST_BITLOCKER_KEY_FILE" readonly PRIMARY_DATA_ENCRYPTION_TYPE="bitlocker" diff --git a/tests/integration/test-config-validation.bats b/tests/integration/test-config-validation.bats index e4ab2e7..74e9dee 100755 --- a/tests/integration/test-config-validation.bats +++ b/tests/integration/test-config-validation.bats @@ -47,6 +47,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid-test" readonly PRIMARY_DATA_KEY_FILE="/tmp/test_keyfile_is_dir" @@ -90,6 +91,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid-test" readonly PRIMARY_DATA_KEY_FILE="/tmp/test_unreadable_keyfile" @@ -140,6 +142,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid-test" readonly PRIMARY_DATA_KEY_FILE="/tmp/test_symlink_keyfile" @@ -182,6 +185,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid-test" readonly PRIMARY_DATA_KEY_FILE="/tmp/test_broken_symlink" @@ -228,6 +232,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid-test" readonly PRIMARY_DATA_KEY_FILE="none" @@ -267,6 +272,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid-test" readonly PRIMARY_DATA_KEY_FILE="none" @@ -310,6 +316,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid-1" readonly PRIMARY_DATA_KEY_FILE="none" @@ -363,6 +370,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="none" diff --git a/tests/integration/test-ownership.bats b/tests/integration/test-ownership.bats index d68a19b..e7667b8 100755 --- a/tests/integration/test-ownership.bats +++ b/tests/integration/test-ownership.bats @@ -146,6 +146,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="syncthing@test_user_1.service" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="none" readonly STORAGE_1A_UUID="none" @@ -184,6 +185,7 @@ readonly ST_USER_2="test_user_2" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="syncthing@test_user_2.service" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="none" readonly STORAGE_1A_UUID="none" @@ -222,6 +224,7 @@ readonly ST_USER_2="test_user_2" readonly ST_SERVICE_1="syncthing@test_user_1.service" readonly ST_SERVICE_2="syncthing@test_user_2.service" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="none" readonly STORAGE_1A_UUID="none" @@ -261,6 +264,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="none" readonly STORAGE_1A_UUID="none" @@ -303,6 +307,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid" readonly PRIMARY_DATA_KEY_FILE="none" @@ -351,6 +356,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid" readonly PRIMARY_DATA_KEY_FILE="none" @@ -399,6 +405,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid" readonly PRIMARY_DATA_KEY_FILE="none" @@ -447,6 +454,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="12345678-fake-uuid" readonly PRIMARY_DATA_KEY_FILE="none" diff --git a/tests/integration/test-services.bats b/tests/integration/test-services.bats index ff789e2..bb0fd66 100755 --- a/tests/integration/test-services.bats +++ b/tests/integration/test-services.bats @@ -124,3 +124,59 @@ setup() { run sudo bash -c "source $PROJECT_ROOT/lib/os-utils.sh && stop_service ''" [ "$status" -ne 0 ] } + +@test "SAMBA_SERVICE integration: Service properly managed when configured" { + # This test verifies that when SAMBA_SERVICE is configured in config.local, + # it's properly included in the start_all_services and stop_all_services workflow + + # Backup existing config + [ -f "$PROJECT_ROOT/config.local" ] && cp "$PROJECT_ROOT/config.local" "$PROJECT_ROOT/config.local.test_backup" + + # Create minimal config with SAMBA_SERVICE pointing to our test service + cat > "$PROJECT_ROOT/config.local" </dev/null || true + + # Source srv-ctl and call start_all_services + run sudo bash -c "source $PROJECT_ROOT/config.local && source $PROJECT_ROOT/lib/os-utils.sh && start_all_services" + [ "$status" -eq 0 ] + + # Verify test service is now running (Samba was started) + run sudo systemctl is-active test-dummy-service + [ "$status" -eq 0 ] + + # Call stop_all_services + run sudo bash -c "source $PROJECT_ROOT/config.local && source $PROJECT_ROOT/lib/os-utils.sh && stop_all_services" + [ "$status" -eq 0 ] + + # Verify test service is now stopped (Samba was stopped) + run sudo systemctl is-active test-dummy-service + [ "$status" -ne 0 ] + + # Restore config + [ -f "$PROJECT_ROOT/config.local.test_backup" ] && mv "$PROJECT_ROOT/config.local.test_backup" "$PROJECT_ROOT/config.local" + rm -f "$PROJECT_ROOT/config.local.test_backup" +} diff --git a/tests/system/test-system.sh b/tests/system/test-system.sh index 0ed0edd..2c10d8d 100755 --- a/tests/system/test-system.sh +++ b/tests/system/test-system.sh @@ -458,6 +458,7 @@ readonly ST_SERVICE_1="ssh" readonly ST_USER_2="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" # Primary Data Device (uses test environment) readonly PRIMARY_DATA_UUID="$TEST_LOOP_UUID" @@ -570,6 +571,7 @@ readonly ST_SERVICE_1="none" readonly ST_USER_2="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="none" readonly PRIMARY_DATA_MOUNT="none" readonly PRIMARY_DATA_MAPPER="none" @@ -683,6 +685,7 @@ readonly ST_SERVICE_1="none" readonly ST_USER_2="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="none" readonly PRIMARY_DATA_MOUNT="none" readonly PRIMARY_DATA_MAPPER="none" @@ -834,6 +837,7 @@ readonly ST_SERVICE_1="none" readonly ST_USER_2="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="$TEST_LOOP_UUID" readonly PRIMARY_DATA_KEY_FILE="/tmp/test_key.key" @@ -1098,6 +1102,7 @@ readonly ST_SERVICE_1="none" readonly ST_USER_2="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" +readonly SAMBA_SERVICE="none" readonly PRIMARY_DATA_UUID="$TEST_LOOP_UUID" readonly PRIMARY_DATA_KEY_FILE="/tmp/test_key.key" From 8beca32de499ae898fab257e2d82add6873a8644 Mon Sep 17 00:00:00 2001 From: scienmind Date: Sat, 24 Jan 2026 13:53:28 -0500 Subject: [PATCH 2/2] improve tests --- README.md | 6 + srv-ctl.sh | 4 +- tests/README.md | 4 +- tests/integration/test-services.bats | 10 +- tests/system/test-system.sh | 231 ++++++++++++++++++++++++++- 5 files changed, 238 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9da57ae..4ca548c 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,14 @@ readonly ST_USER_2="bob" # Service names (constructed automatically) readonly ST_SERVICE_1="syncthing@${ST_USER_1}.service" readonly ST_SERVICE_2="syncthing@${ST_USER_2}.service" + +# Additional services (set to "none" to disable) +readonly DOCKER_SERVICE="docker.service" # Manage Docker service +readonly SAMBA_SERVICE="smbd.service" # Manage Samba service (for network shares) ``` +All configured services are started when running `srv-ctl.sh start` and stopped when running `srv-ctl.sh stop`. + ### Storage Device Configuration Each storage device supports: diff --git a/srv-ctl.sh b/srv-ctl.sh index 46bedc1..66d9e26 100755 --- a/srv-ctl.sh +++ b/srv-ctl.sh @@ -4,10 +4,10 @@ # # DESCRIPTION: # Manages encrypted storage devices, LVM volumes, and services for a multi-user -# Syncthing setup with support for LUKS/BitLocker encryption and network shares. +# setup with support for LUKS/BitLocker encryption and network shares. # # FEATURES: -# - Supports 2 parallel Syncthing services with separate users +# - Supports multiple systemd services (Syncthing, Docker, Samba, etc.) # - Manages 5 storage devices (1 primary data + 4 paired storage devices) # - LUKS and BitLocker encryption support via cryptsetup 2.4.0+ # - Optional LVM integration per device diff --git a/tests/README.md b/tests/README.md index 4e82f0f..49e2d4c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -86,7 +86,7 @@ Integration tests cover real storage operations (LUKS, LVM, mount, network share - **test-luks-keyfile.bats**: LUKS key file authentication (valid, missing, unreadable, wrong key, symlink, spaces, error handling) - **test-network-shares.bats**: Network share mounting (CIFS/NFS) with real Samba/NFS servers, credentials, error handling, idempotency, and permission scenarios - **test-bitlocker.bats**: BitLocker encryption support (unlock/lock with key files, error handling, idempotency, integration with srv-ctl.sh) -- **test-services.bats**: Service management edge cases (start/stop, idempotency, error handling for nonexistent/failing services) +- **test-services.bats**: Service management edge cases (start/stop, idempotency, error handling for nonexistent/failing services, SAMBA_SERVICE integration) All integration tests are run in CI via VM on all supported OSes. @@ -94,7 +94,7 @@ All integration tests are run in CI via VM on all supported OSes. System tests validate full CLI workflows using srv-ctl.sh, including device orchestration, service management, and network share mounting. These tests use real services and config patching to simulate production scenarios. -- **test-system.sh**: Covers start/stop/unlock workflows, config validation, error handling, multi-device orchestration (PRIMARY + multiple STORAGE + NETWORK_SHARE), and key file authentication tests as part of the main workflow. +- **test-system.sh**: Covers start/stop/unlock workflows, config validation, error handling, multi-device orchestration (PRIMARY + multiple STORAGE + NETWORK_SHARE), service management (including SAMBA_SERVICE with real smbd), and key file authentication tests as part of the main workflow. All system tests are run in CI via VM on all supported OSes. diff --git a/tests/integration/test-services.bats b/tests/integration/test-services.bats index bb0fd66..6008ab3 100755 --- a/tests/integration/test-services.bats +++ b/tests/integration/test-services.bats @@ -140,7 +140,7 @@ readonly ST_USER_2="none" readonly ST_SERVICE_1="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" -readonly SAMBA_SERVICE="test-dummy-service.service" +readonly SAMBA_SERVICE="test-dummy-service" readonly PRIMARY_DATA_UUID="none" readonly STORAGE_1A_UUID="none" @@ -160,16 +160,16 @@ EOF # Ensure test service is stopped sudo systemctl stop test-dummy-service 2>/dev/null || true - # Source srv-ctl and call start_all_services - run sudo bash -c "source $PROJECT_ROOT/config.local && source $PROJECT_ROOT/lib/os-utils.sh && start_all_services" + # Call start_service for SAMBA_SERVICE + run sudo bash -c "source $PROJECT_ROOT/config.local && source $PROJECT_ROOT/lib/os-utils.sh && start_service \"\$SAMBA_SERVICE\"" [ "$status" -eq 0 ] # Verify test service is now running (Samba was started) run sudo systemctl is-active test-dummy-service [ "$status" -eq 0 ] - # Call stop_all_services - run sudo bash -c "source $PROJECT_ROOT/config.local && source $PROJECT_ROOT/lib/os-utils.sh && stop_all_services" + # Call stop_service for SAMBA_SERVICE + run sudo bash -c "source $PROJECT_ROOT/config.local && source $PROJECT_ROOT/lib/os-utils.sh && stop_service \"\$SAMBA_SERVICE\"" [ "$status" -eq 0 ] # Verify test service is now stopped (Samba was stopped) diff --git a/tests/system/test-system.sh b/tests/system/test-system.sh index 2c10d8d..35db778 100755 --- a/tests/system/test-system.sh +++ b/tests/system/test-system.sh @@ -417,6 +417,132 @@ test_system_double_stop() { fi } +# Test 19: System test - SAMBA_SERVICE management +test_system_samba_service() { + run_test "System: SAMBA_SERVICE management with real smbd service" + + # Check if smbd is available + if ! systemctl list-unit-files | grep -q "smbd.service"; then + log_test "smbd.service not available, skipping SAMBA_SERVICE test" + pass_test "SAMBA_SERVICE test skipped (smbd not installed)" + return 0 + fi + + # Stop smbd initially + sudo systemctl stop smbd 2>/dev/null || true + + # Load test environment to get variables + if [ ! -f /tmp/test_env.conf ]; then + fail_test "Test environment not set up" + return 1 + fi + source /tmp/test_env.conf + + # Create config with SAMBA_SERVICE enabled (use existing config as base) + local key_file="/tmp/test_key.key" + cat > "$PROJECT_ROOT/config.local" <&1) + if [ $? -eq 0 ]; then + if systemctl is-active --quiet smbd; then + pass_test "SAMBA_SERVICE started successfully" + else + fail_test "smbd not running after srv-ctl.sh start" + echo "$start_output" + return 1 + fi + else + fail_test "srv-ctl.sh start failed with SAMBA_SERVICE" + echo "$start_output" + return 1 + fi + + # Stop srv-ctl (should stop smbd) + if sudo bash "$PROJECT_ROOT/srv-ctl.sh" stop &>/dev/null; then + if ! systemctl is-active --quiet smbd; then + pass_test "SAMBA_SERVICE stopped successfully" + else + fail_test "smbd still running after srv-ctl.sh stop" + return 1 + fi + else + fail_test "srv-ctl.sh stop failed with SAMBA_SERVICE" + return 1 + fi + + # Restart smbd for subsequent tests (e.g., network shares) + sudo systemctl start smbd 2>/dev/null || true +} + # Setup system test environment (reuses integration test setup) setup_system_environment() { if [ "$EUID" -ne 0 ]; then @@ -443,6 +569,23 @@ setup_system_environment() { echo -n "$TEST_PASSWORD" > "$key_file" chmod 600 "$key_file" + # Create test service for system tests + sudo tee /etc/systemd/system/test-dummy-service.service > /dev/null <<'EOFSERVICE' +[Unit] +Description=Dummy Test Service for srv-ctl System Tests +After=network.target + +[Service] +Type=oneshot +ExecStart=/bin/true +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +EOFSERVICE + + sudo systemctl daemon-reload + sudo systemctl stop test-dummy-service 2>/dev/null || true # Create system test config that uses the test environment @@ -452,9 +595,9 @@ setup_system_environment() { readonly CRYPTSETUP_MIN_VERSION="2.4.0" -# Services (ST_SERVICE_1 set to 'ssh' for system test) +# Services (ST_SERVICE_1 set to 'test-dummy-service' for system test) readonly ST_USER_1="none" -readonly ST_SERVICE_1="ssh" +readonly ST_SERVICE_1="test-dummy-service" readonly ST_USER_2="none" readonly ST_SERVICE_2="none" readonly DOCKER_SERVICE="none" @@ -527,6 +670,63 @@ readonly NETWORK_SHARE_OWNER_GROUP="none" readonly NETWORK_SHARE_OPTIONS="defaults" EOF + # Start services needed for network share tests + echo "Starting services for network share tests..." + + # Wait for cloud-init to complete (it configures Samba/NFS) + echo "Waiting for cloud-init to complete..." + timeout 120 cloud-init status --wait 2>/dev/null || echo "cloud-init wait timed out or not available" + + # Check and start Samba if available + if systemctl list-unit-files | grep -q "smbd.service"; then + echo "Found smbd.service, checking status..." + if ! systemctl is-active --quiet smbd 2>/dev/null; then + echo "Starting smbd service..." + if sudo systemctl start smbd 2>&1 | tee /tmp/smbd-start.log; then + echo "smbd start command succeeded" + else + log_fail "Warning: smbd start command failed:" + cat /tmp/smbd-start.log + sudo systemctl status smbd || true + fi + fi + if systemctl is-active --quiet smbd; then + echo "✓ smbd service is running" + else + log_fail "Warning: smbd service not running - CIFS tests may fail" + sudo systemctl status smbd || true + fi + else + log_fail "Warning: smbd.service not found - CIFS tests will be skipped" + echo "Available samba-related units:" + systemctl list-unit-files | grep -i smb || echo "None found" + fi + + # Check and start NFS if available + if systemctl list-unit-files | grep -q "nfs-server.service"; then + echo "Found nfs-server.service, checking status..." + if ! systemctl is-active --quiet nfs-server 2>/dev/null; then + echo "Starting nfs-server..." + if sudo systemctl start nfs-server 2>&1 | tee /tmp/nfs-start.log; then + echo "nfs-server start command succeeded" + else + log_fail "Warning: nfs-server start command failed:" + cat /tmp/nfs-start.log + sudo systemctl status nfs-server || true + fi + fi + if systemctl is-active --quiet nfs-server; then + echo "✓ nfs-server is running" + else + log_fail "Warning: nfs-server not running - NFS tests may fail" + sudo systemctl status nfs-server || true + fi + else + log_fail "Warning: nfs-server.service not found - NFS tests will be skipped" + echo "Available nfs-related units:" + systemctl list-unit-files | grep -i nfs || echo "None found" + fi + log_pass "System test environment setup complete" return 0 else @@ -541,6 +741,11 @@ cleanup_system_environment() { # Ensure everything is stopped/unmounted sudo bash "$PROJECT_ROOT/srv-ctl.sh" stop &>/dev/null || true + # Cleanup test service + sudo systemctl stop test-dummy-service 2>/dev/null || true + sudo rm -f /etc/systemd/system/test-dummy-service.service + sudo systemctl daemon-reload 2>/dev/null || true + # Cleanup integration test environment if [ -f "$PROJECT_ROOT/tests/fixtures/cleanup-test-env.sh" ]; then sudo bash "$PROJECT_ROOT/tests/fixtures/cleanup-test-env.sh" &>/dev/null || true @@ -557,10 +762,13 @@ test_network_share_system_workflows() { echo "" # --- CIFS (Samba) --- - echo "[Setup] Verifying Samba test server (configured via cloud-init)..." + echo "[Setup] Verifying Samba test server..." if ! systemctl is-active --quiet smbd 2>/dev/null; then - echo "[WARN] Samba service not running, tests may fail" - fi + log_fail "ERROR: smbd service not running. CIFS tests cannot proceed." + log_fail " This indicates a test environment setup failure." + fail_test "CIFS tests skipped - smbd not running" + # Skip CIFS tests but continue to NFS + else # Patch config.local for CIFS cat > "$PROJECT_ROOT/config.local" </dev/null; then - echo "[WARN] NFS service not running, tests may fail" - fi + log_fail "ERROR: nfs-server not running. NFS tests cannot proceed." + log_fail " This indicates a test environment setup failure." + fail_test "NFS tests skipped - nfs-server not running" + # Skip NFS tests + else # Patch config.local for NFS cat > "$PROJECT_ROOT/config.local" <