From 660f3ccb629eb733a530433fce3c4e68629880d0 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 19 May 2023 07:36:15 -0600 Subject: [PATCH 1/5] Implement volume control --- app/deploy_system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/deploy_system.py b/app/deploy_system.py index 5b1341c4..d4dcc36f 100644 --- a/app/deploy_system.py +++ b/app/deploy_system.py @@ -75,7 +75,7 @@ def up(ctx, extra_args): @command.command() -@click.option("--delete-volumes", default=False, help="delete data volumes") +@click.option("--delete-volumes/--preserve-volumes", default=False, help="delete data volumes") @click.argument('extra_args', nargs=-1) # help: command: down @click.pass_context def down(ctx, delete_volumes, extra_args): @@ -88,7 +88,7 @@ def down(ctx, delete_volumes, extra_args): if extra_args_list: timeout_arg = extra_args_list[0] # Specify shutdown timeout (default 10s) to give services enough time to shutdown gracefully - ctx.obj.docker.compose.down(timeout=timeout_arg) + ctx.obj.docker.compose.down(timeout=timeout_arg, volumes=delete_volumes) @command.command() -- 2.45.2 From aa702737eff5762882232d0e1f1ac589bdf10481 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Fri, 19 May 2023 11:26:09 -0500 Subject: [PATCH 2/5] Fix 397 by pegging alpine version. --- app/data/container-build/cerc-fixturenet-eth-geth/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/data/container-build/cerc-fixturenet-eth-geth/Dockerfile b/app/data/container-build/cerc-fixturenet-eth-geth/Dockerfile index 63c3c0a7..666f9117 100644 --- a/app/data/container-build/cerc-fixturenet-eth-geth/Dockerfile +++ b/app/data/container-build/cerc-fixturenet-eth-geth/Dockerfile @@ -6,7 +6,7 @@ RUN go install github.com/go-delve/delve/cmd/dlv@latest FROM cerc/go-ethereum:local as geth -FROM alpine:latest +FROM alpine:3.17 RUN apk add --no-cache python3 python3-dev py3-pip curl wget jq build-base gettext libintl openssl bash bind-tools postgresql-client COPY --from=delve /go/bin/dlv /usr/local/bin/ -- 2.45.2 From 982052bf873790c0aa9a27a5606c567a89f77288 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 19 May 2023 13:35:31 -0600 Subject: [PATCH 3/5] Deploy test --- tests/deploy/run-deploy-test.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 tests/deploy/run-deploy-test.sh diff --git a/tests/deploy/run-deploy-test.sh b/tests/deploy/run-deploy-test.sh new file mode 100755 index 00000000..7d9bc0d6 --- /dev/null +++ b/tests/deploy/run-deploy-test.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi +# Dump environment variables for debugging +echo "Environment variables:" +env +# Test basic stack-orchestrator deploy +echo "Running stack-orchestrator deploy test" +# Bit of a hack, test the most recent package +TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 ) +# Set a non-default repo dir +export CERC_REPO_BASE_DIR=~/stack-orchestrator-test/repo-base-dir +echo "Testing this package: $TEST_TARGET_SO" +echo "Test version command" +reported_version_string=$( $TEST_TARGET_SO version ) +echo "Version reported is: ${reported_version_string}" +echo "Cloning repositories into: $CERC_REPO_BASE_DIR" +rm -rf $CERC_REPO_BASE_DIR +mkdir -p $CERC_REPO_BASE_DIR +# Test pulling a stack +$TEST_TARGET_SO --stack test setup-repositories +# Test building the a stack container +$TEST_TARGET_SO --stack test build-containers +$TEST_TARGET_SO --stack test deploy-system up +# TODO: test that we can use the deployed container somehow +# Clean up +$TEST_TARGET_SO --stack test deploy-system down +echo "Test passed" -- 2.45.2 From 80ecf6342548d5c7049db5fa9f056f4c33a5e31c Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 21 May 2023 07:33:48 -0600 Subject: [PATCH 4/5] Add test for volumes --- tests/deploy/run-deploy-test.sh | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/tests/deploy/run-deploy-test.sh b/tests/deploy/run-deploy-test.sh index 7d9bc0d6..291799a4 100755 --- a/tests/deploy/run-deploy-test.sh +++ b/tests/deploy/run-deploy-test.sh @@ -19,12 +19,30 @@ echo "Version reported is: ${reported_version_string}" echo "Cloning repositories into: $CERC_REPO_BASE_DIR" rm -rf $CERC_REPO_BASE_DIR mkdir -p $CERC_REPO_BASE_DIR -# Test pulling a stack +# Test bringing the test container up and down +# with and without volume removal $TEST_TARGET_SO --stack test setup-repositories -# Test building the a stack container $TEST_TARGET_SO --stack test build-containers -$TEST_TARGET_SO --stack test deploy-system up -# TODO: test that we can use the deployed container somehow -# Clean up -$TEST_TARGET_SO --stack test deploy-system down +$TEST_TARGET_SO --stack test deploy up +$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) +$TEST_TARGET_SO --stack test deploy up +log_output_1=$( $TEST_TARGET_SO --stack test deploy logs ) +if [[ "$log_output_1" == *"Filesystem is old"* ]]; then + echo "Retain volumes test: passed" +else + echo "Retain volumes test: FAILED" + exit 1 +fi +$TEST_TARGET_SO --stack test deploy down --delete-volumes +# Now when we bring the container up the volume will be new again +$TEST_TARGET_SO --stack test deploy up +log_output_2=$( $TEST_TARGET_SO --stack test deploy logs ) +if [[ "$log_output_2" == *"Filesystem is fresh"* ]]; then + echo "Delete volumes test: passed" +else + echo "Delete volumes test: FAILED" + exit 1 +fi +$TEST_TARGET_SO --stack test deploy down --delete-volumes echo "Test passed" -- 2.45.2 From bec2872096d41a09ac58fd02585ab6248a76696b Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sun, 21 May 2023 07:38:35 -0600 Subject: [PATCH 5/5] Enable CI for deploy test --- .gitea/workflows/test-deploy.yml | 39 +++++++++++++++++++++++++++++++ .github/workflows/test-deploy.yml | 29 +++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .gitea/workflows/test-deploy.yml create mode 100644 .github/workflows/test-deploy.yml diff --git a/.gitea/workflows/test-deploy.yml b/.gitea/workflows/test-deploy.yml new file mode 100644 index 00000000..a3e8d20e --- /dev/null +++ b/.gitea/workflows/test-deploy.yml @@ -0,0 +1,39 @@ +name: Deploy Test + +on: + pull_request: + branches: '*' + push: + branches: + - main + - ci-test + +# Needed until we can incorporate docker startup into the executor container +env: + DOCKER_HOST: unix:///var/run/dind.sock + +jobs: + test: + name: "Run deploy test suite" + runs-on: ubuntu-latest + steps: + - name: "Clone project repository" + uses: actions/checkout@v3 + - name: "Install Python" + uses: cerc-io/setup-python@v4 + with: + python-version: '3.8' + - name: "Print Python version" + run: python3 --version + - name: "Install shiv" + run: pip install shiv + - name: "Generate build version file" + run: ./scripts/create_build_tag_file.sh + - name: "Build local shiv package" + run: ./scripts/build_shiv_package.sh + - name: Start dockerd # Also needed until we can incorporate into the executor + run: | + dockerd -H $DOCKER_HOST --userland-proxy=false & + sleep 5 + - name: "Run smoke tests" + run: ./tests/deploy-test/run-smoke-test.sh diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml new file mode 100644 index 00000000..71a764d4 --- /dev/null +++ b/.github/workflows/test-deploy.yml @@ -0,0 +1,29 @@ +name: Deploy Test + +on: + pull_request: + branches: '*' + push: + branches: '*' + +jobs: + test: + name: "Run deploy test suite" + runs-on: ubuntu-latest + steps: + - name: "Clone project repository" + uses: actions/checkout@v3 + - name: "Install Python" + uses: actions/setup-python@v4 + with: + python-version: '3.8' + - name: "Print Python version" + run: python3 --version + - name: "Install shiv" + run: pip install shiv + - name: "Generate build version file" + run: ./scripts/create_build_tag_file.sh + - name: "Build local shiv package" + run: ./scripts/build_shiv_package.sh + - name: "Run smoke tests" + run: ./tests/deploy-test/run-smoke-test.sh -- 2.45.2