Testing a distributed datastore
A distributed datastore needs to be consistent. You put data into it, get a successful response, fetch it in the future, and it matches your expectation. While it’s easy enough to write a script that inserts and reads key-value pairs, making it into a meaningful test that simulates production conditions — with parallel requests, a varied cadence, and a faulty environment — is more complicated. Antithesis simplifies this greatly by providing a Test Composer — a framework that takes care of the parallelism, variation in command order, and more. All you need to provide are the basic functions that exercise the system.Create a test command
Create a new directory in your client.generate_num_requests.
parallel_driver_<name> — in this case, parallel_driver_generate_traffic.py.
put_request to be unsuccessful during faults, and it should not break the system.
You’ve inserted some data into the distributed datastore. Now see if the values match.
validate_puts will fetch and match the value for all the successfully inserted keys.
values_stay_consistent should be true and mismatch should be None.
Add some Assertions to validate
Assertions express properties your system should have, and Antithesis relies on assertions to understand what you’re testing for. Assertions in Antithesis describes the mechanics in a lot more detail. Antithesis’s SDKs provide many types of assertions, but we’ll only use two here. The first is an Always assertion — these assertions are similar to the programming assertions you’re familiar with, but they don’t crash your program. They create a property that Antithesis will test, and list in the triage report as passing or failing. You always want the datastore to be consistent. So, in your parallel driver command,values_stay_consistent must always be true.
Add an always assertion to test that:
Build your client
Now you have a test template with one test command to exercise the etcd cluster. To package it, add instructions in theDockerfile.client:
parallel-driver script is.
$TENANT_NAME with your tenant’s name.
client.yaml in your manifests/ directory. The client containers must be kept running for Antithesis to keep testing. Add a sleep infinity entrypoint for them.
config image:
In practice, you might want to check your test commands and set up locally before running it in Antithesis.
Run your test
Call thebasic_test webhook again endpoint with this updated curl command:
Remember to change user, password, <tenant>, and antithesis.report.recipients accordingly.
v2 of the config image. Also, remember to replace $USER, $PASSWORD, $TENANT_NAME and the antithesis.report.recipients email addresses.
The test is set up to run for 30 minutes this time. To view the progress and results of your test, go to your Runs page at https://$TENANT_NAME.antithesis.com/runs and click the Triage results button to see your report when it finishes. You’ll also receive an email when the run completes.