Fix deploy commands (#404)

* Fix bugs

* Add test for deploy port command
This commit is contained in:
David Boreham 2023-05-23 02:43:59 +08:00 committed by GitHub
parent 9c5f6469ff
commit 161665ef72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 6 deletions

View File

@ -35,5 +35,5 @@ jobs:
run: | run: |
dockerd -H $DOCKER_HOST --userland-proxy=false & dockerd -H $DOCKER_HOST --userland-proxy=false &
sleep 5 sleep 5
- name: "Run smoke tests" - name: "Run deploy tests"
run: ./tests/deploy/run-deploy-test.sh run: ./tests/deploy/run-deploy-test.sh

View File

@ -25,5 +25,5 @@ jobs:
run: ./scripts/create_build_tag_file.sh run: ./scripts/create_build_tag_file.sh
- name: "Build local shiv package" - name: "Build local shiv package"
run: ./scripts/build_shiv_package.sh run: ./scripts/build_shiv_package.sh
- name: "Run smoke tests" - name: "Run deploy tests"
run: ./tests/deploy/run-deploy-test.sh run: ./tests/deploy/run-deploy-test.sh

View File

@ -67,11 +67,11 @@ def up(ctx, extra_args):
if global_context.verbose: if global_context.verbose:
print(f"Running compose up with container_exec_env: {container_exec_env}, extra_args: {extra_args_list}") print(f"Running compose up with container_exec_env: {container_exec_env}, extra_args: {extra_args_list}")
for pre_start_command in cluster_context.pre_start_commands: for pre_start_command in cluster_context.pre_start_commands:
_run_command(ctx.obj, cluster_context.cluster, pre_start_command) _run_command(global_context, cluster_context.cluster, pre_start_command)
ctx.obj.docker.compose.up(detach=True, services=extra_args_list) ctx.obj.docker.compose.up(detach=True, services=extra_args_list)
for post_start_command in cluster_context.post_start_commands: for post_start_command in cluster_context.post_start_commands:
_run_command(ctx.obj, cluster_context.cluster, post_start_command) _run_command(global_context, cluster_context.cluster, post_start_command)
_orchestrate_cluster_config(ctx.obj, cluster_context.config, ctx.obj.docker, container_exec_env) _orchestrate_cluster_config(global_context, cluster_context.config, ctx.obj.docker, container_exec_env)
@command.command() @command.command()
@ -130,7 +130,7 @@ def port(ctx, extra_args):
sys.exit(1) sys.exit(1)
service_name = extra_args_list[0] service_name = extra_args_list[0]
exposed_port = extra_args_list[1] exposed_port = extra_args_list[1]
if ctx.parent.obj.verbose: if global_context.verbose:
print(f"Running compose port {service_name} {exposed_port}") print(f"Running compose port {service_name} {exposed_port}")
mapped_port_data = ctx.obj.docker.compose.port(service_name, exposed_port) mapped_port_data = ctx.obj.docker.compose.port(service_name, exposed_port)
print(f"{mapped_port_data[0]}:{mapped_port_data[1]}") print(f"{mapped_port_data[0]}:{mapped_port_data[1]}")

View File

@ -24,6 +24,14 @@ mkdir -p $CERC_REPO_BASE_DIR
$TEST_TARGET_SO --stack test setup-repositories $TEST_TARGET_SO --stack test setup-repositories
$TEST_TARGET_SO --stack test build-containers $TEST_TARGET_SO --stack test build-containers
$TEST_TARGET_SO --stack test deploy up $TEST_TARGET_SO --stack test deploy up
# Test deploy port command
deploy_port_output=$( $TEST_TARGET_SO --stack test deploy port test 80 )
if [[ "$deploy_port_output" =~ ^0.0.0.0:[1-9][0-9]* ]]; then
echo "Deploy port test: passed"
else
echo "Deploy port test: FAILED"
exit 1
fi
$TEST_TARGET_SO --stack test deploy down $TEST_TARGET_SO --stack test deploy down
# The next time we bring the container up the volume will be old (from the previous run above) # The next time we bring the container up the volume will be old (from the previous run above)
$TEST_TARGET_SO --stack test deploy up $TEST_TARGET_SO --stack test deploy up