# test-mqtt5 **Repository Path**: ningchenglin/test-mqtt5 ## Basic Information - **Project Name**: test-mqtt5 - **Description**: 一个测试MQTT Serrver 对 MQTT5 协议的遵循度 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2024-10-18 - **Last Updated**: 2024-10-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: mqtt, Server, Testing ## README ## test-mqtt5 这是一个测试 MQTT 服务器对 MQTT 5.0 协议遵循情况的测试工具。 该工具是从 [gmqtt](https://gitee.com/hopebj2008/gmqtt) 开源项目抽出来的并进行了少许的修改而成。 ### 测试用例(共22个) 1. test_basic 基本测试 2. test_basic_subscriptions 基本订阅 3. test_retained_message_rap 保留消息并带有RAP标志 4. test_retained_message_not_rap 保留消息并不带RAP标志 5. test_will_message 遗嘱消息 6. test_no_will_message_on_gentle_disconnect 没有遗嘱消息 7. test_shared_subscriptions 共享消息 8. test_assigned_clientid 由服务端赋给客户ID 9. test_unsubscribe 取消订阅 10. test_overlapping_subscriptions 通配符重叠订阅 11. test_redelivery_on_reconnect 客户端重连消息重传 12. test_request_response 请求响应 topic 13. test_subscribe_no_local 非本地消息 NL 14. test_subscribe_retain_01_handling_flag 保留消息 RH=1 15. test_subscribe_retain_2_handling_flag 保留消息 RH=2 16. test_reconnection_with_failure 失败重连 17. test_invalid_utf8_clientid 登录,赋给 clientid 无效的utf8串值 18. test_invalid_utf8_username 登录,赋给 username 无效的utf8串值 19. test_invalid_utf8_password 登录,赋给 password 无效的utf8串值 20. test_invalid_utf8_topic 发布, 赋给 topic无效的utf8串值 21. test_invalid_utf8_topic_filter 订阅,赋给 topic_filter 无效的utf8串值 22. test_invalid_utf8_topic_filter_unsub 取消订阅,赋给 topic_filter 无效的utf8串值 ### 运行环境 Python 3.9+ ### 开始 + 克隆代码 ```bash $ git clone https://gitee.com:ningchenglin/test-mqtt5.git ``` + 安装依赖库 ```bash $ cd ./test-mqtt5 $ python -m pip install -r requirements.txt ``` + 修改 MQTT 服务器地址(在 test_mqtt5.py 开头) ```py host = "localhost" # 改成你的服务地址 port = 1883 ``` + 运行测试程序 ```bash $ pytest ./test_mqtt5.py E:\dev\test-mqtt5\.venv\lib\site-packages\pytest_asyncio\plugin.py:208: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_l oop_scope" is unset. The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop sco pe for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Va lid fixture loop scopes are: "function", "class", "module", "package", "session" warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) =============================================================== test session starts ================================================================ platform win32 -- Python 3.10.5, pytest-8.3.3, pluggy-1.5.0 rootdir: E:\dev\test-mqtt5 plugins: asyncio-0.24.0 asyncio: mode=strict, default_loop_scope=None collected 16 items test_mqtt5.py ................ [100%] ========================================================== 16 passed in 441.47s (0:07:21) ========================================================== (.venv) ```