PolySwarmPolySwarmPolySwarmPolySwarm
Help

集成测试

概览

PolySwarm 市场由众多参与者及技术所组成:以太坊、IPFS 节点、合约、微引擎、代表、仲裁者、工件等等。 测试一个单独的组件通常需要能够获得所有其他组件。

借助 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:运行着我们的测试网的 “Homechain” 的 geth 节点。 See Homechains & Sidechains for an explanation of our split-chain design.
  5. sidechain :运行着我们测试网的“侧链”的另一个 geth 实例。
  6. ipfs:一个 IPFS 节点,负责在我们的开发测试网中托管所有工件。
  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

It will take several minutes for polyswarmd to become available. 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 →