Skip to content

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

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

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

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
@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds comprehensive REST API contract test coverage for dataset update operations, including tests for name deduplication (case-insensitive), metadata field persistence, chunk method and parser configuration updates with default fallback behavior, embedding model authorization-conditional outcomes, permission normalization, and concurrent update stress testing.

Changes

Dataset Update REST API Contract Tests

Layer / File(s) Summary
Test imports and setup
test/testcases/restful_api/test_datasets.py
Import block extended with os module and reordered to place pytest before concurrent.futures imports.
Basic metadata field updates
test/testcases/restful_api/test_datasets.py
Tests validate updating dataset name (case-insensitive duplicate detection), language, connectors, avatar (base64), and description fields with persistence verification across successive PUT requests.
Chunk method and parser config updates
test/testcases/restful_api/test_datasets.py
Parameterized tests ensure chunk_method can be updated across all supported values and that parser_config updates persist with proper default fallback behavior when chunk method changes or parser_config is cleared/unset.
Embedding model updates
test/testcases/restful_api/test_datasets.py
Tests cover updating embedding_model with authorization-conditional outcomes (xfail when tenant model unavailable), format validation (error code/message assertions), updating when chunks exist (iterating candidate models and xfail when no authorized alternative available).
Permission and pagerank updates
test/testcases/restful_api/test_datasets.py
Tests validate updating permission field with response normalization verification, environment-dependent pagerank skipping/handling, distinct behavior for non-elasticsearch engines (error assertions), and concurrent update stress test confirming all requests return code == 0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • infiniflow/ragflow#15208: Both PRs add extensive test/testcases/restful_api/test_datasets.py contract coverage for dataset payload fields like chunk_method, parser_config (including valid-matrix/default/unset behavior), and embedding_model, with this PR targeting the update endpoint while the retrieved PR targets create.

Suggested labels

ci

Poem

🐰 Tests multiply like rabbits in the field,
Dataset updates thoroughly revealed,
Chunk methods, embeddings, permissions—all in sight,
From concurrent stress to config delight,
REST contracts verified, specifications tight! 🧪✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title mentions 'tests and testcases' for the restful api suite, which aligns with adding comprehensive REST API dataset update contract tests, but contains a typo ('tescases') and is slightly vague about the specific scope.
Description check ✅ Passed The description covers the required template sections with a stated problem ('extend restful api suite') and proper type of change selection, though the problem statement is brief and lacks detailed context about what specifically is being extended.
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 added the ci Continue Integration label May 26, 2026
@6ba3i
6ba3i marked this pull request as draft May 26, 2026 01:46
@6ba3i
6ba3i marked this pull request as ready for review May 26, 2026 01:46

@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.

Actionable comments posted: 1

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

375-392: ⚡ Quick win

Add lightweight logging in new environment-dependent and concurrent update flows.

The new update suite introduces xfail, skipif(DOC_ENGINE), and concurrent request paths; adding debug logs for payload/code outcomes will make flaky triage much faster without changing assertions.

As per coding guidelines, "**/*.py: Add logging for new flows".

Also applies to: 487-560, 564-581

🤖 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 375 - 392, In
test_dataset_update_embedding_model_contract add lightweight debug logging using
the module logger (e.g., logger = logging.getLogger(__name__)) to record
create_res.status_code, create_payload (create_res.json()),
update_res.status_code and update_payload (update_res.json()), and log the
xfail/skip branch details before calling pytest.xfail so you can see the
payload/code outcomes; apply the same pattern to the other update tests
referenced (the functions covering lines ~487-560 and ~564-581) so every
environment-dependent or concurrent update path logs response status and JSON
payloads for faster triage while keeping existing assertions unchanged.

157-174: ⚡ Quick win

Remove duplicated ids maintenance in parametrized matrices.

The explicit ids=[...] duplicates the case-name data and is easy to desync when editing. Generate IDs from the case tuples to keep one source of truth.

Suggested pattern
 `@pytest.mark.parametrize`(
     "name, parser_config",
     [
         ("auto_keywords_min", {"auto_keywords": 0}),
         ...
     ],
-    ids=[
-        "auto_keywords_min",
-        ...
-    ],
+    ids=lambda c: c[0],
 )

Also applies to: 193-303

🤖 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 157 - 174, The
pytest.mark.parametrize call that passes "chunk_method" currently repeats the
same list in both the values and the ids which risks desync; update the
decorator (the parametrize for "chunk_method") to remove the explicit ids
argument and instead let pytest auto-generate IDs or generate them
programmatically from the values list (e.g., map str over the chunk_method list)
so there's a single source of truth; apply the same change to the other
parametrized matrices in this file that duplicate ids (the other parametrize
blocks around lines 193–303).
🤖 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.

Inline comments:
In `@test/testcases/restful_api/test_datasets.py`:
- Around line 403-405: The two parametrized test cases
("whitespace_only_model_name" and "whitespace_only_provider") currently expect
the generic error "Both model_name and provider must be non-empty strings";
update their expected error fragment (the third element of each tuple) to the
validator's whitespace-specific message emitted for whitespace-only inputs
(replace the third field in the tuples for "whitespace_only_model_name" and
"whitespace_only_provider" with the exact whitespace-specific error string from
the validator so the test matches upstream behavior).

---

Nitpick comments:
In `@test/testcases/restful_api/test_datasets.py`:
- Around line 375-392: In test_dataset_update_embedding_model_contract add
lightweight debug logging using the module logger (e.g., logger =
logging.getLogger(__name__)) to record create_res.status_code, create_payload
(create_res.json()), update_res.status_code and update_payload
(update_res.json()), and log the xfail/skip branch details before calling
pytest.xfail so you can see the payload/code outcomes; apply the same pattern to
the other update tests referenced (the functions covering lines ~487-560 and
~564-581) so every environment-dependent or concurrent update path logs response
status and JSON payloads for faster triage while keeping existing assertions
unchanged.
- Around line 157-174: The pytest.mark.parametrize call that passes
"chunk_method" currently repeats the same list in both the values and the ids
which risks desync; update the decorator (the parametrize for "chunk_method") to
remove the explicit ids argument and instead let pytest auto-generate IDs or
generate them programmatically from the values list (e.g., map str over the
chunk_method list) so there's a single source of truth; apply the same change to
the other parametrized matrices in this file that duplicate ids (the other
parametrize blocks around lines 193–303).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 34ed86fd-82e7-4d33-a951-15fb8ea88b74

📥 Commits

Reviewing files that changed from the base of the PR and between 4b36801 and 7ff1329.

📒 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 (af85aa9) to head (7ff1329).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15223   +/-   ##
=======================================
  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 c3b38d3 into infiniflow:main May 26, 2026
1 check passed
@6ba3i
6ba3i deleted the restful2 branch May 26, 2026 02:25
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