Monitor - E2E (#112)

* Monitor in e2e

* Cleanup trap

* Exposing monitor port

* Cleanup script

* Exposing monitor port

* Test cases

* Silent curl

* Introduced monitor-e2e into CI

* only monitor

* machine executor

* Readme

* Echoing test cases

* Revert "only monitor"

bb6c8baf06029a1d6ea86cf62e8112ef78b8eaf4

* Negated commands in a subshell
This commit is contained in:
Przemyslaw Rzad 2019-06-27 09:57:45 +02:00 committed by GitHub
parent 68a2b5be90
commit f1d24f0e2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 107 additions and 0 deletions

@ -104,6 +104,14 @@ jobs:
paths:
- ~/.cache/yarn
- run: yarn run ui-e2e
monitor-e2e:
machine:
image: circleci/classic:latest
docker_layer_caching: true
steps:
- checkout
- run: git submodule update --init
- run: ./monitor-e2e/run-tests.sh
cover:
docker:
- image: circleci/node:10.15
@ -139,3 +147,4 @@ workflows:
- ansible-lint
- oracle-e2e
- ui-e2e
- monitor-e2e

@ -24,6 +24,7 @@ Sub-repositories maintained within this monorepo are listed below.
| [Monitor](monitor/README.md) | Tool for checking balances and unprocessed events in bridged networks. |
| [Deployment](deployment/README.md) | Ansible playbooks for deploying cross-chain bridges. |
| [Oracle-E2E](oracle-e2e/README.md) | End to end tests for the Oracle |
| [Monitor-E2E](monitor-e2e/README.md) | End to end tests for the Monitor |
| [UI-E2E](ui-e2e/README.md) | End to end tests for the UI |
| [E2E-Commons](e2e-commons/README.md) | Common utilities and configuration used in end to end tests |

@ -183,6 +183,25 @@ services:
- REACT_APP_FOREIGN_GAS_PRICE_UPDATE_INTERVAL=15000
- PORT=3000
command: "true"
monitor:
build:
context: ..
dockerfile: monitor/Dockerfile
environment:
- HOME_RPC_URL=http://parity1:8545
- FOREIGN_RPC_URL=http://parity2:8545
- HOME_BRIDGE_ADDRESS=0x32198D570fffC7033641F8A9094FFDCaAEF42624
- FOREIGN_BRIDGE_ADDRESS=0x2B6871b9B02F73fa24F4864322CdC78604207769
- HOME_DEPLOYMENT_BLOCK=0
- FOREIGN_DEPLOYMENT_BLOCK=0
- GAS_PRICE_SPEED_TYPE=standard
- GAS_LIMIT=300000
- GAS_PRICE_FALLBACK=21
- LEFT_TX_THRESHOLD=100
- PORT=3003
entrypoint: yarn start
ports:
- "3003:3003"
e2e:
build:
context: ..

@ -39,5 +39,9 @@ while [ "$1" != "" ]; do
node ./scripts/blocks.js &
fi
if [ "$1" == "monitor" ]; then
docker-compose up -d monitor
fi
shift # Shift all the parameters down by one
done

11
monitor-e2e/README.md Normal file

@ -0,0 +1,11 @@
# POA Token Bridge / Monitor-E2E
End to end tests for the POA Token Bridge [Monitor](../monitor/README.md).
## Running
To run the bridge end-to-end tests, you just have to run:
```
./run-tests.sh
```

63
monitor-e2e/run-tests.sh Executable file

@ -0,0 +1,63 @@
#!/usr/bin/env bash
cd $(dirname $0)
set -e # exit when any command fails
##### Helper Functions #####
function cleanup {
../e2e-commons/down.sh
}
trap cleanup EXIT
FILES=(getBalances.json validators.json eventsStats.json alerts.json)
check_files_exist() {
rc=0
for f in "${FILES[@]}"; do
command="test -f responses/$f"
(docker-compose -f ../e2e-commons/docker-compose.yml exec monitor /bin/bash -c "$command") || rc=1
done
return $rc
}
##### Initialization #####
../e2e-commons/up.sh oracle deploy monitor
##### Test cases #####
echo "Test case - CheckWorker scripts should work and create files in responses/ directory"
(! check_files_exist)
docker-compose -f ../e2e-commons/docker-compose.yml exec monitor /bin/bash -c "node checkWorker.js"
docker-compose -f ../e2e-commons/docker-compose.yml exec monitor /bin/bash -c "node checkWorker2.js"
check_files_exist
echo "Test case - Web Interface should return balances"
OUTPUT=$(curl -s http://localhost:3003/)
grep -q home <<< "$OUTPUT"
grep -q foreign <<< "$OUTPUT"
(! grep -q error <<< "$OUTPUT")
echo "Test case - Web Interface should return validators"
OUTPUT=$(curl -s http://localhost:3003/validators)
grep -q home <<< "$OUTPUT"
grep -q foreign <<< "$OUTPUT"
(! grep -q error <<< "$OUTPUT")
echo "Test case - Web Interface should return eventsStats"
OUTPUT=$(curl -s http://localhost:3003/eventsStats)
grep -q lastChecked <<< "$OUTPUT"
(! grep -q error <<< "$OUTPUT")
echo "Test case - Web Interface should return alerts"
OUTPUT=$(curl -s http://localhost:3003/alerts)
grep -q lastChecked <<< "$OUTPUT"
(! grep -q error <<< "$OUTPUT")
##### Cleanup #####
cleanup