/ test-sync-behavior-complete.sh
test-sync-behavior-complete.sh
1 #!/bin/bash 2 3 echo "๐งช COMPREHENSIVE SYNC BEHAVIOR TEST" 4 echo "===================================" 5 6 # Clean up any existing files 7 echo "๐งน Cleaning up existing files..." 8 rm -f /home/master/keepsync-files/* 9 sudo systemctl stop keepsync 2>/dev/null || true 10 11 # Create test files 12 echo "๐ Creating test files..." 13 echo "This is test file 1" > /home/master/keepsync-files/test1.txt 14 echo "This is test file 2" > /home/master/keepsync-files/test2.txt 15 echo "This is test file 3" > /home/master/keepsync-files/test3.txt 16 17 echo "๐ Local files created:" 18 ls -la /home/master/keepsync-files/ 19 20 # Test 1: Upload files using KeepSync CLI 21 echo "" 22 echo "๐ Test 1: Uploading files to remote storage..." 23 go run cmd/keepsync/main.go sync /home/master/keepsync-files keepsync-files --provider s3 24 25 # Verify upload 26 echo "" 27 echo "๐ Verifying files uploaded to S3..." 28 aws s3 ls s3://storage-a01/keepsync-files/ --recursive --endpoint-url https://s3.filebase.com 29 30 # Test 2: Delete a local file and test sync behavior 31 echo "" 32 echo "๐๏ธ Test 2: Deleting test1.txt locally..." 33 rm /home/master/keepsync-files/test1.txt 34 echo "๐ Local files after deletion:" 35 ls -la /home/master/keepsync-files/ 36 37 # Test sync behavior - should delete remote file, not re-download 38 echo "" 39 echo "๐ Testing sync behavior after local deletion..." 40 go run cmd/keepsync/main.go sync /home/master/keepsync-files keepsync-files --provider s3 --bidirectional --delete 41 42 # Verify the file was deleted remotely and not re-downloaded 43 echo "" 44 echo "๐ Checking remote files after sync..." 45 aws s3 ls s3://storage-a01/keepsync-files/ --recursive --endpoint-url https://s3.filebase.com 46 47 echo "" 48 echo "๐ Checking local files after sync..." 49 ls -la /home/master/keepsync-files/ 50 51 # Test 3: Create a new file and sync 52 echo "" 53 echo "๐ Test 3: Creating new file and syncing..." 54 echo "This is a new test file" > /home/master/keepsync-files/new-file.txt 55 56 echo "๐ Syncing new file..." 57 go run cmd/keepsync/main.go sync /home/master/keepsync-files keepsync-files --provider s3 58 59 # Test 4: Delete all local files and test download behavior 60 echo "" 61 echo "๐๏ธ Test 4: Deleting all local files..." 62 rm -f /home/master/keepsync-files/* 63 echo "๐ Local directory is now empty:" 64 ls -la /home/master/keepsync-files/ 65 66 echo "" 67 echo "๐ Testing download behavior with empty local directory..." 68 go run cmd/keepsync/main.go sync /home/master/keepsync-files keepsync-files --provider s3 --bidirectional 69 70 echo "" 71 echo "๐ Local files after download:" 72 ls -la /home/master/keepsync-files/ 73 74 echo "" 75 echo "๐ Final remote state:" 76 aws s3 ls s3://storage-a01/keepsync-files/ --recursive --endpoint-url https://s3.filebase.com 77 78 echo "" 79 echo "โ SYNC BEHAVIOR TEST COMPLETED!" 80 echo "================================" 81 echo "Expected results:" 82 echo "- test1.txt should be deleted from remote (not re-downloaded)" 83 echo "- test2.txt and test3.txt should remain" 84 echo "- new-file.txt should be uploaded and then downloaded" 85 echo "- No files should reappear after being deleted"