From 1c9e7ea8fb26bebdb6175223b7469a85649efa55 Mon Sep 17 00:00:00 2001 From: Daniel Abramov Date: Wed, 21 Apr 2021 14:36:16 +0200 Subject: [PATCH] tests: use autobahn test suite as docker image According to the documentation from the Autobahn Suite GitHub page, it seems like they do not support Python 3 which is currently the default Python version used with our GitHub Actions. The simplest way to workaround it properly seems to be using the Docker image that the maintainers of the project suggest to use for running the suite. This is more future-proof way that we should rely upon. This commit also removes some redundant steps that are not required. --- .github/workflows/ci.yml | 12 ++---------- scripts/autobahn-client.sh | 13 +++++++++---- scripts/autobahn-server.sh | 11 +++++++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 870b44c..23ed9a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,16 +104,8 @@ jobs: with: rust-version: ${{ matrix.rust }} - - name: Install dependencies - run: | - sudo apt-get install libssl-dev python-unittest2 - sudo pip install urllib3[secure] autobahntestsuite - - - name: Build Autobahn TestSuite for client - run: cargo build --release --features async-std-runtime --example autobahn-client - - - name: Build Autobahn TestSuite for server - run: cargo build --release --features async-std-runtime --example autobahn-server + - name: Install and configure docker + uses: docker-practice/actions-setup-docker@v1 - name: Running Autobahn TestSuite for client run: ./scripts/autobahn-client.sh diff --git a/scripts/autobahn-client.sh b/scripts/autobahn-client.sh index cd63693..cd24caf 100755 --- a/scripts/autobahn-client.sh +++ b/scripts/autobahn-client.sh @@ -6,8 +6,9 @@ SOURCE_DIR=$(readlink -f "${BASH_SOURCE[0]}") SOURCE_DIR=$(dirname "$SOURCE_DIR") cd "${SOURCE_DIR}/.." +CONTAINER_NAME=fuzzingserver function cleanup() { - kill -9 ${FUZZINGSERVER_PID} + docker container stop "${CONTAINER_NAME}" } trap cleanup TERM EXIT @@ -23,10 +24,14 @@ function test_diff() { fi } -cargo build --release --features async-std-runtime --example autobahn-client +docker run -d --rm \ + -v "${PWD}/autobahn:/autobahn" \ + -p 9001:9001 \ + --init \ + --name "${CONTAINER_NAME}" \ + crossbario/autobahn-testsuite \ + wstest -m fuzzingserver -s 'autobahn/fuzzingserver.json' -wstest -m fuzzingserver -s 'autobahn/fuzzingserver.json' & FUZZINGSERVER_PID=$! sleep 3 -echo "Server PID: ${FUZZINGSERVER_PID}" cargo run --release --features async-std-runtime --example autobahn-client test_diff diff --git a/scripts/autobahn-server.sh b/scripts/autobahn-server.sh index 86be38a..d41408a 100755 --- a/scripts/autobahn-server.sh +++ b/scripts/autobahn-server.sh @@ -5,7 +5,6 @@ set -x SOURCE_DIR=$(readlink -f "${BASH_SOURCE[0]}") SOURCE_DIR=$(dirname "$SOURCE_DIR") cd "${SOURCE_DIR}/.." -WSSERVER_PID= function cleanup() { kill -9 ${WSSERVER_PID} @@ -23,9 +22,13 @@ function test_diff() { fi } -cargo build --release --features async-std-runtime --example autobahn-server cargo run --release --features async-std-runtime --example autobahn-server & WSSERVER_PID=$! -echo "Server PID: ${WSSERVER_PID}" sleep 3 -wstest -m fuzzingclient -s 'autobahn/fuzzingclient.json' + +docker run --rm \ + -v "${PWD}/autobahn:/autobahn" \ + --network host \ + crossbario/autobahn-testsuite \ + wstest -m fuzzingclient -s 'autobahn/fuzzingclient.json' + test_diff