Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ultimate E2E tests #158

Merged
merged 24 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions deployment/molecule/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
1 change: 0 additions & 1 deletion deployment/molecule/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 2 deletions deployment/molecule/molecule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions deployment/molecule/ultimate-native-to-erc/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- import_playbook: ../../site.yml
- import_playbook: ./overwrite-docker-compose.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modification of Oracle's docker-compose.yml file is necessary in order to add ultimate network - joining the containers with parity containers

8 changes: 3 additions & 5 deletions deployment/molecule/ultimate-native-to-erc/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions deployment/roles/common/tasks/repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
force: no
update: no
version: "{{ bridge_repo_branch }}"
- name: Initialize submodules
shell: git submodule update --init
args:
chdir: "{{ bridge_path }}"
4 changes: 4 additions & 0 deletions e2e-commons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 29 additions & 0 deletions e2e-commons/ULTIMATE.md
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 27 additions & 0 deletions e2e-commons/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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: ..
Expand Down Expand Up @@ -47,6 +58,8 @@ services:
- FOREIGN_POLLING_INTERVAL=500
- ALLOW_HTTP=yes
command: "true"
networks:
- ultimate
oracle-erc20:
build:
context: ..
Expand Down Expand Up @@ -78,6 +91,8 @@ services:
- FOREIGN_POLLING_INTERVAL=500
- ALLOW_HTTP=yes
command: "true"
networks:
- ultimate
oracle-erc20-native:
build:
context: ..
Expand Down Expand Up @@ -109,6 +124,8 @@ services:
- FOREIGN_POLLING_INTERVAL=500
- ALLOW_HTTP=yes
command: "true"
networks:
- ultimate
ui:
build:
context: ..
Expand Down Expand Up @@ -137,6 +154,8 @@ services:
- REACT_APP_FOREIGN_GAS_PRICE_FACTOR=1
- PORT=3000
command: "true"
networks:
- ultimate
ui-erc20:
build:
context: ..
Expand Down Expand Up @@ -165,6 +184,8 @@ services:
- REACT_APP_FOREIGN_GAS_PRICE_FACTOR=1
- PORT=3000
command: "true"
networks:
- ultimate
ui-erc20-native:
build:
context: ..
Expand Down Expand Up @@ -193,6 +214,8 @@ services:
- REACT_APP_FOREIGN_GAS_PRICE_FACTOR=1
- PORT=3000
command: "true"
networks:
- ultimate
monitor:
build:
context: ..
Expand All @@ -219,8 +242,12 @@ services:
entrypoint: yarn start
ports:
- "3003:3003"
networks:
- ultimate
e2e:
build:
context: ..
dockerfile: Dockerfile.e2e
command: "true"
networks:
- ultimate
1 change: 1 addition & 0 deletions e2e-commons/down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file added e2e-commons/ultimate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions e2e-commons/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion oracle-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down