From ffeaaa9d686186bc024c71a8a64f743a887635b0 Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Thu, 15 Apr 2021 13:14:41 +0530 Subject: [PATCH] Automate autobhan test suite. --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ autobahn/Readme.md | 25 +++++++++++++++++++++++++ autobahn/fuzzingclient.json | 11 +++++++++++ scripts/start_server.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 autobahn/Readme.md create mode 100644 autobahn/fuzzingclient.json create mode 100644 scripts/start_server.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e60d1c6..c627d7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -200,3 +200,28 @@ jobs: cd nim-ws nimble install -y --depsOnly nimble test + + - name: Setup Python version + if: runner.os == 'macos' && matrix.target.cpu == 'amd64' + uses: actions/setup-python@v2 + with: + python-version: 2.7.17 + + - name: Setup and run Autobahn test suite. + if: runner.os == 'macos' && matrix.target.cpu == 'amd64' + run: | + pip install virtualenv + virtualenv --python=/usr/bin/python2 autobahn + source autobahn/bin/activate + pip install autobahntestsuite + cd nim-ws + ./scripts/start_server.sh + cd autobahn + wstest --mode fuzzingclient --spec fuzzingclient.json + + - name: Deploy autobahn report. + if: runner.os == 'macos' && matrix.target.cpu == 'amd64' + uses: peaceiris/actions-gh-pages@v3 + with: + personal_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./nim-ws/autobahn/reports/servers diff --git a/autobahn/Readme.md b/autobahn/Readme.md new file mode 100644 index 0000000..684518a --- /dev/null +++ b/autobahn/Readme.md @@ -0,0 +1,25 @@ +## Running autobahn test suite. + +### Start the websocket server + +```bash +nim c -r examples/server.nim +``` +### Install autobahn + ```bash + # Set up virtualenv in autobahn folder + virtualenv --python=/usr/bin/python2 autobahn + + # Activate the virtualenv + source autobahn/bin/activate + + # Install autobahn + pip install autobahntestsuite + ``` + + ### Run the test Websocket client. + ```bash + wstest --mode fuzzingclient --spec fuzzingclient.json + ``` + + Reports will be generated in `reports/server` which can be configured in `fuzzingclient.json` \ No newline at end of file diff --git a/autobahn/fuzzingclient.json b/autobahn/fuzzingclient.json new file mode 100644 index 0000000..ec96834 --- /dev/null +++ b/autobahn/fuzzingclient.json @@ -0,0 +1,11 @@ +{ + "outdir": "./reports/servers", + "servers": [ + { + "url": "ws://127.0.0.1:8888/ws" + } + ], + "cases": ["*"], + "exclude-cases": ["6.*", "9.*", "12.*", "13.*"], + "exclude-agent-cases": {} +} \ No newline at end of file diff --git a/scripts/start_server.sh b/scripts/start_server.sh new file mode 100644 index 0000000..08daadc --- /dev/null +++ b/scripts/start_server.sh @@ -0,0 +1,27 @@ +#!/bin/bash + + nim c -r examples/server.nim & + + max_iterations=10 + wait_seconds=6 + http_endpoint="http://127.0.0.1:8888/" + + iterations=0 + while true + do + ((iterations++)) + echo "Attempt $iterations" + sleep $wait_seconds + + http_code=$(curl --verbose -s -o /tmp/result.txt -w '%{http_code}' "$http_endpoint";) + + if [ "$http_code" -eq 200 ]; then + echo "Server Up" + break + fi + + if [ "$iterations" -ge "$max_iterations" ]; then + echo "Loop Timeout" + exit 1 + fi + done \ No newline at end of file