Skip to content

[CI] 【Hackathon 9th Sprint No.38】NO.38 功能模块单测补充 - #5060

Merged
CSWYF3634076 merged 18 commits into
PaddlePaddle:developfrom
xunyoyo:fastdeploy/scheduler/global_scheduler.py
Dec 19, 2025
Merged

CSWYF3634076 merged 18 commits into
PaddlePaddle:developfrom
xunyoyo:fastdeploy/scheduler/global_scheduler.py

Conversation

@xunyoyo

@xunyoyo xunyoyo commented Nov 15, 2025 •

Copy link
Copy Markdown
Contributor

This file contains tests for the global scheduler, including request handling, load accounting, and response management.

Motivation

NO.38 功能模块 fastdeploy/scheduler/global_scheduler.py 单测补充

Modifications

new dir and add tests/scheduler/test_global_scheduler.py

Usage or Command

tests/scheduler/test_global_scheduler.py:

python -m coverage run -m unittest tests.scheduler.test_global_scheduler \
&& python -m coverage report -m --include='fastdeploy/scheduler/global_scheduler.py'

Accuracy Tests

原来的覆盖:

Microsoft Edge 2025-12-15 18 16 17

tests/scheduler/test_global_scheduler.py:

image

覆盖 ++270 行

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

This file contains tests for the global scheduler, including request handling, load accounting, and response management.
Copilot AI review requested due to automatic review settings November 15, 2025 10:40
@paddle-bot

paddle-bot Bot commented Nov 15, 2025

Copy link
Copy Markdown

Thanks for your contribution!

Copilot AI 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.

Pull Request Overview

This PR adds comprehensive unit tests for the global scheduler module (fastdeploy/scheduler/global_scheduler.py) as part of Hackathon 9th Sprint No.38. The tests use pytest with custom fixtures and mocks to achieve 83% code coverage.

Key Changes

  • Implements fake Redis and worker implementations for isolated testing
  • Tests request handling, load balancing, request stealing, and response routing
  • Adds tests for scheduler configuration and reset functionality
  • Includes helper function tests for block calculation and request/response marking


def test_get_requests_requeues_when_chunked_limits_hit(scheduler_fixture):
scheduler, fake_redis = scheduler_fixture
envs.FD_ENABLE_MAX_PREFILL = 0

Copilot AI Nov 15, 2025

Copy link

Choose a reason for hiding this comment

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

Directly modifying envs.FD_ENABLE_MAX_PREFILL without restoring it can lead to test isolation issues. Consider using monkeypatch.setattr(envs, "FD_ENABLE_MAX_PREFILL", 0) to ensure the value is automatically restored after the test completes.

Copilot uses AI. Check for mistakes.

def test_get_requests_blocking_pop_returns_when_idle(scheduler_fixture):
scheduler, fake_redis = scheduler_fixture
envs.FD_ENABLE_MAX_PREFILL = 0

Copilot AI Nov 15, 2025

Copy link

Choose a reason for hiding this comment

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

Directly modifying envs.FD_ENABLE_MAX_PREFILL without restoring it can lead to test isolation issues. Consider using monkeypatch.setattr(envs, "FD_ENABLE_MAX_PREFILL", 0) to ensure the value is automatically restored after the test completes.

Copilot uses AI. Check for mistakes.
Comment thread tests/scheduler/test_global_scheduler.py Outdated
Comment thread tests/scheduler/test_global_scheduler.py Outdated
Comment thread tests/scheduler/test_global_scheduler.py Outdated
Comment on lines +5 to +6
python -m coverage run -m pytest tests/scheduler/test_global_scheduler.py \
&& python -m coverage report -m --include='fastdeploy/scheduler/global_scheduler.py'

Copilot AI Nov 15, 2025

Copy link

Choose a reason for hiding this comment

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

The command in the docstring uses pytest (python -m coverage run -m pytest), but the PR description specifies unittest (python -m unittest tests.scheduler.test_global_scheduler). These should be consistent. Since the tests use pytest fixtures, the docstring appears correct, but this inconsistency with the PR description may confuse users.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,431 @@
"""Tests for the global scheduler.

Copilot AI Nov 15, 2025

Copy link

Choose a reason for hiding this comment

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

Missing the Apache 2.0 license header that is present in all other test files in this repository. The copyright header should be added at the top of the file following the project's convention:

"""
# Copyright (c) 2025  PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""

Copilot uses AI. Check for mistakes.
Comment thread tests/scheduler/test_global_scheduler.py Outdated
@codecov-commenter

codecov-commenter commented Dec 15, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@d739af5). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #5060   +/-   ##
==========================================
  Coverage           ?   64.43%           
==========================================
  Files              ?      329           
  Lines              ?    41756           
  Branches           ?     6388           
==========================================
  Hits               ?    26906           
  Misses             ?    12798           
  Partials           ?     2052           
Flag Coverage Δ
GPU 64.43% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@lddfym

lddfym commented Dec 18, 2025

Copy link
Copy Markdown
Collaborator

1.可以参考下 copilot 给出的建议
2.需要增加一些注释

xunyoyo and others added 9 commits December 18, 2025 17:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Updated comments and docstrings in Chinese to enhance clarity for native speakers.
Replaced direct assignment with monkeypatching for FD_ENABLE_MAX_PREFILL in test cases.
Fix function definitions and update test cases for scheduler.
Fix typos in global scheduler tests
@EmmonsCurse

Copy link
Copy Markdown
Collaborator

@xunyoyo Please confirm your changes carefully and avoid triggering the job repeatedly. Otherwise, trigger permissions may be revoked.

image

@xunyoyo

xunyoyo commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

@lddfym 麻烦review~

@lddfym

lddfym commented Dec 19, 2025

Copy link
Copy Markdown
Collaborator

代码中的注释请改用英文吧,和整体代码风格保持一致

Updated comments and docstrings in test_global_scheduler.py from Chinese to English for better clarity and consistency.
@xunyoyo

xunyoyo commented Dec 19, 2025

Copy link
Copy Markdown
Contributor Author

@lddfym 已修改

@lddfym

lddfym commented Dec 19, 2025

Copy link
Copy Markdown
Collaborator

LGTM

@CSWYF3634076
CSWYF3634076 merged commit 669dfe8 into PaddlePaddle:develop Dec 19, 2025
16 of 19 checks passed
@CSWYF3634076

Copy link
Copy Markdown
Collaborator

0.3⭐️
@luotao1

ckl117 pushed a commit to fxyfxy777/FastDeploy that referenced this pull request Dec 29, 2025
* Add tests for global scheduler functionality

This file contains tests for the global scheduler, including request handling, load accounting, and response management.

* Enhance global scheduler unit tests

* Clean up comments in test_global_scheduler.py

Removed unnecessary comments and coverage instructions.

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Translate comments and docstrings to Chinese

Updated comments and docstrings in Chinese to enhance clarity for native speakers.

* Use monkeypatch for FD_ENABLE_MAX_PREFILL in tests

Replaced direct assignment with monkeypatching for FD_ENABLE_MAX_PREFILL in test cases.

* Correct test function definitions in test_global_scheduler

Fix function definitions and update test cases for scheduler.

* Fix typos in global scheduler tests

* Translate comments to English in test_global_scheduler.py

Updated comments and docstrings in test_global_scheduler.py from Chinese to English for better clarity and consistency.

---------

Co-authored-by: CSWYF3634076 <wangyafeng@baidu.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jiaxin Sui <95567040+plusNew001@users.noreply.github.com>
chang-wenbin pushed a commit to chang-wenbin/FastDeploy that referenced this pull request Mar 2, 2026
* Add tests for global scheduler functionality

This file contains tests for the global scheduler, including request handling, load accounting, and response management.

* Enhance global scheduler unit tests

* Clean up comments in test_global_scheduler.py

Removed unnecessary comments and coverage instructions.

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Translate comments and docstrings to Chinese

Updated comments and docstrings in Chinese to enhance clarity for native speakers.

* Use monkeypatch for FD_ENABLE_MAX_PREFILL in tests

Replaced direct assignment with monkeypatching for FD_ENABLE_MAX_PREFILL in test cases.

* Correct test function definitions in test_global_scheduler

Fix function definitions and update test cases for scheduler.

* Fix typos in global scheduler tests

* Translate comments to English in test_global_scheduler.py

Updated comments and docstrings in test_global_scheduler.py from Chinese to English for better clarity and consistency.

---------

Co-authored-by: CSWYF3634076 <wangyafeng@baidu.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jiaxin Sui <95567040+plusNew001@users.noreply.github.com>
xiaoguoguo626807 pushed a commit to xiaoguoguo626807/FastDeploy that referenced this pull request May 7, 2026
* Add tests for global scheduler functionality

This file contains tests for the global scheduler, including request handling, load accounting, and response management.

* Enhance global scheduler unit tests

* Clean up comments in test_global_scheduler.py

Removed unnecessary comments and coverage instructions.

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/scheduler/test_global_scheduler.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Translate comments and docstrings to Chinese

Updated comments and docstrings in Chinese to enhance clarity for native speakers.

* Use monkeypatch for FD_ENABLE_MAX_PREFILL in tests

Replaced direct assignment with monkeypatching for FD_ENABLE_MAX_PREFILL in test cases.

* Correct test function definitions in test_global_scheduler

Fix function definitions and update test cases for scheduler.

* Fix typos in global scheduler tests

* Translate comments to English in test_global_scheduler.py

Updated comments and docstrings in test_global_scheduler.py from Chinese to English for better clarity and consistency.

---------

Co-authored-by: CSWYF3634076 <wangyafeng@baidu.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jiaxin Sui <95567040+plusNew001@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants