Ultimate E2E tests (#158)

* Ultimate e2e for native to erc type of bridge

* One job

* Try to run the tests

* Run on CI

* Docs

* Cosmetics

* Final changes

* Revert the changes

* Networks

* Waiting for Oracle

* One job

* Initialize the contracts submodule

* Run on ci

* comment

* Sleep.

* ultimate network

* Docker localhost no longer needed

* Final changes

* Timeout

* Naming

* Sleep task.
This commit is contained in:
Przemyslaw Rzad 2019-07-26 10:14:25 +02:00 committed by GitHub
parent 5c92cf50d7
commit c9d100491c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 138 additions and 15 deletions

@ -134,11 +134,32 @@ jobs:
docker_layer_caching: true
steps:
- checkout
- run:
name: Install redis tools
command: sudo apt-get install -y redis-tools
- run: git submodule update --init
- run:
name: Prepare the infrastructure
command: e2e-commons/up.sh deploy native-to-erc
- run: 'echo "TODO - Run the e2e tests on top of the infrastructure created by previous step"'
no_output_timeout: 30m
- run:
name: Wait for the Oracle to start
command: |
set +e
i=0
while [[ $(redis-cli GET native-erc-collected-signatures:lastProcessedBlock) = "" ]]; do
((i++))
if [ "$i" -gt 30 ]
then
exit -1
fi
echo "Sleeping..."
sleep 3
done
- run:
name: Run the oracle-e2e tests
command: cd e2e-commons && docker-compose run e2e yarn workspace oracle-e2e run native-to-erc
workflows:
version: 2
tokenbridge:

@ -30,3 +30,7 @@ Scenario | Description
--- | ---
oracle | Deploys and checks standalone Oracle on Ubuntu host
ui | Deploys and checks standalone UI on Ubuntu host
## Ultimate E2E tests
For information on the Ultimate tests, please refer to [Ultimate](../../e2e-commons/ULTIMATE.md).

@ -7,6 +7,5 @@ services:
dockerfile: molecule/Dockerfile
restart: 'no'
privileged: true
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock

@ -3,10 +3,9 @@ cd $(dirname $0)
set -e # exit when any command fails
CODEBASE_BRANCH=${CIRCLE_BRANCH-$(git symbolic-ref --short HEAD)}
DOCKER_LOCALHOST=${DOCKER_LOCALHOST-localhost}
while [ "$1" != "" ]; do
docker-compose build && docker-compose run -e CODEBASE_BRANCH=$CODEBASE_BRANCH -e DOCKER_LOCALHOST=$DOCKER_LOCALHOST molecule_runner /bin/bash -c "molecule test --scenario-name $1"
docker-compose build && docker-compose run -e CODEBASE_BRANCH=$CODEBASE_BRANCH molecule_runner /bin/bash -c "molecule test --scenario-name $1"
shift # Shift all the parameters down by one
done

@ -0,0 +1,3 @@
---
- import_playbook: ../../site.yml
- import_playbook: ./overwrite-docker-compose.yml

@ -16,7 +16,7 @@ provisioner:
name: ansible
playbooks:
prepare: ../prepare.yml
converge: ../../site.yml
converge: converge.yml
inventory:
host_vars:
oracle-native-to-erc-host:
@ -26,10 +26,8 @@ provisioner:
HOME_BRIDGE_ADDRESS: "0x32198D570fffC7033641F8A9094FFDCaAEF42624"
FOREIGN_BRIDGE_ADDRESS: "0x2B6871b9B02F73fa24F4864322CdC78604207769"
ERC20_TOKEN_ADDRESS: "0xdbeE25CbE97e4A5CC6c499875774dc7067E9426B"
QUEUE_URL: "amqp://$DOCKER_LOCALHOST"
REDIS_URL: "redis://$DOCKER_LOCALHOST:6379"
HOME_RPC_URL: "http://$DOCKER_LOCALHOST:8541"
FOREIGN_RPC_URL: "http://$DOCKER_LOCALHOST:8542"
HOME_RPC_URL: "http://parity1:8545"
FOREIGN_RPC_URL: "http://parity2:8545"
ALLOW_HTTP: yes
LOG_LEVEL: debug
verifier:

@ -0,0 +1,37 @@
---
# The Oracle's docker-compose file has to be modified, in order to join the docker containers over network with the parity containers
- name: Overwrite the docker-compose
hosts: oracle
become: true
tasks:
- name: stop the service
shell: service poabridge stop
- name: Slurp docker compose file
slurp:
src: "/home/poadocker/bridge/oracle/docker-compose.yml"
register: docker_compose_slurp
- name: Parse docker compose file
set_fact:
docker_compose_parsed: "{{ docker_compose_slurp['content'] | b64decode | from_yaml }}"
- name: Add the external network used to connect to Parity nodes
set_fact:
docker_compose_parsed: "{{ docker_compose_parsed |combine({'networks': {'ultimate': {'external': 'true'}}}, recursive=True) }}"
- name: Add all Oracle containers to the network
set_fact:
docker_compose_parsed: "{{ docker_compose_parsed | combine({'services': {item: {'networks': docker_compose_parsed.services[item].networks | union(['ultimate'])}}}, recursive=True) }}"
with_items: "{{ docker_compose_parsed.services }}"
- name: Expose Redis port to allow connecting from redis-cli
set_fact:
docker_compose_parsed: "{{ docker_compose_parsed | combine({'services': {'redis': {'ports': ['6379:6379']}}}, recursive=True) }}"
- name: Write new docker-compose file
copy:
content: "{{ docker_compose_parsed | to_yaml }}"
dest: "/home/poadocker/bridge/oracle/docker-compose.yml"
- name: start the service
shell: service poabridge start

@ -6,3 +6,7 @@
force: no
update: no
version: "{{ bridge_repo_branch }}"
- name: Initialize submodules
shell: git submodule update --init
args:
chdir: "{{ bridge_path }}"

@ -25,3 +25,7 @@ Shut down and cleans up containers, networks, services, running scripts:
| ui | Launches UI containers |
| blocks | Auto mines blocks |
| native-to-erc | Creates infrastructure for ultimate e2e testing, for native-to-erc type of bridge |
#### Ultimate e2e testing
For more information on the Ultimate e2e testing, please refer to [Ultimate](./ULTIMATE.md).

29
e2e-commons/ULTIMATE.md Normal file

@ -0,0 +1,29 @@
# POA TokenBridge / Ultimate E2E
Documentation regarding the Ultimate end-to-end tests.
## Overview
The ultimate e2e test scenario covers native-to-erc type of bridge.
It runs the e2e tests on components deployed using the deployment playbooks.
## Usage
### 1. Prepare the infrastructure
Run the Parity nodes, deploy the bridge contracts, deploy Oracle using the deployment playbook.
```bash
./up.sh deploy native-to-erc
```
### 2. Run the E2E tests
```
docker-compose run e2e yarn workspace oracle-e2e run native-to-erc
```
## Diagram
![diagram](./ultimate.png)

@ -1,22 +1,33 @@
---
version: '3'
networks:
ultimate:
external: true
services:
parity1:
build: ../parity
ports:
- "8541:8545"
networks:
- ultimate
parity2:
build:
context: ../parity
dockerfile: Dockerfile-foreign
ports:
- "8542:8545"
networks:
- ultimate
redis:
image: "redis:4"
networks:
- ultimate
rabbit:
image: "rabbitmq:3-management"
ports:
- "15672:15672"
networks:
- ultimate
oracle:
build:
context: ..
@ -47,6 +58,8 @@ services:
- FOREIGN_POLLING_INTERVAL=500
- ALLOW_HTTP=yes
command: "true"
networks:
- ultimate
oracle-erc20:
build:
context: ..
@ -78,6 +91,8 @@ services:
- FOREIGN_POLLING_INTERVAL=500
- ALLOW_HTTP=yes
command: "true"
networks:
- ultimate
oracle-erc20-native:
build:
context: ..
@ -109,6 +124,8 @@ services:
- FOREIGN_POLLING_INTERVAL=500
- ALLOW_HTTP=yes
command: "true"
networks:
- ultimate
ui:
build:
context: ..
@ -137,6 +154,8 @@ services:
- REACT_APP_FOREIGN_GAS_PRICE_FACTOR=1
- PORT=3000
command: "true"
networks:
- ultimate
ui-erc20:
build:
context: ..
@ -165,6 +184,8 @@ services:
- REACT_APP_FOREIGN_GAS_PRICE_FACTOR=1
- PORT=3000
command: "true"
networks:
- ultimate
ui-erc20-native:
build:
context: ..
@ -193,6 +214,8 @@ services:
- REACT_APP_FOREIGN_GAS_PRICE_FACTOR=1
- PORT=3000
command: "true"
networks:
- ultimate
monitor:
build:
context: ..
@ -219,8 +242,12 @@ services:
entrypoint: yarn start
ports:
- "3003:3003"
networks:
- ultimate
e2e:
build:
context: ..
dockerfile: Dockerfile.e2e
command: "true"
networks:
- ultimate

@ -5,3 +5,4 @@ if [ $CI ]; then exit $rc; fi
ps | grep node | grep -v grep | awk '{print "kill " $1}' | /bin/bash
docker-compose down
docker network rm ultimate || true

BIN
e2e-commons/ultimate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

@ -4,14 +4,10 @@ set -e # exit when any command fails
./down.sh
docker-compose build
docker network create --driver bridge ultimate || true
docker-compose up -d parity1 parity2 e2e
export DOCKER_LOCALHOST="localhost"
while [ "$1" != "" ]; do
if [ "$1" == "macos" ]; then
export DOCKER_LOCALHOST="host.docker.internal"
fi
if [ "$1" == "oracle" ]; then
docker-compose up -d redis rabbit oracle oracle-erc20 oracle-erc20-native

@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"start": "mocha",
"lint": "eslint . --ignore-path ../.eslintignore"
"lint": "eslint . --ignore-path ../.eslintignore",
"native-to-erc": "mocha test/nativeToErc.js"
},
"author": "",
"license": "ISC",