write-flow-tests

Write Python end-to-end flow tests for RediSearch using the RLTest framework.

6.2k|596|Updated May 5, 2016
One-click install
npx skills add https://github.com/RediSearch/RediSearch --skill write-flow-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-flow-tests
Source: https://github.com/RediSearch/RediSearch/tree/main/.skills/write-flow-tests
Command: npx skills add https://github.com/RediSearch/RediSearch --skill write-flow-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing consistent, deterministic end-to-end tests for RediSearch requires knowing framework conventions, cluster behavior, and indexing timing rules that are easy to get wrong. This Skill codifies those conventions so new tests in tests/pytests/ follow the same patterns as existing ones.

Core Features & Use Cases

  • RLTest conventions: Enforces the standard pattern of creating indexes with env.expect('FT.CREATE', ...).ok(), loading data with conn.execute_command('HSET', ...), and asserting query results.
  • Determinism rules: Guides use of waitForIndex for background indexing, _FT.DEBUG hooks instead of sleeps, and full-result assertions with message=res for partial checks.
  • Cluster and environment handling: Covers @skip(cluster=True), {hash_tag} key prefixes, and when a custom Env() with protocol=3 or DEFAULT_DIALECT 1 is justified.
  • Use Case: When adding a test for a new FT.SEARCH dialect behavior, use this Skill to place the test in the right file, structure the function signature, and write deterministic assertions that pass on every machine.

Quick Start

Write a new Python flow test in tests/pytests/ that verifies prefix search behavior on a RediSearch index following the project guidelines.

Frequently Asked Questions about write-flow-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a flow test for RediSearch in Python?

Create a test function accepting env, build an index with env.expect('FT.CREATE', ...).ok(), load data via conn.execute_command('HSET', ...), then assert query results with env.cmd or env.expect. Place the test in tests/pytests/ near related functionality.

When should I use waitForIndex in RediSearch tests?

Call waitForIndex(env, 'idx') only when data existed before FT.CREATE, since background indexing must backfill. Data written after FT.CREATE is indexed synchronously, so no wait is needed.

How do I make RediSearch tests deterministic?

Avoid wall-clock timeouts, sleeps, and races with background indexing or GC. Use _FT.DEBUG hooks found in tests/pytests/ to control internal behavior, and compare full query results rather than partial checks.

Do RediSearch flow tests need to run in cluster mode?

Add @skip(cluster=True) to tests that do not exercise cluster-specific behavior to avoid redundant runs. Tests that must run in cluster mode should use {hash_tag} key prefixes so keys land on the same shard.

Why should tests avoid FT.ADD in RediSearch?

FT.ADD is deprecated and does not work in cluster mode. Load documents with conn.execute_command('HSET', ...) instead, which works across all deployment modes.