Skip to content

Commit

Permalink
Add "Docker compose smoke test" step
Browse files Browse the repository at this point in the history
  • Loading branch information
Github Action committed Jun 28, 2024
1 parent 939b7b5 commit 79ffaa5
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 30 deletions.
89 changes: 60 additions & 29 deletions .buildkite/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,65 @@ steps:
agents:
system: x86_64-linux

- label: 'Build package (linux)'
key: linux-package
depends_on: add-release-commits
command:
- ./scripts/buildkite/release/linux-package.sh
artifact_paths: [ "./result/linux/**" ]
agents:
system: x86_64-linux
- group: "Linux E2E"
key: "linux-e2e"
steps:
- block: 'Linux build and test'
depends_on: add-release-commits
key: linux-block
if: build.branch != "master"

- label: 'Build Docker Image'
key: build-docker
depends_on:
- add-release-commits
commands:
./scripts/buildkite/release/docker-build.sh
agents:
system: x86_64-linux
- label: 'Build package (linux)'
key: linux-package
depends_on:
- add-release-commits
- linux-block
command:
- ./scripts/buildkite/release/linux-package.sh
artifact_paths: [ "./result/linux/**" ]
agents:
system: x86_64-linux

- label: 'Run linux e2e tests'
depends_on:
- add-release-commits
- linux-package
commands: |
./scripts/buildkite/release/linux-e2e.sh
artifact_paths:
- "./result/linux/**"
- "./logs/**/*"
env:
NODE_STATE_DIR: "${STATE_DIR?}/node/preprod"
agents:
system: x86_64-linux
- label: 'Run linux e2e tests'
depends_on:
- linux-package
commands: |
./scripts/buildkite/release/linux-e2e.sh
artifact_paths:
- "./result/linux/**"
- "./logs/**/*"
env:
NODE_STATE_DIR: "${STATE_DIR?}/node/preprod"
agents:
system: x86_64-linux

- group: "Docker E2E"
key: "docker-e2e"
steps:
- block: 'Docker build and test'
depends_on: add-release-commits
key: docker-block
if: build.branch != "master"

- label: 'Build Docker Image'
key: build-docker
depends_on:
- add-release-commits
- docker-block
commands:
./scripts/buildkite/release/docker-build.sh
agents:
system: x86_64-linux

- label: 'Smoke test docker-compose'
depends_on:
- build-docker
timeout_in_minutes: 2
commands:
- ./scripts/buildkite/release/docker-smoke-test.sh
artifact_paths:
- "./logs/*"
env:
NODE_STATE_DIR: "${STATE_DIR?}/node/preprod"
agents:
system: x86_64-linux
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
- node-ipc:/ipc
- ./configs/cardano:/configs
restart: on-failure
user: ${USER_ID}
logging:
driver: "json-file"
options:
Expand Down Expand Up @@ -40,6 +41,7 @@ services:
environment:
CMD: "cardano-wallet serve --node-socket /ipc/node.socket --database /wallet-db --listen-address 0.0.0.0"
NETWORK:
user: ${USER_ID}
restart: on-failure
logging:
driver: "json-file"
Expand Down
50 changes: 50 additions & 0 deletions scripts/buildkite/release/docker-smoke-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#! /usr/bin/env -S nix shell 'nixpkgs#docker-compose' 'nixpkgs#rsync' 'nixpkgs#jq' --command bash
# shellcheck shell=bash

set -euox pipefail


NETWORK=preprod
export NETWORK

TESTS_NODE_DB="$(pwd)/state/node_db"
mkdir -p "$TESTS_NODE_DB"
export TESTS_NODE_DB

rsync -a --delete "$NODE_STATE_DIR/db/" "$TESTS_NODE_DB"

WALLET_TAG=$(buildkite-agent meta-data get "release-cabal-version")
export WALLET_TAG

NODE_TAG="8.9.3"
export NODE_TAG

NODE_DB="$TESTS_NODE_DB"
export NODE_DB

WALLET_DB="$(pwd)/state/wallet_db"
mkdir -p "$WALLET_DB"
export WALLET_DB

WALLET_PORT=$(shuf -i 2000-65000 -n 1)
export WALLET_PORT

USER_ID=$(id -u)
export USER_ID

docker-compose up -d

n=0
while :
do
result=$(curl --connect-timeout 1 localhost:$WALLET_PORT/v2/network/information || echo wait)
echo $result
[[ $result != "wait" ]] && break || ((n++))
(( n >= 20 )) && break
done

echo $result | jq

mkdir -p logs
docker-compose logs > logs/docker-compose.log
docker-compose down
2 changes: 2 additions & 0 deletions scripts/buildkite/release/linux-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ TESTS_E2E_FIXTURES="$FIXTURE_DECRYPTION_KEY"

export TESTS_E2E_FIXTURES

pkill screen

nix develop -c rake "run_on[preprod,sync,true]" # SPEC_OPTS="-e '<match>'"

rm "$tmpfile"
7 changes: 6 additions & 1 deletion scripts/buildkite/release/release-candidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ OLD_CABAL_VERSION=$(tag_cabal_ver "$OLD_GIT_TAG")

CARDANO_NODE_TAG=$(cardano-node version | head -n1 | awk '{print $2}')

RELEASE_CANDIDATE_BRANCH="release-candidate-new/$NEW_GIT_TAG"
if [ "$BUILDKITE_BRANCH" == "master" ]; then
RELEASE_CANDIDATE_BRANCH="release-candidate-new/$NEW_GIT_TAG"
else
RELEASE_CANDIDATE_BRANCH="release-candidate-new/$BUILDKITE_BRANCH"
fi

git config --global user.email "gha@cardanofoundation.org"
git config --global user.name "Github Action"
Expand Down Expand Up @@ -61,3 +65,4 @@ git push -f origin "$RELEASE_CANDIDATE_BRANCH"
buildkite-agent meta-data set "release-version" "$NEW_GIT_TAG"
buildkite-agent meta-data set "release-commit" "$RELEASE_COMMIT"
buildkite-agent meta-data set "release-candidate-branch" "$RELEASE_CANDIDATE_BRANCH"
buildkite-agent meta-data set "release-cabal-version" "$NEW_CABAL_VERSION"

0 comments on commit 79ffaa5

Please sign in to comment.