Skip to content

Commit cf825e8

Browse files
committed
add ci cases
1 parent ccc7f1b commit cf825e8

File tree

5 files changed

+201
-1
lines changed

5 files changed

+201
-1
lines changed

test/ci_use/EB_Lite/test_EB_Lite_serving.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import os
16+
import re
1617
import signal
1718
import socket
1819
import subprocess
@@ -939,3 +940,42 @@ def test_streaming_completion_with_bad_words(openai_client, capsys):
939940
assert hasattr(chunk.choices[0], "text")
940941
output_1.append(chunk.choices[0].text)
941942
assert output_0 not in output_1
943+
944+
945+
def test_profile_reset_block_num():
946+
"""测试profile reset_block_num功能,与baseline diff不能超过5%"""
947+
log_file = "./log/config.log"
948+
baseline = 6408
949+
950+
if not os.path.exists(log_file):
951+
pytest.fail(f"Log file not found: {log_file}")
952+
953+
with open(log_file, "r") as f:
954+
log_lines = f.readlines()
955+
956+
target_line = None
957+
for line in log_lines:
958+
if "Reset block num" in line:
959+
target_line = line.strip()
960+
break
961+
962+
if target_line is None:
963+
pytest.fail("日志中没有Reset block num信息")
964+
965+
match = re.search(r"total_block_num:(\d+)", target_line)
966+
if not match:
967+
pytest.fail(f"Failed to extract total_block_num from line: {target_line}")
968+
969+
try:
970+
actual_value = int(match.group(1))
971+
except ValueError:
972+
pytest.fail(f"Invalid number format: {match.group(1)}")
973+
974+
lower_bound = baseline * (1 - 0.05)
975+
upper_bound = baseline * (1 + 0.05)
976+
print(f"Reset total_block_num: {actual_value}. baseline: {baseline}")
977+
978+
assert lower_bound <= actual_value <= upper_bound, (
979+
f"Reset total_block_num {actual_value} 与 baseline {baseline} diff需要在5%以内"
980+
f"Allowed range: [{lower_bound:.1f}, {upper_bound:.1f}]"
981+
)

test/ci_use/EB_Lite_mtp/test_EB_Lite_serving_mtp.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import json
1616
import os
17+
import re
1718
import signal
1819
import socket
1920
import subprocess
@@ -344,3 +345,42 @@ def test_streaming(openai_client, capsys):
344345
for chunk in response:
345346
output.append(chunk.choices[0].text)
346347
assert len(output) > 0
348+
349+
350+
def test_profile_reset_block_num():
351+
"""测试profile reset_block_num功能,与baseline diff不能超过5%"""
352+
log_file = "./log/config.log"
353+
baseline = 6058
354+
355+
if not os.path.exists(log_file):
356+
pytest.fail(f"Log file not found: {log_file}")
357+
358+
with open(log_file, "r") as f:
359+
log_lines = f.readlines()
360+
361+
target_line = None
362+
for line in log_lines:
363+
if "Reset block num" in line:
364+
target_line = line.strip()
365+
break
366+
367+
if target_line is None:
368+
pytest.fail("日志中没有Reset block num信息")
369+
370+
match = re.search(r"total_block_num:(\d+)", target_line)
371+
if not match:
372+
pytest.fail(f"Failed to extract total_block_num from line: {target_line}")
373+
374+
try:
375+
actual_value = int(match.group(1))
376+
except ValueError:
377+
pytest.fail(f"Invalid number format: {match.group(1)}")
378+
379+
lower_bound = baseline * (1 - 0.05)
380+
upper_bound = baseline * (1 + 0.05)
381+
print(f"Reset total_block_num: {actual_value}. baseline: {baseline}")
382+
383+
assert lower_bound <= actual_value <= upper_bound, (
384+
f"Reset total_block_num {actual_value} 与 baseline {baseline} diff需要在5%以内"
385+
f"Allowed range: [{lower_bound:.1f}, {upper_bound:.1f}]"
386+
)

test/ci_use/EB_VL_Lite/test_EB_VL_Lite_serving.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import json
1616
import os
17+
import re
1718
import signal
1819
import socket
1920
import subprocess
@@ -535,3 +536,42 @@ def test_chat_with_thinking(openai_client, capsys):
535536
total_tokens += len(delta_message.completion_token_ids)
536537
assert completion_tokens + reasoning_tokens == total_tokens
537538
assert reasoning_tokens <= reasoning_max_tokens
539+
540+
541+
def test_profile_reset_block_num():
542+
"""测试profile reset_block_num功能,与baseline diff不能超过5%"""
543+
log_file = "./log/config.log"
544+
baseline = 15910
545+
546+
if not os.path.exists(log_file):
547+
pytest.fail(f"Log file not found: {log_file}")
548+
549+
with open(log_file, "r") as f:
550+
log_lines = f.readlines()
551+
552+
target_line = None
553+
for line in log_lines:
554+
if "Reset block num" in line:
555+
target_line = line.strip()
556+
break
557+
558+
if target_line is None:
559+
pytest.fail("日志中没有Reset block num信息")
560+
561+
match = re.search(r"total_block_num:(\d+)", target_line)
562+
if not match:
563+
pytest.fail(f"Failed to extract total_block_num from line: {target_line}")
564+
565+
try:
566+
actual_value = int(match.group(1))
567+
except ValueError:
568+
pytest.fail(f"Invalid number format: {match.group(1)}")
569+
570+
lower_bound = baseline * (1 - 0.05)
571+
upper_bound = baseline * (1 + 0.05)
572+
print(f"Reset total_block_num: {actual_value}. baseline: {baseline}")
573+
574+
assert lower_bound <= actual_value <= upper_bound, (
575+
f"Reset total_block_num {actual_value} 与 baseline {baseline} diff需要在5%以内"
576+
f"Allowed range: [{lower_bound:.1f}, {upper_bound:.1f}]"
577+
)

test/ci_use/Qwen2-7B-Instruct_serving/test_Qwen2-7B-Instruct_serving.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import concurrent.futures
1616
import json
1717
import os
18+
import re
1819
import signal
1920
import socket
2021
import subprocess
@@ -599,3 +600,42 @@ def test_streaming(openai_client, capsys):
599600
for chunk in response:
600601
output.append(chunk.choices[0].text)
601602
assert len(output) > 0
603+
604+
605+
def test_profile_reset_block_num():
606+
"""测试profile reset_block_num功能,与baseline diff不能超过5%"""
607+
log_file = "./log/config.log"
608+
baseline = 7514
609+
610+
if not os.path.exists(log_file):
611+
pytest.fail(f"Log file not found: {log_file}")
612+
613+
with open(log_file, "r") as f:
614+
log_lines = f.readlines()
615+
616+
target_line = None
617+
for line in log_lines:
618+
if "Reset block num" in line:
619+
target_line = line.strip()
620+
break
621+
622+
if target_line is None:
623+
pytest.fail("日志中没有Reset block num信息")
624+
625+
match = re.search(r"total_block_num:(\d+)", target_line)
626+
if not match:
627+
pytest.fail(f"Failed to extract total_block_num from line: {target_line}")
628+
629+
try:
630+
actual_value = int(match.group(1))
631+
except ValueError:
632+
pytest.fail(f"Invalid number format: {match.group(1)}")
633+
634+
lower_bound = baseline * (1 - 0.05)
635+
upper_bound = baseline * (1 + 0.05)
636+
print(f"Reset total_block_num: {actual_value}. baseline: {baseline}")
637+
638+
assert lower_bound <= actual_value <= upper_bound, (
639+
f"Reset total_block_num {actual_value} 与 baseline {baseline} diff需要在5%以内"
640+
f"Allowed range: [{lower_bound:.1f}, {upper_bound:.1f}]"
641+
)

test/ci_use/Qwen3-MoE/test_Qwen3-MoE_serving.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import os
16+
import re
1617
import signal
1718
import socket
1819
import subprocess
@@ -116,7 +117,7 @@ def setup_and_run_server():
116117
)
117118

118119
# Wait up to 300 seconds for API server to be ready
119-
for _ in range(300):
120+
for _ in range(480):
120121
if is_port_open("127.0.0.1", FD_API_PORT):
121122
print(f"API server is up on port {FD_API_PORT}")
122123
break
@@ -297,3 +298,42 @@ def test_non_thinking_prompt(api_url, headers):
297298
assert not any(
298299
x in content for x in ["根据", "我认为", "推测", "可能"]
299300
), "Expected no reasoning in non-thinking response"
301+
302+
303+
def test_profile_reset_block_num():
304+
"""测试profile reset_block_num功能,与baseline diff不能超过5%"""
305+
log_file = "./log/config.log"
306+
baseline = 3253
307+
308+
if not os.path.exists(log_file):
309+
pytest.fail(f"Log file not found: {log_file}")
310+
311+
with open(log_file, "r") as f:
312+
log_lines = f.readlines()
313+
314+
target_line = None
315+
for line in log_lines:
316+
if "Reset block num" in line:
317+
target_line = line.strip()
318+
break
319+
320+
if target_line is None:
321+
pytest.fail("日志中没有Reset block num信息")
322+
323+
match = re.search(r"total_block_num:(\d+)", target_line)
324+
if not match:
325+
pytest.fail(f"Failed to extract total_block_num from line: {target_line}")
326+
327+
try:
328+
actual_value = int(match.group(1))
329+
except ValueError:
330+
pytest.fail(f"Invalid number format: {match.group(1)}")
331+
332+
lower_bound = baseline * (1 - 0.05)
333+
upper_bound = baseline * (1 + 0.05)
334+
print(f"Reset total_block_num: {actual_value}. baseline: {baseline}")
335+
336+
assert lower_bound <= actual_value <= upper_bound, (
337+
f"Reset total_block_num {actual_value} 与 baseline {baseline} diff需要在5%以内"
338+
f"Allowed range: [{lower_bound:.1f}, {upper_bound:.1f}]"
339+
)

0 commit comments

Comments
 (0)