Skip to content

test: Add regression coverage for RedisVL CLI foundation contracts#596

Open
limjoobin wants to merge 45 commits into
mainfrom
test/RAAE-1558/redisvl-cli-regression-test
Open

test: Add regression coverage for RedisVL CLI foundation contracts#596
limjoobin wants to merge 45 commits into
mainfrom
test/RAAE-1558/redisvl-cli-regression-test

Conversation

@limjoobin
Copy link
Copy Markdown
Contributor

@limjoobin limjoobin commented Apr 29, 2026

Changes

In this PR, we reinforce our test coverage of redisVL CLI foundation contracts.
For CLI foundation contracts, the following were verified for correctness:

  • sydout/stderr output
  • system exit codes
  • usage errors
  • runtime failures
  • human-readable success paths
  • JSON success paths

Note: This PR merges commits from:


Note

Low Risk
Changes are limited to unit tests; they document and guard existing CLI behavior without modifying runtime code in this diff.

Overview
This PR expands CLI regression tests only (no production redisvl/cli changes in the diff). It replaces shallow fake-Redis tests with contract-focused coverage for rvl, rvl index, and rvl stats.

Top-level CLI (test_cli_main.py): new tests assert help lists index, mcp, version, and stats (in-process and via python -m redisvl.cli.runner), and that unknown commands exit 2 with errors on stderr and empty stdout.

Index CLI (test_cli_index.py): adds help/subprocess help checks, a real Redis index fixture for listall/info, success assertions for create (exact success banner; --json does not add JSON), JSON shape checks for listall and info, human-output smoke tests, and parametrized usage errors (exit 2) vs runtime/Redis failures (exit 1, no stdout JSON).

Stats CLI (test_cli_stats.py): mirrors the same patterns—help, runner subprocess, real-index JSON/table success, _stats_rows ordering, usage exit 2, and runtime RedisSearchError/generic errors exit 1 with empty stdout on --json failure paths.

Reviewed by Cursor Bugbot for commit c7d67fa. Bugbot is set up for automated code reviews on this repo. Configure here.

limjoobin and others added 30 commits April 24, 2026 18:51
- add_json_output_flag for --json on argparse parsers
- cli_print_json for single-object stdout; bytes-safe default

Made-with: Cursor
Print {"version": <package>} to stdout; --json overrides --short

Made-with: Cursor
- tests for add_json_output_flag, cli_print_json, Version

Made-with: Cursor
Align rvl index and stats:
usage problems exit 2 with messages on stderr,
Redis/search failures exit 1,
success on stdout.
Share schema and RedisSearchError handling via redisvl.cli.utils helpers.
Move SCHEMA_INPUT_ERRORS handling into _connect_to_index (match index CLI)
so ValueError from the stats display path is not misclassified as exit 2.

Made-with: Cursor
Co-authored-by: Vishal Bala <vishal-bala@users.noreply.github.com>
Co-authored-by: Vishal Bala <vishal-bala@users.noreply.github.com>
Move SCHEMA_INPUT_ERRORS, exit_schema_input_error, and
exit_redis_search_error from utils into index.py and stats.py so CLI
behavior is visible next to each command. utils keeps URL and argparse
helpers only.

Made-with: Cursor
@limjoobin limjoobin self-assigned this Apr 29, 2026
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented Apr 29, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@limjoobin limjoobin marked this pull request as ready for review May 6, 2026 13:12
@limjoobin limjoobin requested review from vishal-bala May 6, 2026 13:12
Copy link
Copy Markdown
Collaborator

@vishal-bala vishal-bala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a decent amount of structure in place to fake the Redis part of the tests, but when we run the tests, we typically have a Redis instance available. Would it simplify a lot of the code to just use a real Redis instance instead of faking it, or do you think that's messier than it's worth?

Comment thread tests/unit/test_cli_index.py
Comment thread tests/unit/test_cli_index.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants