netalertx-testing-workflow
GitHub在 NetAlertX devcontainer 中运行、调试 pytest 测试。强制先检查失败,支持全量/指定文件/上次失败测试,处理认证与 403 问题,必要时重建 Docker 镜像。
Trigger Scenarios
Install
npx skills add netalertx/NetAlertX --skill netalertx-testing-workflow -g -y
SKILL.md
Frontmatter
{
"name": "netalertx-testing-workflow",
"description": "Run and debug tests in the NetAlertX devcontainer. Use this when asked to run tests, check test failures, debug failing tests, or execute pytest."
}
Testing Workflow
Pre-Flight Check (MANDATORY)
Before running any tests, always check for existing failures first:
- Use the
testFailuretool to gather current failure information - Review the failures to understand what's already broken
- Only then proceed with test execution
Running Tests
Use VS Code's testing interface or the runTests tool with appropriate parameters:
- To run all tests: invoke runTests without file filter
- To run specific test file: invoke runTests with the test file path
- To run failed tests only: invoke runTests with
--lfflag
Test Location
Tests live in test/ directory. App code is under server/.
PYTHONPATH is preconfigured to include the following which should meet all needs:
/app# the primary location where python runs in the production system/app/server# symbolic link to /wprkspaces/NetAlertX/server/app/server/plugins# symbolic link to /workspaces/NetAlertX/server/plugins/opt/venv/lib/pythonX.Y/site-packages/workspaces/NetAlertX/test/workspaces/NetAlertX/server/workspaces/NetAlertX/usr/lib/pythonX.Y/site-packages
Authentication in Tests
Retrieve API_TOKEN using Python (not shell):
from helper import get_setting_value
token = get_setting_value("API_TOKEN")
Troubleshooting 403 Forbidden
- Ensure backend is running (use devcontainer-services skill)
- Verify config loaded:
get_setting_value("API_TOKEN")returns non-empty - Re-run startup if needed (use devcontainer-setup skill)
Docker Test Image
If container changes affect tests, rebuild the test image first:
docker buildx build -t netalertx-test .
This takes ~30 seconds unless venv stage changes (~90s).
Version History
-
548d698
Current 2026-08-19 22:09
修正 PYTHONPATH 中插件路径拼写错误(front/plugins 改为 server/plugins);更新文档以匹配网站监控插件引入后的目录结构变更。
- 8aec57b 2026-07-24 22:14


