Testing Parallel Executions
Explore how to use PropEr to transform sequential stateful tests into parallel ones that can reveal concurrency issues. Understand the process of generating parallel command sequences, handling Erlang scheduler challenges, and applying fixes to ensure safe concurrent cache operations. This lesson equips you with practical methods for detecting and resolving concurrency bugs.
We'll cover the following...
Getting started
One of the most interesting features of stateful tests with PropEr is taking the models we write for sequential ones and automatically turning them into parallel tests that have a decent chance at finding concurrency bugs in our code at nearly no cost. It requires just a few minor changes to the property, and the rest is done for us.
The way it works is conceptually simple. The framework first takes the existing command generation mechanism and then builds a sequence. It should look something like the following in abstract terms:
It next picks a common root of operations. Let’s say in this case A -> B is shared by all operations that follow them both. PropEr will take the remaining chain and split it up in concurrent timelines based on some elevated analysis, generating something like this:
This new sequence will be represented as a tuple of the form {SequentialRoot, [LeftBranch, RightBranch]}. PropEr will run the common sequential root, and then run both alternative branches in parallel in an attempt to surface any bugs. It will check the model for any possible ...