task/TEST.md

49 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Test Report
## v1.5.7 验证
- `go test -v ./...`:通过;在临时标准 Redis 8.8 实例上覆盖任务调度、运行控制和可靠队列行为,测试后已关闭实例。
- `go test -bench=. ./...`:通过;`BenchmarkTaskRegistration-16``138.8 ns/op`Task Get/List 分别为 `7.614 ns/op``67.71 ns/op`Apple M3 Max
- 队列测试验证 processing 恢复、批量 Fetch/Finish、compatibility marker 不残留,以及 Sorted Set 延迟任务只在到期后提升;同一组测试已在未修改的 SugarDB 实例上通过。
- 现有调度测试覆盖对象级 Enable/Disable包级 `Enable`/`Disable` 和运行级 Logger 传导已通过编译与 master 集成,尚缺独立单元测试。
- `git diff --check`:通过。
## v1.5.6 验证
- 独立模块解析、全量测试与基准测试均通过。
## Environment
- **Date**: 2026-06-22
- **Go Version**: go 1.25.0
- **OS**: darwin/amd64
## Summary
| Test Case | Status | Duration |
|-----------|--------|----------|
| TestTaskBasic | PASS | 2.50s |
| TestTaskLifecycle | PASS | 4.00s |
| TestTaskPolicySkip | PASS | 3.50s |
| TestTaskTimeout | PASS | 2.50s |
| TestTaskPanicRecover | PASS | 2.50s |
| TestTaskManualRun | PASS | 0.20s |
| TestGracefulStop | PASS | 1.00s |
## Benchmarks
| Benchmark | Iterations | ns/op |
|-----------|------------|-------|
| BenchmarkTaskRegistration | 3664093 | 318.1 |
| BenchmarkTaskExecutionOverhead/Get | 52381898 | 26.07 |
| BenchmarkTaskExecutionOverhead/List | 10123669 | 116.2 |
## Details
### TestGracefulStop
Successfully verified that the scheduler waits for running tasks to complete during `Stop(ctx)` using manual triggers for higher reliability.
### TestTaskPanicRecover
Verified that the scheduler remains operational and continues to schedule tasks even if a specific task panics, with full stack trace logging.
### TestTaskTimeout
Verified that the task-specific `context.Context` is correctly cancelled when the configured timeout is exceeded.
## Conclusion
All 7 test cases passed. The implementation of the `Service` interface is robust and optimized for performance.