From d5c858e0b9ac0daa0d8744100f2ff8253f0caaeb Mon Sep 17 00:00:00 2001 From: David Boreham Date: Mon, 31 Jul 2023 14:18:52 -0600 Subject: [PATCH] Add a basic deployment test --- app/deployment_create.py | 2 +- tests/deploy/run-deploy-test.sh | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/deployment_create.py b/app/deployment_create.py index bafb46cd..af5eefb2 100644 --- a/app/deployment_create.py +++ b/app/deployment_create.py @@ -209,7 +209,7 @@ def create(ctx, spec_file, deployment_dir): # stack member here. deployment_command_context = ctx.obj deployment_command_context.stack = stack_name - deployment_context = DeploymentContext(Path(deployment_dir), ctx.obj) + deployment_context = DeploymentContext(Path(deployment_dir), deployment_command_context) call_stack_deploy_create(deployment_context) diff --git a/tests/deploy/run-deploy-test.sh b/tests/deploy/run-deploy-test.sh index 70eb0e18..9054384f 100755 --- a/tests/deploy/run-deploy-test.sh +++ b/tests/deploy/run-deploy-test.sh @@ -26,17 +26,18 @@ $TEST_TARGET_SO --stack test build-containers # Test deploy command execution $TEST_TARGET_SO --stack test deploy setup $CERC_REPO_BASE_DIR # Check that we now have the expected output directory -if [ ! -d "$CERC_REPO_BASE_DIR/container-output-dir" ]; then +container_output_dir=$CERC_REPO_BASE_DIR/container-output-dir +if [ ! -d "$container_output_dir" ]; then echo "deploy setup test: output directory not present" echo "deploy setup test: FAILED" exit 1 fi -if [ ! -f "$CERC_REPO_BASE_DIR/container-output-dir/output-file" ]; then +if [ ! -f "$container_output_dir/output-file" ]; then echo "deploy setup test: output file not present" echo "deploy setup test: FAILED" exit 1 fi -output_file_content=$(<$CERC_REPO_BASE_DIR/container-output-dir/output-file) +output_file_content=$(<$container_output_dir/output-file) if [ ! "$output_file_content" == "output-data" ]; then echo "deploy setup test: output file contents not correct" echo "deploy setup test: FAILED" @@ -73,4 +74,25 @@ 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 +$TEST_TARGET_SO --stack test deploy init --output $test_deployment_spec +# Check the file now exists +if [ ! -f "$test_deployment_spec" ]; then + echo "deploy init test: spec file not present" + echo "deploy init test: FAILED" + exit 1 +fi +$TEST_TARGET_SO deploy create --spec-file $test_deployment_spec --deployment-dir $test_deployment_dir +# Check the deployment dir exists +if [ ! -d "$test_deployment_dir" ]; then + echo "deploy create test: deployment directory not present" + echo "deploy create test: FAILED" + exit 1 +fi +# Try to start the deployment +$TEST_TARGET_SO deployment --dir $test_deployment_dir start +# Stop and clean up +$TEST_TARGET_SO deployment --dir $test_deployment_dir stop --delete-volumes echo "Test passed"