# DocWell Testing Guide This document provides specific test scenarios for using the test-stack with DocWell. ## Prerequisites 1. Install the test stack: ```bash cd test-stack ./setup.sh ``` 2. Ensure DocWell is built: ```bash cd go go build -o docwell docwell.go ``` ## Test Scenarios ### 1. Stack Management Tests #### Test: List Stacks ```bash ./docwell --stack-list ``` **Expected**: Should show `test-stack` with status (running/stopped) #### Test: Start Stack ```bash ./docwell --stack-start test-stack ``` **Expected**: Stack starts, container runs, web interface accessible at http://localhost:8080 #### Test: Check Status ```bash ./docwell --stack-status test-stack ``` **Expected**: Outputs "running" or "stopped" #### Test: View Logs ```bash ./docwell --stack-logs test-stack ``` **Expected**: Shows Nginx logs #### Test: Restart Stack ```bash ./docwell --stack-restart test-stack ``` **Expected**: Stack restarts, service remains available #### Test: Stop Stack ```bash ./docwell --stack-stop test-stack ``` **Expected**: Stack stops, container removed, port 8080 no longer accessible ### 2. Backup Tests #### Test: Backup Single Stack ```bash ./docwell --backup-stack test-stack ``` **Expected**: - Creates backup in configured backup directory - Backup file: `docker-//docker-test-stack.tar.zst` - Stack restarts if it was running #### Test: List Stacks for Backup ```bash ./docwell --backup-list ``` **Expected**: Lists all stacks with their status #### Test: Backup All Stacks ```bash ./docwell --backup ``` **Expected**: Backs up all stacks including test-stack ### 3. Update Tests #### Test: Check for Updates ```bash ./docwell --update-check ``` **Expected**: Shows update status for nginx:alpine image #### Test: Update Single Stack ```bash ./docwell --update-stack test-stack ``` **Expected**: - Pulls latest nginx:alpine image - Recreates container if stack was running - Service continues to work #### Test: Update All Stacks ```bash ./docwell --update-all ``` **Expected**: Updates all stacks including test-stack ### 4. Cleanup Tests #### Test: Cleanup Containers ```bash # Stop the stack first ./docwell --stack-stop test-stack ./docwell --cleanup-containers ``` **Expected**: Removes stopped containers #### Test: Cleanup Images ```bash ./docwell --cleanup-images ``` **Expected**: Removes unused images (may remove old nginx images) #### Test: Cleanup Volumes ```bash ./docwell --cleanup-volumes ``` **Expected**: Removes unused volumes (be careful - this removes data!) ### 5. Migration Tests #### Test: Migrate to Another Server (Clone Mode) ```bash ./docwell --migrate \ --migrate-service test-stack \ --migrate-source local \ --migrate-dest user@remote-host \ --migrate-method rsync ``` **Expected**: - Creates backup of config and volumes - Transfers to destination - Starts service on destination - Original service keeps running #### Test: Migrate (Transfer Mode) ```bash ./docwell --migrate \ --migrate-service test-stack \ --migrate-source local \ --migrate-dest user@remote-host \ --migrate-method rsync \ --migrate-transfer ``` **Expected**: - Stops service on source - Transfers everything - Starts on destination - Source service is stopped ### 6. Interactive Mode Tests #### Test: Interactive Backup ```bash ./docwell # Select option 1 (Backup Stacks) # Select test-stack ``` **Expected**: Interactive menu works, backup completes #### Test: Interactive Stack Manager ```bash ./docwell # Select option 4 (Stack Manager) # Select test-stack # Try start/stop/restart/update/logs ``` **Expected**: All operations work through interactive menu ## Verification Steps After each test, verify: 1. **Service Status**: ```bash docker compose -f /opt/stacks/test-stack/compose.yaml ps ``` 2. **Web Interface**: ```bash curl http://localhost:8080 # Should return HTML content ``` 3. **Volume Exists**: ```bash docker volume ls | grep test-stack ``` 4. **Backup Created**: ```bash ls -lh /storage/backups/docker-*/$(date +%Y-%m-%d)/ ``` ## Troubleshooting ### Port Already in Use If port 8080 is in use, edit `compose.yaml`: ```yaml ports: - "8081:80" # Change port ``` ### Permission Denied ```bash sudo chown -R $USER:$USER /opt/stacks/test-stack ``` ### Container Won't Start ```bash cd /opt/stacks/test-stack docker compose logs docker compose up -d ``` ### Backup Fails - Check backup directory permissions - Ensure enough disk space - Check logs: `tail -f /var/log/docwell.log` ## Test Checklist - [ ] Stack listing works - [ ] Start/stop/restart operations work - [ ] Status checking works - [ ] Log viewing works - [ ] Backup creates valid archive - [ ] Update pulls new images - [ ] Cleanup removes unused resources - [ ] Migration transfers correctly - [ ] Interactive mode works - [ ] Web interface accessible after operations ## Performance Testing For stress testing: 1. **Multiple Stacks**: Create several test stacks 2. **Parallel Operations**: Run multiple operations simultaneously 3. **Large Volumes**: Add data to volumes to test transfer speeds 4. **Network Testing**: Test migration over slow networks ## Cleanup After Testing ```bash # Stop and remove stack cd /opt/stacks/test-stack docker compose down -v # Remove directory sudo rm -rf /opt/stacks/test-stack # Clean up backups (optional) rm -rf /storage/backups/docker-*/$(date +%Y-%m-%d)/docker-test-stack.tar.zst ```