Compare commits
4 Commits
5e7edd31db
...
ddbf93bcda
| Author | SHA1 | Date |
|---|---|---|
|
|
ddbf93bcda | |
|
|
693259473e | |
|
|
d0041bc820 | |
|
|
a96dd88477 |
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue