PolySwarmPolySwarmPolySwarmPolySwarm
Help

Integration Testing

概覽

PolySwarm 市場由眾多參與者及技術所組成:以太坊、IPFS 節點、合約、微引擎、代表、仲裁者、工件等等。 Testing a single component often demands availability of all of the other components.

借助 orchestration 項目,可簡便、順暢地建立一個完整的測試網。 顧名思義,orchestration 協調所有必要的組件,以便在本地開發計算機上搭建和拆分整個 PolySwarm 市場環境。

Always ensure that you have the latest updates to core PolySwarm Docker images prior to running integration tests. docker-compose ... up commands must always be proceeded with docker-compose ... pull commands.

Arbiter testing is not yet supported.

Windows developers: unless otherwise specified, execute all commands on this page in your Linux VM.


Getting Started

克隆與參與者目錄相鄰的 orchestration

$ git clone https://github.com/polyswarm/orchestration

orchestration 存儲庫中的以下 docker-compose 文件將有可幫助測試:

  • base.yml: defines the infrastructure basics for our testnet (e.g. geth nodes and relays)
  • ambassador-eicar.yml:使用 eicar.py 定義代表服務。
  • arbiter-verbatim.yml:使用 verbatim.py 定義仲裁者服務。
  • microengine-eicar.yml:使用 eicar.py 定義微引擎服務。
  • microengine-clamav.yml:使用 clamav.py + ClamAV 守護進城定義微引擎服務。
  • microengine-multi.yml:使用 multi.py 定義微引擎服務。

Create the orchestration_default network:

$ docker network create orchestration_default

(可選)預覽一個完整、可用的測試網

在 cloned 的 orchestration 目錄中:

$ docker-compose -f base.yml -f ambassador-eicar.yml -f microengine-eicar.yml -f arbiter-verbatim.yml pull
$ docker-compose -f base.yml -f ambassador-eicar.yml -f microengine-eicar.yml -f arbiter-verbatim.yml up

你會看到來自以下服務的輸出:

  1. contracts:負責管理及將 PolySwarm Nectar (NCT) 和 BountyRegistry 合約部署到我們的開發中測試網。
  2. polyswarmd:實現方便地訪問 homechainsidechainipfs 所提供的服務的 PolySwarm 守護進程。 所有參與者(代表、仲裁者和微引擎)都與此服務通信。
  3. consul:一個密鑰值存儲,由承包商用於將關鍵信息傳遞到polyswarmd,例如部署的BountyRegistry 合約的以太坊地址。
  4. homechain: A geth node running our testnet's "homechain". See Homechains & Sidechains for an explanation of our split-chain design.
  5. sidechain: Another geth instance, this one running our testnet's "sidechain".
  6. ipfs: An IPFS node responsible for hosting all artifacts in our development testnet.
  7. postgrescontractor 的數據存儲
  8. deposit_*balancemanager 實例,代表對應的參與者,使用relay 節點,將NCT 從homechain 移動到sidechain
  9. relay[0-2]:負責管理和選擇性地釋放區塊鏈中的保管資金的節點(例如homechainsidechain) 。 這些節點提供了一個“relay”抽象 API,參與者可以使用它們方便地在整個鏈中“中轉”資金。
  10. ambassador:一個簡單代表,它會在 EICAR 文件 和非 EICAR 的文件上面放置懸賞。
  11. Microngine-eicar:一個簡單的微型引擎,會將 EICCAR 文件作為惡意文件,並將所有其他工件識別為良性。
  12. arbiter-verbatim:一個簡單的仲​​裁者,提供腳本化標定真實數據投票,包括準確的 ERICAR 響應。

Browse through the logs to get a sense for what each of these components is doing.

Let it run for at least 5 minutes - it can take time to deploy contracts.

When you've seen enough log output, press Ctrl-C to halt the development testnet gracefully.

測試您的參與者

We'll use orchestration to start the entire testnet with one exception: we will not launch a competing version of the participant we're testing.

If we're developing a custom arbiter, for example, we don't want the stock arbiter stepping on our toes.

Prior to testing your participant, rebuild your participant's image, as necessary.

Testing Microengines

Linux-Based Engines

Execute the following in the orchestration directory (replace YOUR_PARTICIPANT_DIRECTORY):

$ docker-compose -f base.yml -f arbiter-verbatim.yml -f ambassador-eicar.yml pull
$ docker-compose -f base.yml -f arbiter-verbatim.yml -f ambassador-eicar.yml -f ../YOUR_PARTICIPANT_DIRECTORY/docker/test-integration.yml up

After the containers have been created, follow your participant's container for log messages (replace YOUR_PARTICIPANT_DIRECTORY and YOUR_PARTICIPANT_SERVICE_NAME):

docker-compose -f base.yml -f arbiter-verbatim.yml -f ambassador-eicar.yml -f ../YOUR_PARTICIPANT_DIRECTORY/docker/test-integration.yml logs --follow YOUR_PARTICIPANT_SERVICE_NAME
Observe Output

Observe your microengine's output to ensure that your microengine is seeing and responding to the incoming bounties.

Windows-Based Engines

Your microengine's "worker", the Docker service responsible for implementing scan logic, is the only Docker service that we will be running on your Windows host.

Your engine's frontend, redis, balancemanager and the rest of the testnet will run on your Linux VM.

Launch the Base Network + an Arbiter

Execute the following in the orchestration directory:

$ docker-compose -f base.yml -f arbiter-verbatim.yml pull
$ docker-compose -f base.yml -f arbiter-verbatim.yml up
Wait for polyswarmd to Become Available

polyswarmd 可能需要過幾分鐘才會完整運行。 During this time, you will see many messages like Problem with dial... dial tcp connection refused. and chain for config not available in consul yet. These errors are normal while the testnet is initializing, so have patience.

In a new shell, execute the following in the orchestration directory:

$ docker-compose -f base.yml logs --follow polyswarmd

In this new shell, wait for polyswarmd:

Attaching to orchestration_polyswarmd_1_c1d732ac5355
polyswarmd_1_c1d732ac5355 | [2019-05-13 20:52:36 +0000] [1] [INFO] Starting gunicorn 19.9.0
polyswarmd_1_c1d732ac5355 | [2019-05-13 20:52:36 +0000] [1] [INFO] Listening at: http://0.0.0.0:31337 (1)
...
polyswarmd_1_c1d732ac5355 | CRITICAL:polyswarmd.wsgi:polyswarmd is ready!
polyswarmd_1_c1d732ac5355 | CRITICAL:polyswarmd.wsgi:polyswarmd is ready!
polyswarmd_1_c1d732ac5355 | CRITICAL:polyswarmd.wsgi:polyswarmd is ready!
polyswarmd_1_c1d732ac5355 | CRITICAL:polyswarmd.wsgi:polyswarmd is ready!

When ready, polyswarmd will print polyswarmd is ready! once for every polyswarmd thread (4 by default).

Launch BalanceManager + Redis + Microengine Frontend

Share your microengine's root directory with your Linux VM.

In a new shell, execute the following in the root of your microengine's directory (replace YOUR_ENGINE_SLUG with, e.g. eicar):

$ docker-compose -f docker/test-integration.yml up --scale test_microengine-worker_YOUR_ENGINE_SLUG=0
Launch Your Microengine Worker

Launch your engine's Docker container and get an interactive PowerShell:

PS > docker run --isolation=process --network "PolySwarm Network" -it microengine-eicar

In this PowerShell session, launch your microengine, (replace the --backend argument for your engine's package_slug):

[container] PS > microengine --log INFO --keyfile microengine_keyfile --password password --polyswarmd-addr polyswarmd:31337 --insecure-transport --testing 2 --backend <YOUR ENGINES_PACKAGE_SLUG>
Launch an Ambassador to Introduce Bounties

Execute the following in the orchestration directory:

$ docker-compose -f ambassador-eicar.yml pull
$ docker-compose -f ambassador-eicar.yml up

The ambassador's balancemanager may print out many scary messages about insufficient funds while starting up.

This is normal and should stop after balancemanager is able to move the ambassador's funds from the testnet homechain to the testnet sidechain.

Observe Output

Observe your microengine's output to ensure that your microengine is seeing and responding to the incoming bounties.

Testing Ambassadors

Execute the following in the orchestration directory (replace YOUR_PARTICIPANT_DIRECTORY):

$ docker-compose -f base.yml -f arbiter-verbatim.yml -f microengine-eicar.yml pull
$ docker-compose -f base.yml -f arbiter-verbatim.yml -f microengine-eicar.yml -f ../YOUR_PARTICIPANT_DIRECTORY/docker/test-integration.yml up

After the containers have been created, follow your participant's container for log messages (replace YOUR_PARTICIPANT_DIRECTORY and YOUR_PARTICIPANT_SERVICE_NAME):

docker-compose -f base.yml -f arbiter-verbatim.yml -f microengine-eicar.yml -f ../YOUR_PARTICIPANT_DIRECTORY/docker/test-integration.yml logs --follow YOUR_PARTICIPANT_SERVICE_NAME
Observe Output

Observe your ambassadors's output to ensure that your ambassador is successfully submitting bounties.

Next Steps

If you're satisfied with your participant's performance on the testnet, it's time to connect to the real PolySwarm network!

Connecting to the Marketplace →