livepeer / test-harness

3 stars 2 forks source link

test-harness


This is a work in progress, so code is :lava:

Dependencies

That's alotta dependencies, I know. technically you don't need docker-compose if if you're not going to run the test harness locally. so there is that :)

installation

$ git clone https://github.com/livepeer/test-harness.git
$ cd test-harness
$ npm install

Local Mode

  1. check examples/local.js, note that in the config object local is true. note that this will use docker-compose up to run instead of docker-swarm. this is easier to debug for smallish setups locally.

  2. important edit the examples/local.js file livepeerBinaryPath value to the livepeer binary you'd like to test. this has to be built for linux

  3. run node examples/local.js to fire up the test-harness.

  4. thats it. now you got a running setup. note that in the dist folder there will be a folder for this experiment, which will contain the docker-compose generated. this will have the port forwarding for each node and should be accessible at your dev machine's localhost

Using official docker image

If flag publicImage is set to true in config, then image from Docker Hub will be used (livepeer/go-livepeer:edge). This image is built on Docker Hub from master branch of go-livepeer repository. Also publicImage could be set to name of any other public image, which in turn will be used.

Local Build

If flag localBuild is set to true in config, then livepeer binary will be taken from local docker image tagged livepeerbinary:debian. It should be build by running make localdocker

GCP integrated Test-harness

  1. setup gcloud, docker-machine Google driver uses [Application Default Credentials]() to get authorization credentials for use in calling Google APIs. follow https://cloud.google.com/sdk/docs/#deb to gcloud init.

  2. run gcloud auth login

  3. now you should have gcloud and ready to spin up instances, if you're having issues , let me know (open an issue or buzz me at discord @Yahya#0606 )

  4. there is a ready made example in /examples/index.js, Change the test name and run in node examples/index.js which will spin up a docker cluster of 2 hosts, with livepeer containers and geth with protocol ready to go


Config Options



Automating Livepeer actions


this isn't complete yet. but it's functioning . checkout this example along with the comments in the code to get an idea of how to use it.


Pumba (Chaos Monkey) support


stopping a random container within a livepeer group

$ ./test-harness disrupt -h
Usage: disrupt [options] [name] [group]                                                                         

uses pumba to kill containers in a specified livepeer group randomly                                            

Options:                                                                                                        
  -i --interval <interval>  recurrent interval for chaos command; use with optional unit suffix: 'ms/s/m/h'     
  -h, --help                output usage information                                                            
example: ./test-harness disrupt -i 30s my-deployment o_a
# Kill a random livepeer container in group o_a every 30 seconds

To stop an ongoing disruption

./test-harness disrupt-stop my-deployment

simulating network delays

$ ./test-harness delay -h                                                                         
Usage: delay [options] [name] [group]                                                                                                         

uses pumba to cause network delays for a livepeer group                                                                                       

Options:                                                                                                                                      
  -i --interval <interval>  recurrent interval for chaos command; use with optional unit suffix: 'ms/s/m/h'                                   
  -d --duration <duration>   network emulation duration; should be smaller than recurrent interval; use with optional unit suffix: 'ms/s/m/h'
  -h, --help                output usage information                                                                                          

to stop a network delay run the following command

./test-harness delay-stop my-deployment