Skip to content
Snippets Groups Projects
user avatar
Jonas Theis authored
* Add docker compose for running integration tests.
Runs entry_node and arbitrary number of peers in docker network

* Fix permission denied in container if run without mounting a `rw` volume making it possible to run as throw-away container.
Remove `VOLUME` from Dockerfile as this only pollutes host system with anonymous volumes.

* Use named network for easier external use

* Add test container that discovers peers and waits for autopeering to happen

* Fix min waitForNeighbors

* Add go.sum

* Run integration tests with Github Actions

* Added framework that abstracts the docker network and provides convenience functionality

* Update directory in Github Actions

* Add bash script for automated local test execution

* Add getMessageByHash endpoint

* Adjust to merge changes

* Add methods to easily do HTTP POST requests

* Added relay message test

* Increase client timeout

* Verbose output for tests makes it easier to follow the execution

* Introduce small API wrapper for GoShimmer HTTP API

* Adjust relay test to use new API wrapper

* WIP: Docker logs

* Fix issue with serving visualizer analysis server of entry node

* Persist logs of containers after CI run

* Fix test file

* Fix uploading of artifacts

* Save all containers' logs as artifacts

* Create logs files also with local run

* Add possibility to retrieve logs from a peer via Docker logs

* Make tester part of the goshimmer module to make code sharing possible

* Use client/lib to make HTTP requests in tester

* Fix unit test directory

* Add comments/doc to the code

* Add readme

* Move tester to own module and don't build container but use existing golang one instead

* Address PR comments

* Adjust to merge

* Only use 1 config file for all containers

* go mod tidy

* Rename client lib base url
14948393
History

Integration tests with Docker

Integration testing setup

Running the integration tests spins up a GoShimmer network within Docker as schematically shown in the figure above. N defines the number of peer_replicas and can be specified when running the network. The peers can communicate freely within the Docker network and this is exactly how the tests are run using the tester container. Test can be written in regular Go style while the framework provides convenience functions to access a specific peer's web API or logs.

The autopeering network visualizer, master_peer's dashboard and web API are reachable from the host system on the respective ports.

The different containers (entry_node, peer_master, peer_replica) load separate config files that can be modified as necessary, respectively.

How to run

Prerequisites:

  • Docker
  • Docker compose
# Mac & Linux
./runTests.sh

The tests produce *.log files for every peer in the logs folder after every run.

Currently, the integration tests are configured to run on every push to GitHub with peer_replica=5. The logs of every peer are stored as artifacts and can be downloaded for closer inspection once the job finishes.

Creating tests

Tests can be written in regular Go style. Each tested component should reside in its own test file in tester/tests. main_test with its TestMain function is executed before any test in the package and initializes the integration test framework.

Use as development tool

Using a standalone throwaway Docker network can be really helpful as a development tool as well.

Reachable from the host system

It is therefore possible to send messages to the local network via the master_peer and observe log messages either via docker logs --follow CONTAINER or by starting the Docker network without the -d option, as follows.

docker-compose -f docker-compose.yml up --scale peer_replica=5

# 1. test manually with master_peer

# 2. or run in separate terminal window
docker-compose -f tester/docker-compose.yml up --exit-code-from tester

Sometimes when changing files, either in the tests or in GoShimmer, Docker does not detect the changes on a rebuild. Then the option --build needs to be used with docker-compose.