Redis-lettuce plugin
The Redis-lettuce plugin connects QALIPSIS to Redis.
- Technology addressed
-
Redis: https://redis.io/
- Dependency
-
io.qalipsis.plugin:qalipsis-plugin-redis-lettuce - Namespace in scenario
-
redisLettuce() - Client library
-
Lettuce: refer to Lettuce.
- Supported steps
Example scenarios using a combination of Redis supported steps are provided on Github.
Poll step
The poll step within the Redis-lettuce plugin polls the newest records from a Redis key, with a delay between each execution of polling.
- Ancestor
-
Scenario
- Functionality
-
The
pollstep is created only once in a scenario; it is then used throughout the scenario as called.-
The
KeyOrPatternto be used in the poll is set to one of the following valid values:scan,sscan,hscan,zscan. -
The native Redis-lettuce command is called using the
KeyOrPatternprovided.
-
- Example
-
it.redisLettuce() .pollSscan { connection { nodes = listOf("localhost:6379") database = 0 redisConnectionType = RedisConnectionType.SINGLE authUser = "Celia45" authPassword = "Columbus1963" } keyOrPattern("battery_state_save_and_poll") pollDelay(Duration.ofSeconds(1)) } - Notable parameters
-
-
Connection(required): specifies the connection parameters. -
redisConnectionType(required): indicates the connection type asSINGLE,CLUSTERorSENTINEL. -
KeyOrPattern(required): specifies the key or pattern that will be polled after eachpollDelay. -
pollDelay(required): specifies the delay between query executions. -
broadcast(optional): specifies the broadcast parameters for the step.
-
- Tips
-
-
Use the
pollstep with a join operator when you need to verify the values saved by your tested system in the database. -
In addition to SSCAN (
pollSscanin the example), thepollstep also supports the following Redis commands: HSCAN (polllHscan) SCAN (pollScan), and ZSCAN (pollZscan).
-
- Reference documentation
-
-
For more information on the
SENTINELredisConnectionType, refer to: Redis discovery using Redis Sentinel. -
Refer to the Redis documentation for further parameter and configuration information.
-
Save step
The save step within the Redis-lettuce plugin persists a batch of records into Redis.
- Ancestor
-
Step
- Functionality
-
The
savestep’s input and step context are used to generate a valid Redis command and the values to complete it; the batch of results is then forwarded to the next step(s). The records are saved individually. - Example
-
.redisLettuce() .save { connection { nodes = listOf("localhost:6379") database = 0 redisConnectionType = RedisConnectionType.SINGLE authUser = "Celia45" authPassword = "Columbus1963" } records { _, input -> listOf( SetRecord("battery_state_save_and_poll", objectMapper.writeValueAsString(input) ) ) } } - Notable parameters
-
-
Connection(required): specifies the connection parameters. -
redisConnectionType(required): indicates the connection type asSINGLE,CLUSTERorSENTINEL. -
records(required): generates and configures a list of saved records.
-
- Tip
-
-
The
savestep supports the following Redis commands: SET, SADD, HSET, ZADD. The provided command may depend on the context and input value received from the previous step. -
If the
redisConnectionTypeis set toSENTINEL, the parametermasterIdis necessary.
-
- Reference documentation
-
-
For more information on the
SENTINELredisConnectionType, refer to: Redis discovery using Redis Sentinel. -
Refer to the Redis documentation for further parameter and configuration information.
-
Consume step
The consume step within the Redis-lettuce plugin records data from Redis streams.
- Ancestor
-
Scenario
- Functionality
-
The
consumestep creates a consumer group in a Redis stream with the providedconnection, consumergroupname, andconcurrency. Ifconcurrencyis set to 1, records are transmitted sequentially to the next step. - Example
-
redisLettuce() .streamsConsume { connection { nodes = redis://localhost:6439 database = 0 redisConnectionType = RedisConnectionType.SINGLE authUser = "Celia45" authPassword = "Columbus1963" } streamKey("battery_state_produce_and_consume") offset(LettuceStreamsConsumerOffset.FROM_BEGINNING) group("consumer") } - Notable parameters
-
-
connection(required): configures the connection to QALIPSIS. -
redisConnectionType(required): indicates the connection type asSINGLE,CLUSTERorSENTINEL. The default isSINGLE. -
offset(required): sets the offset value toFROM_BEGINNING,LAST_CONSUMEDorLATESTfor each topic and consumer group. -
broadcast(optional): specifies the broadcast parameters for the step.
-
- Tip
-
If
redisConnectionTypeis set toSENTINEL, the parametermasterIdis necessary. - Reference documentation
-
-
For more information on the
SENTINELredisConnectionType, refer to: Redis discovery using Redis Sentinel. -
Refer to the Redis documentation for further parameter and configuration information.
-
Produce step
The produce step within the Redis-lettuce plugin produces records into the Redis streams.
- Ancestor
-
Step
- Example
-
.redisLettuce() .streamsProduce { connection { nodes = listOf("localhost:6379") database = 0 redisConnectionType = RedisConnectionType.SINGLE authUser = "Celia45" authPassword = "Columbus1963" } records { _, input -> listOf( LettuceStreamsProduceRecord( key = "battery_state_produce_and_consume", value = mapOf( "device_id" to input.deviceId, "timestamp" to input.timestamp.epochSecond.toString(), "battery_level" to input.batteryLevel.toString() ) ) ) } } - Notable parameters
-
-
redisConnectionType(required): sets the connection type asSINGLE,CLUSTERorSENTINEL. -
records(required): generates and configures a list of produced records.
-
- Tip
-
-
If
redisConnectionTypeis set toSENTINEL, the parametermasterIdis necessary.
-
- Reference documentation
-
-
For more information on the
SENTINELredisConnectionType, refer to: Redis discovery using Redis Sentinel. -
Refer to the Redis documentation for further parameter and configuration information.
-