diff --git a/.circleci/config.yml b/.circleci/config.yml index a0ddf53c..68a0cfbd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -210,7 +210,16 @@ jobs: name: Run the scenario command: deployment-e2e/molecule.sh repo no_output_timeout: 40m - + deployment-multiple: + executor: tokenbridge-orb/machine-with-docker-caching + steps: + - checkout + - run: git submodule update --init + - run: + name: Run the scenario + command: deployment-e2e/molecule.sh multiple + no_output_timeout: 40m + ultimate: executor: tokenbridge-orb/machine-with-docker-caching parameters: @@ -272,6 +281,7 @@ workflows: - deployment-ui - deployment-monitor - deployment-repo + - deployment-multiple - ultimate: name: "ultimate: native to erc" scenario-name: native-to-erc diff --git a/deployment-e2e/molecule/multiple/Dockerfile.j2 b/deployment-e2e/molecule/multiple/Dockerfile.j2 new file mode 100644 index 00000000..e6aa95d3 --- /dev/null +++ b/deployment-e2e/molecule/multiple/Dockerfile.j2 @@ -0,0 +1,14 @@ +# Molecule managed + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi diff --git a/deployment-e2e/molecule/multiple/molecule.yml b/deployment-e2e/molecule/multiple/molecule.yml new file mode 100644 index 00000000..f161410e --- /dev/null +++ b/deployment-e2e/molecule/multiple/molecule.yml @@ -0,0 +1,59 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint + enabled: True + options: + config-data: + ignore: ../../hosts.yml +platforms: + - name: multiple-host + groups: + - example + children: + - oracle + - monitor + - ui + image: ubuntu:16.04 + privileged: true + network_mode: host + volumes: + - /var/run/docker.sock:/var/run/docker.sock +provisioner: + name: ansible + lint: + name: ansible-lint + enabled: True + options: + r: ["bug"] + playbooks: + prepare: ../prepare.yml + converge: ../monitor/converge.yml + inventory: + host_vars: + multiple-host: + ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9" + MONITOR_PORT: 3003 + syslog_server_port: "udp://127.0.0.1:514" +verifier: + name: testinfra + lint: + name: flake8 + additional_files_or_dirs: + - ../../tests/* +scenario: + name: multiple + test_sequence: + - lint + - cleanup + - destroy + - dependency + - syntax + - create + - prepare + - converge + - verify + - destroy diff --git a/deployment-e2e/molecule/multiple/tests/test_multiple.py b/deployment-e2e/molecule/multiple/tests/test_multiple.py new file mode 100644 index 00000000..7feebd25 --- /dev/null +++ b/deployment-e2e/molecule/multiple/tests/test_multiple.py @@ -0,0 +1,32 @@ +import os +import pytest +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +@pytest.mark.parametrize("service", [ + ("poabridge"), + ("tokenbridge-ui"), + ("tokenbridge-monitor") +]) +def test_services(host, service): + assert host.service(service).is_enabled + assert host.service(service).is_running + + +@pytest.mark.parametrize("name", [ + ("oracle_rabbit_1"), + ("oracle_redis_1"), + ("oracle_bridge_request_1"), + ("oracle_bridge_collected_1"), + ("oracle_bridge_affirmation_1"), + ("oracle_bridge_senderhome_1"), + ("oracle_bridge_senderforeign_1"), + ("ui_ui_1"), + ("monitor_monitor_1") +]) +def test_docker_containers(host, name): + container = host.docker(name) + assert container.is_running diff --git a/deployment/roles/common/tasks/main.yml b/deployment/roles/common/tasks/main.yml index d78b1509..2cb59c4a 100644 --- a/deployment/roles/common/tasks/main.yml +++ b/deployment/roles/common/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Check if component is already deployed - shell: "test -f {{ bridge_path }}/{{ component }}/docker-compose.yml && echo 'true'" + shell: "test -f {{ bridge_path }}/{{ component }}/.env && echo 'true'" ignore_errors: True register: already_deployed when: check_deployed is defined