Skip to content

Instantly share code, notes, and snippets.

@dopatraman
Created September 7, 2018 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dopatraman/d00f9dbb4e35fe4b2f6f6d0c35be37f7 to your computer and use it in GitHub Desktop.
Save dopatraman/d00f9dbb4e35fe4b2f6f6d0c35be37f7 to your computer and use it in GitHub Desktop.
System Test Plan

System Test Plan

The goal of this plan is to test the end-to-end functionality of our entire system.

The system consists of 4 parts:

  1. Trader App
  2. Ledger
  3. Orderbook
  4. Verifiers

These tests will mock the interactions between these 4 services, most specifically the communication between the Orderbook, Ledger, and Verifiers.

API + Contract

Transport

Each API contract will implement HTTP endpoints. Future specs may use other methods of transport (websockets, MQ, etc). Any changes in communication protocol should be recorded here.

Contract

Each Verifier will present a common public API:

  • POST -> <path>/verify
  • POST -> <path>/verify/<entity>

Request

The payload should have this schema:

{
    target: Verifiable,
    signature: String
}

Where a Verifiable is any quantity that can be signed with a public key, and the signature is the string produced by the signing function.

** Verifiable definition: TBD **

Response

Each of which will return a Vouch struct serialized into JSON:

{
    details_hash: String,
    verifier_type: Int,
    signature: String,
    public_key: String,
    vouch: Boolean
}

Extended Functionality

Some Verifiers may have the mandate to perform functions outside of verification. The Ledger is one Verifier that fits this description. Verifiers that have other responsibilities may implement endpoints under the action/ scope:

scope "<path>/action", LedgerWeb do
    post("/update_balance, BalanceController, :update_balance)
    ...
end

Private state

Some verifiers will keep state. Thorough tests will query verifiers throughout the verification workflow to ensure that test is being stored and sent properly.

Any verifier that keeps private state should implement the following endpoint:

  • GET -> <path>/state

which will be cordoned off for the test environment with some kind of configuration value:

scope <path>, LedgerWeb do
    if @include_black_listed_routes do
        post("/state", EntriesController, :get_state)
    end
end

Containerization

Part of maintaining a secure, distributed, multi-service system is being able to reliably reproduce a scaled down version for testing. We can spin up and network docker containers for each service with a single compose file.

Some services will need to maintain databases. These, like the Ledger, can expose ports via the compose file only during tests.

Running the tests

The system tests will live at the root of the project in a test/ folder. A compose file in this directory will start containers for each of the services, ideally using a Dockerfile made specifically for testing.

Unfortunately, docker-compose doesn't have startup hooks (yet). So we'll have to spin up all the containers with docker-compose up, and in a second terminal window run the testing command (mix test etc).

If we want to automate these tests to run on CI, a bash script that unites these two commands might be the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment