codex-factory/README.md
nugaon e61f2cb8a1
feat: traffic gen (#21)
* feat: generate random bytes and push to the binded nodes

* fix: npm reinstall

* fix: version dumps in package.json

* ci: bump version number of node

* feat: payment-tolerance

* refactor: gen 400 chunks with the trafficgen command

* feat: parametric traffic generation

* docs: amend beeShPorts description

* docs: readme

* fix: payment tolerance default value in bee.sh

* refactor: only beeApiUrl argument on script call

* docs: traffic gen readme adjustment

* refactor: instead of payment tolerance use payment threshold

* refactor: sleep ms raise and take out unnecessary axios call

* chore: await for upload, the script no longer overloads bee nodes with data (#27)

Co-authored-by: Vojtech Simetka <vojtech@simetka.cz>
2021-05-17 11:03:36 +02:00

3.3 KiB

Bee Factory

This project builds up a test environment with Bee clients and with a test blockchain. The created environment is runnable on local machine as well.

All services run in Docker containers only.

Currently, the repository supports running Bee nodes up to 5 by default.

Usage

The whole Bee environment (with blockchain) can be started by running one script, but for that you need to have the necessary Docker images, which is possible to build yourself by running some scripts

First you may want to set all global variables that the scripts will use. For that, there is a .env file which contains all necessary variables that you need.

set -a && source ./scripts/.env && set +a

If you do not set these global variables, the scripts will use those which are available in the .env file.

Setup the environment

Create the common Docker network for the environment with

./scripts/network.sh

To start the blockchain, run the following command in the root directory of the project:

./scripts/blockchain.sh

After that, it's possible to deploy Swarm smart contracts

npm run migrate:contracts

Before you start the Bee nodes with the deployed Swap Factory, you have to fund your overlay addresses of your Bee nodes for the successful start. The supply.js script can fund the addresses which are defined in bee-overlay-addresses.json file. To run this script just execute

npm run supply

and the configured accounts will get 1 ether and 100 BZZ Token.

After all above went successfully you can start the Bee nodes

./scripts/bee.sh start --workers=4

OR it is possible to build docker images on a desired state, so that a fresh environment can be started on each run.

Build Docker Images

Basically, a full-featured Bee environment has 2 types of Docker image:

  • Bee images: Bee clients with pre-defined keys (and optionally including the state which you nodes have in its data-dirs)
./scripts/bee-docker-build.sh
  • Blockchain image: Ganache blockchain which you may want to take a snapshot of after the contracts are deployed and the pre-defined Bee client keys are funded already.
./scripts/blockchain-docker-build.sh

Run Environment

If you have all Docker images that your environment file requires, start the Bee cluster

./scripts/environment.sh start

Utilities

It is possible to generate random traffic in your cluster:

$ npm run gen:traffic 

The script is in an infinite loop, so if you want to stop the generation you have to terminate it manually in your terminal by pressing Ctrl^C.

If you don't specify any parameters it will produce 400 chunks/0.5 sec that the script tries to upload on the http://localhost:1633 - that is the binded port of the queen node if you orchestrated the environment with the envrionment.sh.

The following way you can pass parameter

  1. BEE_API_URL - Host that has reachable port to the Bee API. [Array,Default:['http://localhost:1633']]
$ npm run gen:traffic -- <BEE_API_URL> <BEE_API_URL> <BEE_API_URL> (...)

e.g.

$ npm run gen:traffic -- http://localhost:1633 http://localhost:11633