Skip to content

Commit

Permalink
tests: setup consensus module e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Apr 23, 2021
1 parent 7d96201 commit cf8e372
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 24 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,14 @@ jobs:
sudo apt-get update
sudo apt-get install bubblewrap build-essential libseccomp-dev libssl-dev protobuf-compiler
- name: Download artifacts
working-directory: tests/
run: ./download-artifacts.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run end-to-end tests
run: ./tests/run-e2e.sh
env:
TEST_NODE_BINARY: tests/untracked/oasis-node
TEST_RUNTIME_LOADER: tests/untracked/oasis-core-runtime-loader
5 changes: 5 additions & 0 deletions tests/consts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
OASIS_CORE_VERSION=21.1-dev
# To download a pre-released version of oasis-core built by oasis-core/release-dev action
# set artifact ID to use here.
# To download a released version of oasis-core unset this variable.
GITHUB_ARTIFACT=55594708
22 changes: 22 additions & 0 deletions tests/download-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh -eux
. ./consts.sh

mkdir -p untracked
if [ ! -e "untracked/oasis_core_${OASIS_CORE_VERSION}_linux_amd64/oasis-node" ]; then
(
cd untracked
if [ ! -z "${GITHUB_ARTIFACT:-}" ]; then
# Authentication is required to download the artifacts, although those are public.
curl -fLO -h "Authorization: Bearer ${GITHUB_TOKEN}" "https://api.github.com/repos/oasisprotocol/oasis-core/actions/artifacts/${GITHUB_ARTIFACT}/zip"
unzip oasis-core.zip
else
curl -fLO "https://github.com/oasisprotocol/oasis-core/releases/download/v$OASIS_CORE_VERSION/oasis_core_${OASIS_CORE_VERSION}_linux_amd64.tar.gz"
fi

tar -xf "oasis_core_${OASIS_CORE_VERSION}_linux_amd64.tar.gz" \
--strip-components=1 \
"oasis_core_${OASIS_CORE_VERSION}_linux_amd64/oasis-node" \
"oasis_core_${OASIS_CORE_VERSION}_linux_amd64/oasis-net-runner" \
"oasis_core_${OASIS_CORE_VERSION}_linux_amd64/oasis-core-runtime-loader"
)
fi
43 changes: 19 additions & 24 deletions tests/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -o nounset -o pipefail -o errexit
trap "exit 1" INT

# Oasis Core release version to test against.
OASIS_RELEASE=21.0.1
OASIS_RELEASE=21.1-dev

# Get the root directory of the tests dir inside the repository.
ROOT="$(cd $(dirname $0); pwd -P)"
Expand All @@ -28,6 +28,16 @@ cleanup() {
}
trap "cleanup" EXIT

if [[ ! -v TEST_NODE_BINARY ]]; then
printf "${RED}### Please set \$TEST_NODE_BINARY variable.${OFF}\n"
exit 1
fi

if [[ ! -v TEST_RUNTIME_LOADER ]]; then
printf "${RED}### Please set \$TEST_RUNTIME_LOADER variable.${OFF}\n"
exit 1
fi

# Find build tools.
if [[ "$(which go)" == "" ]]; then
printf "${RED}### Please install 'go'.${OFF}\n"
Expand All @@ -38,45 +48,30 @@ if [[ "$(which cargo)" == "" ]]; then
exit 1
fi

# Find a downloader tool.
if [[ "$(which wget)" == "" ]]; then
if [[ "$(which curl)" == "" ]]; then
printf "${RED}### Please install 'wget' or 'curl'.${OFF}\n"
exit 1
else
DOWNLOAD="curl --progress-bar --location -o"
fi
else
DOWNLOAD="wget --quiet --show-progress --progress=bar:force:noscroll -O"
fi

printf "${CYAN}### Building test simple-keyvalue runtime...${OFF}\n"
cd "${ROOT}"/runtimes/simple-keyvalue
cargo build
cp "${ROOT}"/../target/debug/test-runtime-simple-keyvalue "${TEST_BASE_DIR}"/

printf "${CYAN}### Building test simple-consensus runtime...${OFF}\n"
cd "${ROOT}"/runtimes/simple-consensus
cargo build
cp "${ROOT}"/../target/debug/test-runtime-simple-consensus "${TEST_BASE_DIR}"/

printf "${CYAN}### Building e2e test harness...${OFF}\n"
cd "${ROOT}"/e2e
go build
cp "${ROOT}"/e2e/e2e "${TEST_BASE_DIR}"/

cd "${TEST_BASE_DIR}"

printf "${CYAN}### Downloading oasis-core release ${OASIS_RELEASE}...${OFF}\n"
${DOWNLOAD} oasis-core.tar.gz https://github.com/oasisprotocol/oasis-core/releases/download/v${OASIS_RELEASE}/oasis_core_${OASIS_RELEASE}_linux_amd64.tar.gz

printf "${CYAN}### Unpacking oasis-node...${OFF}\n"
${TAR} -xf oasis-core.tar.gz --strip-components=1 oasis_core_${OASIS_RELEASE}_linux_amd64/oasis-node

printf "${CYAN}### Unpacking oasis-core-runtime-loader...${OFF}\n"
${TAR} -xf oasis-core.tar.gz --strip-components=1 oasis_core_${OASIS_RELEASE}_linux_amd64/oasis-core-runtime-loader

printf "${CYAN}### Running end-to-end tests...${OFF}\n"
./e2e --log.level=INFO \
--log.format json \
--basedir.no_cleanup \
--e2e.node.binary="${TEST_BASE_DIR}"/oasis-node \
--e2e.node.binary="${TEST_NODE_BINARY}" \
--e2e.runtime.binary_dir.default="${TEST_BASE_DIR}" \
--e2e.runtime.loader="${TEST_BASE_DIR}"/oasis-core-runtime-loader
--e2e.runtime.loader="${TEST_RUNTIME_LOADER}"

cd "${ROOT}"
rm -rf "${TEST_BASE_DIR}"
Expand Down

0 comments on commit cf8e372

Please sign in to comment.