Skip to content

Feat: add new tests and tescases for restful api suite - #15230

Merged
asiroliu merged 2 commits into
infiniflow:mainfrom
6ba3i:restful3
May 26, 2026
Merged

asiroliu merged 2 commits into
infiniflow:mainfrom
6ba3i:restful3

Conversation

@6ba3i

@6ba3i 6ba3i commented May 26, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

extend restful api suite

Type of change

  • New Feature (non-breaking change which adds functionality)
  • Other (please describe): test

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 26, 2026
@6ba3i 6ba3i added the ci Continue Integration label May 26, 2026
@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extends the dataset REST API test suite with comprehensive contract tests covering update, delete, list, get, and metadata operations. The additions include authorization validation, HTTP payload validation, field-specific validation matrices, concurrent operation coverage, and edge-case handling across 20 new test functions.

Changes

Dataset REST API Contract Tests

Layer / File(s) Summary
Test infrastructure and imports
test/testcases/restful_api/test_datasets.py
Module imports expanded to include UUID utilities, REST client, authorization token helpers, and file creation utilities for the contract test suite.
Dataset update contracts
test/testcases/restful_api/test_datasets.py
13 test functions validating dataset update endpoint behavior: authorization (missing/invalid tokens), HTTP payload and content-type validation, dataset ID/UUID format validation, avatar/description/name field constraints (length, MIME types, None handling), embedding model and permission validation, chunk method and pagerank validation, parser configuration defaults and invalid field matrices, and rejection of unsupported/extra fields.
Dataset delete contracts
test/testcases/restful_api/test_datasets.py
Contract tests for dataset deletion: authorization requirements, request validation (content-type, JSON), single deletion success, bulk deletion (1000 datasets), concurrent deletion (100 datasets), invalid UUID handling, unauthorized dataset rejection, duplicate ID handling, and unsupported field rejection.
Dataset list, get, and metadata contracts
test/testcases/restful_api/test_datasets.py
List operation tests covering authorization, pagination and filter parameter validation (orderby, desc, name, id filters), concurrent list retrieval; get operation tests for success, invalid/unauthorized/nonexistent dataset IDs; and metadata summary test uploading documents, patching per-document metadata fields, verifying aggregated summary counts, and handling invalid/nonexistent dataset summary errors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • infiniflow/ragflow#15223: Overlapping dataset update REST contract tests (chunk_method, parser_config validation/defaults, embedding_model/permission behavior, concurrent update stress); this PR extends coverage to delete, list, get, and metadata operations.

Suggested labels

ci

Poem

🐰 A hundred tests now hop and play,
Contracts validated every way,
Update, delete, list, and get—
No API edge will be unmet!
Each field is checked, each error known,
REST reliability fully grown! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title contains a typo ('tescases' instead of 'testcases') and is somewhat vague about the specific changes being made. Correct the typo to 'testcases' and consider a more specific title like 'Add comprehensive REST API contract tests for dataset operations' to better describe the scope of changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description follows the required template with both 'What problem does this PR solve?' and 'Type of change' sections completed, marking 'New Feature' and providing context about test additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@6ba3i
6ba3i marked this pull request as draft May 26, 2026 03:17
@6ba3i
6ba3i marked this pull request as ready for review May 26, 2026 03:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
test/testcases/restful_api/test_datasets.py (2)

1874-1913: 💤 Low value

Consider making bulk test sizes configurable.

The test creates 1,000 datasets for bulk delete and 100 for concurrent delete (1,100 total). While this provides good stress coverage, it may slow down CI/CD pipelines. Consider parameterizing these counts via environment variables or pytest configuration to allow faster runs in development environments while maintaining full coverage in nightly/release testing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_datasets.py` around lines 1874 - 1913, The
hardcoded loop sizes in test_dataset_delete_bulk_and_concurrent_contract
(range(1000) and range(100)) should be made configurable; replace the literal
counts by reading values from environment or pytest config (e.g.,
os.getenv("DATASET_BULK_COUNT") / os.getenv("DATASET_CONCURRENT_COUNT") or
pytest config/getoption) and fall back to the current defaults (1000 and 100) if
not set so bulk_ids and concurrent_ids generation uses these variables; update
any test parametrization or fixture as needed so CI/nightly can set larger
values while local/dev runs use smaller defaults.

602-646: 💤 Low value

Contract tests rely on exact error message strings.

The validation contract tests assert specific error message substrings (e.g., "String should have at most 65535 characters", "Invalid UUID1 format"). While this provides precise validation, it couples tests tightly to error message format. If the API changes error text, many tests will fail even though the contract (error code + general meaning) may still be correct.

This is an acceptable trade-off for contract testing, but be aware that error message refactoring will require coordinated test updates.

Also applies to: 671-716, 916-993, 1927-2146

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_datasets.py` around lines 602 - 646, The test
test_dataset_update_content_type_and_payload_contract (and other contract blocks
at the noted ranges) is brittle because it asserts exact error message
substrings; change these assertions to rely primarily on the numeric error codes
(e.g., code == 101/102) and, if needed, assert only a stable, small substring or
use regex matching for the high-level meaning (e.g., "Unsupported content type",
"Malformed JSON", "Invalid request payload") instead of full exact phrases like
"String should have at most 65535 characters" or "Invalid UUID1 format"; update
the specific assertions in this test (and the similar checks at 671-716,
916-993, 1927-2146) to assert error code equality and replace exact message
equality checks with contains/regex checks for the minimal stable text.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/testcases/restful_api/test_datasets.py`:
- Around line 1874-1913: The hardcoded loop sizes in
test_dataset_delete_bulk_and_concurrent_contract (range(1000) and range(100))
should be made configurable; replace the literal counts by reading values from
environment or pytest config (e.g., os.getenv("DATASET_BULK_COUNT") /
os.getenv("DATASET_CONCURRENT_COUNT") or pytest config/getoption) and fall back
to the current defaults (1000 and 100) if not set so bulk_ids and concurrent_ids
generation uses these variables; update any test parametrization or fixture as
needed so CI/nightly can set larger values while local/dev runs use smaller
defaults.
- Around line 602-646: The test
test_dataset_update_content_type_and_payload_contract (and other contract blocks
at the noted ranges) is brittle because it asserts exact error message
substrings; change these assertions to rely primarily on the numeric error codes
(e.g., code == 101/102) and, if needed, assert only a stable, small substring or
use regex matching for the high-level meaning (e.g., "Unsupported content type",
"Malformed JSON", "Invalid request payload") instead of full exact phrases like
"String should have at most 65535 characters" or "Invalid UUID1 format"; update
the specific assertions in this test (and the similar checks at 671-716,
916-993, 1927-2146) to assert error code equality and replace exact message
equality checks with contains/regex checks for the minimal stable text.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b1e9adb7-83c5-4599-b891-86a9fc256884

📥 Commits

Reviewing files that changed from the base of the PR and between 3dbd874 and b537851.

📒 Files selected for processing (1)
  • test/testcases/restful_api/test_datasets.py

@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.12%. Comparing base (c3b38d3) to head (b537851).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15230   +/-   ##
=======================================
  Coverage   93.12%   93.12%           
=======================================
  Files          10       10           
  Lines         713      713           
  Branches      116      116           
=======================================
  Hits          664      664           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asiroliu
asiroliu merged commit 036ed5b into infiniflow:main May 26, 2026
1 check passed
@6ba3i
6ba3i deleted the restful3 branch September 22, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants