Compare commits

..

4 Commits

Author SHA1 Message Date
Roy Crihfield ddbf93bcda Merge branch 'deploy-create-sync' into vaasl-deploy
Lint Checks / Run linter (push) Failing after 2s Details
Database Test / Run database hosting test on kind/k8s (push) Failing after 2s Details
2025-10-19 21:16:07 +08:00
Roy Crihfield 693259473e Check the deployment dir exists when syncing 2025-10-19 21:14:49 +08:00
Roy Crihfield d0041bc820 fix test 2025-10-19 19:52:46 +08:00
Roy Crihfield a96dd88477 misc test improvement 2025-10-19 19:52:33 +08:00
3 changed files with 6 additions and 38 deletions

View File

@ -472,6 +472,8 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, sync
if opts.o.debug:
print(f"Syncing existing deployment at {deployment_dir_path}")
else:
if sync:
error_exit(f"--sync requires that {deployment_dir_path} already exists")
os.mkdir(deployment_dir_path)
# Copy spec file and the stack file into the deployment dir
copyfile(spec_file, deployment_dir_path.joinpath(constants.spec_file_name))

View File

@ -86,7 +86,7 @@ fi
echo "deploy init test: passed"
# Switch to a full path for the data dir so it gets provisioned as a host bind mounted volume and preserved beyond cluster lifetime
sed -i "s|^\(\s*db-data:$\)$|\1 ${test_deployment_dir}/data/db-data|" $test_deployment_spec
sed -i.bak "s|^\(\s*db-data:$\)$|\1 ${test_deployment_dir}/data/db-data|" $test_deployment_spec
$TEST_TARGET_SO --stack ${stack} deploy create --spec-file $test_deployment_spec --deployment-dir $test_deployment_dir
# Check the deployment dir exists
@ -97,41 +97,6 @@ if [ ! -d "$test_deployment_dir" ]; then
fi
echo "deploy create test: passed"
# Test sync functionality: update deployment without destroying data
# Create a marker file in the database data directory to verify it's preserved
test_data_marker="$test_deployment_dir/data/db-data/sync-test-marker.txt"
mkdir -p "$test_deployment_dir/data/db-data"
echo "db-marker-$(date +%s)" > "$test_data_marker"
original_marker_content=$(<$test_data_marker)
# Save current timestamp of deployment file to verify it gets preserved
if [ -f "$test_deployment_dir/deployment.yml" ]; then
original_deployment_file_time=$(stat -c %Y "$test_deployment_dir/deployment.yml" 2>/dev/null || stat -f %m "$test_deployment_dir/deployment.yml")
fi
# Modify spec to simulate an update
echo " test-annotation: sync-update" >> $test_deployment_spec
# Run sync to update deployment files without destroying data
$TEST_TARGET_SO --stack ${stack} deploy create --spec-file $test_deployment_spec --deployment-dir $test_deployment_dir --sync
# Verify the data marker file still exists with original content
if [ ! -f "$test_data_marker" ]; then
echo "deploy sync test: database data marker deleted - FAILED"
exit 1
fi
synced_marker_content=$(<$test_data_marker)
if [ "$synced_marker_content" == "$original_marker_content" ]; then
echo "deploy sync test: database data preserved - passed"
else
echo "deploy sync test: database data corrupted - FAILED"
exit 1
fi
# Verify compose files were updated (should have newer timestamp)
if [ -f "$test_deployment_dir/compose/docker-compose-${stack}.yml" ]; then
echo "deploy sync test: compose files present - passed"
else
echo "deploy sync test: compose files missing - FAILED"
exit 1
fi
echo "deploy sync test: passed"
# Try to start the deployment
$TEST_TARGET_SO deployment --dir $test_deployment_dir start
wait_for_pods_started

View File

@ -85,6 +85,7 @@ else
exit 1
fi
$TEST_TARGET_SO --stack test deploy down --delete-volumes
# Basic test of creating a deployment
test_deployment_dir=$CERC_REPO_BASE_DIR/test-deployment-dir
test_deployment_spec=$CERC_REPO_BASE_DIR/test-deployment-spec.yml
@ -125,12 +126,12 @@ echo "deploy create output file test: passed"
# Test sync functionality: update deployment without destroying data
# First, create a marker file in the data directory to verify it's preserved
test_data_marker="$test_deployment_dir/data/test-data/sync-test-marker.txt"
mkdir -p "$test_deployment_dir/data/test-data"
test_data_marker="$test_deployment_dir/data/test-data-bind/sync-test-marker.txt"
echo "original-data-$(date +%s)" > "$test_data_marker"
original_marker_content=$(<$test_data_marker)
# Also save original spec content to compare
original_spec_content=$(<$test_deployment_spec)
# Modify spec file to simulate an update
sed -i.bak 's/CERC_TEST_PARAM_3:/CERC_TEST_PARAM_3: FASTER/' $test_deployment_spec
# Run sync to update deployment files without destroying data