{"id":29966273,"url":"https://github.com/thingspanel/thingspanel-testing-tools","last_synced_at":"2025-08-04T02:32:40.088Z","repository":{"id":292787225,"uuid":"981926084","full_name":"ThingsPanel/thingspanel-testing-tools","owner":"ThingsPanel","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-12T05:51:43.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T06:36:46.820Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThingsPanel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-12T05:45:00.000Z","updated_at":"2025-05-12T05:51:46.000Z","dependencies_parsed_at":"2025-05-12T06:36:54.694Z","dependency_job_id":"d4b60d0a-908c-47b0-bf49-7f7cb676a0e6","html_url":"https://github.com/ThingsPanel/thingspanel-testing-tools","commit_stats":null,"previous_names":["thingspanel/thingspanel-testing-tools"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ThingsPanel/thingspanel-testing-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThingsPanel%2Fthingspanel-testing-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThingsPanel%2Fthingspanel-testing-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThingsPanel%2Fthingspanel-testing-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThingsPanel%2Fthingspanel-testing-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThingsPanel","download_url":"https://codeload.github.com/ThingsPanel/thingspanel-testing-tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThingsPanel%2Fthingspanel-testing-tools/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268639931,"owners_count":24282678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-04T02:31:52.340Z","updated_at":"2025-08-04T02:32:40.072Z","avatar_url":"https://github.com/ThingsPanel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ThingsPanel性能测试工具\n\n这是一个用于测试ThingsPanel物联网平台性能的工具集，主要包含设备创建和MQTT性能测试两个主要功能模块。\n\n## 功能特点\n\n### 1. 设备创建模块\n- 支持批量创建设备\n- 自动生成设备ID和Token\n- 支持将设备信息保存到文件\n- 支持追加模式写入\n- 支持自定义设备名称前缀和后缀\n\n### 2. MQTT性能测试模块\n- 支持多设备并发连接\n- 支持自定义数据上报间隔\n- 支持自定义测试循环次数\n- 支持自定义数据点数量\n- 实时监控数据写入情况\n- 支持数据库写入性能监控\n- 提供详细的测试报告\n\n## 使用方法\n\n### 1. 创建设备\n\n```bash\ncd create_device\ngo run main.go [参数]\n```\n\n主要参数说明：\n- `--db-host`: 数据库服务器地址和端口（默认：127.0.0.1:5432）\n- `--db-user`: 数据库用户名（默认：postgres）\n- `--db-pass`: 数据库密码（默认：ThingsPanel2023）\n- `--db-name`: 数据库名称（默认：thingspanel）\n- `--tenant`: 租户ID（默认：9c3f8a70）\n- `--prefix`: 设备名称前缀（默认：2025.5.8测试）\n- `--number`: 设备名称后缀数字（默认：3）\n- `--count`: 要创建的设备数量（默认：3）\n- `--batch`: 批量插入的大小（默认：100）\n- `--output`: 输出文件目录（默认：当前目录）\n- `--id-file`: 设备ID文件名（默认：device_id.txt）\n- `--token-file`: 设备Token文件名（默认：device_username.txt）\n- `--append`: 是否追加写入文件（默认：true）\n\n### 2. MQTT性能测试\n\n```bash\ncd mqtt\ngo run main.go [参数]\n```\n\n主要参数说明：\n- `--config`: 配置文件路径（默认：config.yml）\n- `--token-file`: 设备token文件路径\n- `--clients`: 模拟连接的设备数量\n- `--mqtt-server`: MQTT服务器地址\n- `--qos`: MQTT服务质量(0,1,2)\n- `--topic`: 发布主题\n- `--interval`: 数据上报间隔时间\n- `--cycles`: 测试循环次数\n- `--connect-wait`: 连接等待时间\n- `--min-value`: 传感器数据最小值\n- `--max-value`: 传感器数据最大值\n- `--data-points`: 每条消息包含的数据点数量\n\n## 配置文件说明\n\n配置文件（config.yml）包含以下主要配置项：\n\n```yaml\n# 设备相关配置\ndevice:\n  token_file: \"../create_device/device_username.txt\"  # 设备token文件路径\n  client_number: 5                                     # 模拟连接的设备数量\n\n# MQTT相关配置\nmqtt:\n  server: \"127.0.0.1:1883\"  # MQTT服务器地址\n  qos: 0                        # MQTT服务质量(0,1,2)\n  topic: \"devices/telemetry\"    # 发布主题\n\n# 测试参数配置\ntest:\n  data_interval: 100ms          # 数据上报间隔时间\n  cycle_count: 200              # 测试循环次数\n  connect_wait_time: 3s         # 连接等待时间\n\n# 数据参数\ndata:\n  min_value: 1.0                # 传感器数据最小值\n  max_value: 10.0               # 传感器数据最大值\n  data_point_count: 10          # 每条消息包含的数据点数量\n\n# 数据库配置\ndatabase:\n  host: \"127.0.0.1:5432\"    # 数据库服务器地址和端口\n  user: \"postgres\"              # 数据库用户名\n  password: \"ThingsPanel2023\"   # 数据库密码\n  name: \"thingspanel\"              # 数据库名称\n  ssl_mode: \"disable\"           # 数据库SSL模式\n\n# 监控配置\nmonitor:\n  log_interval: 10s             # 日志输出间隔\n```\n\n## 测试报告\n\n测试完成后，工具会生成详细的测试报告，包括：\n- 测试总耗时\n- 测试循环次数\n- 成功连接设备数\n- 总发送数据点数\n- 平均吞吐量\n- 每个数据点平均耗时\n- 数据库写入性能统计\n\n## 注意事项\n\n1. 使用前请确保已正确配置数据库连接信息\n2. 建议先使用少量设备进行测试，确认配置无误后再进行大规模测试\n3. 注意监控服务器资源使用情况，避免资源耗尽\n4. 建议在测试环境中进行测试，避免影响生产环境","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthingspanel%2Fthingspanel-testing-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthingspanel%2Fthingspanel-testing-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthingspanel%2Fthingspanel-testing-tools/lists"}