Skip to content

Use fast-check to test concurrency consistency invariants #382

@CMCDragonkai

Description

@CMCDragonkai

Specification

We are likely to have alot of concurrency consistency invariants to test. EFS showed us alot of potential pitfalls and bugs in race conditions. SI helps at least ensure that we always have consistency at the DB layer, however it turns out testing concurrency is always really complicated and involves some overhead. Simple expect tests are not enough.

Here comes https://github.com/dubzzz/fast-check, it's a property based testing based on quickcheck. This can be used for quick light-weight model based testing.

Primarily quick-check related libraries provide 2 things:

  1. A quick way of generating random data according to some schema, which is useful for any kind fuzzing (and we saw how fuzzing was useful in solving our DB encoding issues)
  2. And a way to specify models and testing software if they fit our models.

While other model-based testing tools such as ModelJUnit 1 are perfectly valid alternatives, as a model-based testing tool, we selected QuickCheck [4] for the fact that it provides test case shrinking functionality whereby upon detecting a failure, it searches for smaller test cases which also generate the fault to aid debugging. Although initially developed as a tool for the Haskell programming language, it has been implemented on a number of platforms and for this work, we utilise the Erlang implementation [2]. QuickCheck is primarily a random test data generation tool but it also supports model-based testing. Given a model and a set of pre and postconditions, the tool is able to automatically generate test cases which are used to verify that the conditions hold in the context of different sequences of actions.

So we should see if fast-check can help us do concurrency testing in a number of domains:

  1. Our network domain has lots of concurrency issues
  2. Vaults domain - lots of reads/writes here
  3. Nodes domain - lots of management of nodes
  4. Gestalts and ACL domain

Additional context

Tasks

  1. Investigate how fast-check can help with concurrent tests and fuzz tests
  2. Investigate how to integrate fast-check into jest testing including timeouts and reporting
  3. Apply fast-check to EFS tests and PK tests

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions