Seed keys into Redis, and check the keys your services write there: their values, their JSON properties or hash fields, and that they are gone. Every server that speaks Redis’s protocol works: Redis, Valkey, Dragonfly, KeyDB, Garnet.
Register the server once, usually in the Background; every Redis step of the scenario uses it:
Given the cache redis server with the following properties: | url | redis://localhost:6379/0 |- A key is shown as JSON, whatever its type: a string holding JSON as that JSON (other text as a string), a hash as an object of its fields, a list as an array, a set as a sorted array, and a sorted set as an object of its members and their scores.
has the following properties:reads paths into it. - Checks wait for the key to be as they say, 10 seconds unless
within {duration}says otherwise. - Scenarios share the server, so each seeds and checks keys of its own, named after data unique to it, such as a parcel reference.
- Secrets stay secret: a password in the URL, or from
${env:..}, is masked in logs and failures.
Add it to a project with axx pack add redis.
redis.server
Section titled “redis.server”Given the {word} redis server with the following properties: | property | value |The table may start with the row naming its columns, as above, or go straight to its rows.
Register the Redis server the steps talk to.
- The first server registered is the one the scenario’s Redis steps use.
- Values expand
${env:..}and${sys:..};${env:..}values are masked.
| Parameter | Takes | For example |
|---|---|---|
{word} |
one word, with no spaces | parcels, PX-4101 |
| Property | Takes | Default |
|---|---|---|
url |
the server’s URL: redis://user:password@host:6379/0, or rediss:// for TLS |
required |
database |
the database number, instead of the URL’s |
Example:
Given the cache redis server with the following properties: | url | redis://localhost:6379/0 |Since 0.1.5.
redis.seed
Section titled “redis.seed”Given a {filepath} redis seedWrite the keys of a YAML or JSON file to the scenario’s Redis server, replacing any keys of those names.
The file maps each key to one of value (text, or JSON for an object or an array), hash (its fields), list, set or sorted set (members and their scores), and optionally a ttl (like 10m) after which it expires.
| Parameter | Takes | For example |
|---|---|---|
{filepath} |
a file of the project: a path relative to the feature file’s directory, the resources directories or axx.yaml’s directory (looked for in that order), or an absolute path, quoted when it has a space |
seeds/parcels.yaml, kafka/scan-delivered.json |
Example:
Given a seeds/quote-cache.yaml redis seedSince 0.1.5.
redis.value
Section titled “redis.value”Then [[within {duration} ]]the {word} redis key has the value {string}Check that the key holds that text. The check waits for it: 10 seconds, or within {duration}.
- The key must be a string key; for the others, check their properties.
| Parameter | Takes | For example |
|---|---|---|
{duration} |
a duration in seconds (s) or minutes (m) |
5s, 2m |
{word} |
one word, with no spaces | parcels, PX-4101 |
{string} |
text in double or single quotes, which the step leaves out | "Get a quote", 'Express' |
Variants, the parts in [[...]] said or left out:
the {word} redis key has the value {string}within {duration} the {word} redis key has the value {string}
Example:
Then within 10s the quote:DE-1:STANDARD:1200 redis key has the value '690'Since 0.1.5.
redis.properties
Section titled “redis.properties”Then [[within {duration} ]]the {word} redis key has the following properties: | path | value |The table may start with the row naming its columns, as above, or go straight to its rows.
Check that the key, shown as JSON, has the properties of the table. The check waits for it: 10 seconds, or within {duration}.
- A string key holding JSON is that JSON; a hash is an object of its fields; a list an array; a set a sorted array; a sorted set an object of its members and their scores.
| Parameter | Takes | For example |
|---|---|---|
{duration} |
a duration in seconds (s) or minutes (m) |
5s, 2m |
{word} |
one word, with no spaces | parcels, PX-4101 |
Each row is a path into the key’s JSON (a field name, a dotted path or a JSONPath) and the value it has, compared as text: null for null and undefined for absent.
Variants, the parts in [[...]] said or left out:
the {word} redis key has the following properties:within {duration} the {word} redis key has the following properties:
Example:
Then within 10s the quote:DE-1:STANDARD:1200 redis key has the following properties: | priceCents | 690 | | currency | EUR |Then the shop:hawthorn-home redis key has the following properties: | tier | gold |Since 0.1.5.
redis.absent
Section titled “redis.absent”Then [[within {duration} ]]the {word} redis key does not existCheck that the key does not exist, or waits for it to go: 10 seconds, or within {duration}, for a service that deletes it or lets it expire.
| Parameter | Takes | For example |
|---|---|---|
{duration} |
a duration in seconds (s) or minutes (m) |
5s, 2m |
{word} |
one word, with no spaces | parcels, PX-4101 |
Variants, the parts in [[...]] said or left out:
the {word} redis key does not existwithin {duration} the {word} redis key does not exist
Example:
Then within 10s the tracking:PX-RDS-9603 redis key does not existSince 0.1.5.