返回顶部
g

grpc-test-automationgRPC测试自动化

|

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
91
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

grpc-test-automation

嵌入式设备gRPC测试自动化

通过gRPC + JMeter对嵌入式板卡上的C/C++ SDK进行自动化测试的框架。

完整工作流程

┌─────────────────────────────────────────────────────────────────┐
│ 输入: 需求文档 + C/C++ SDK (头文件 + 库) │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ 步骤1: 分析SDK头文件 │
│ - 提取函数签名 │
│ - 识别错误码枚举 │
│ - 理解数据结构 │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ 步骤2: 编写C++ gRPC服务端 │
│ - 创建Proto文件 (基于SDK接口) │
│ - 实现gRPC服务类 (封装SDK调用) │
│ - 编写CMakeLists.txt │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ 步骤3: 编译生成 │
│ - cmake + make → 生成可执行文件 │
│ - protoc → 生成proto描述符 (.protobin) │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ 步骤4: 编写JMeter JMX │
│ - 引用proto描述符 │
│ - 配置gRPC采样器 │
│ - 定义测试用例 │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ 步骤5: 串口下发资源到板端 │
│ - 模拟串口通信 (TCP Socket) │
│ - 下发: SDK库 + 服务程序 + Proto │
│ - 挂载到板端目录 │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ 步骤6: 板端拉起服务 │
│ - 设置LDLIBRARYPATH │
│ - 执行./grpc_server 8080 │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ 步骤7: JMeter执行测试 │
│ - jmeter -n -t test.jmx │
│ - 收集响应数据 │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ 步骤8: 生成Excel报告 │
│ - 测试概览 │
│ - 测试详情 │
│ - 性能指标 │
│ - 错误详情 │
└─────────────────────────────────────────────────────────────────┘

输入文件

必需

  • - sdk/include/.h - SDK头文件
  • sdk/lib/.so 或 sdk/lib/*.a - SDK库文件

可选

  • - requirements.md - 接口规范
  • testcases.md - 历史测试用例
  • testframework/ - 历史框架代码

输出结构

grpc_test/
├── proto/
│ └── service.proto # 从SDK分析生成
├── server/
│ ├── CMakeLists.txt # 构建配置
│ ├── grpc_server.cpp # gRPC服务器 (封装SDK)
│ ├── build/ # 构建输出
│ │ ├── grpc_server # 编译后的可执行文件
│ │ └── service.protobin # 供JMeter使用的Proto描述符
│ └── service.pb.h/cc # 生成的Protobuf代码
├── client/
│ └── test_client.cpp # 可选的测试客户端
├── jmeter/
│ ├── test_plans/
│ │ └── test.jmx # JMeter测试计划
│ ├── results/
│ │ ├── result.jtl # 原始结果
│ │ └── report.xlsx # Excel报告
│ └── service.protobin # Proto描述符 (副本)
├── scripts/
│ ├── serial_simulator.py # 串口通信模拟器
│ ├── deploytoboard.sh # 部署资源到板端
│ ├── run_server.sh # 在板端启动服务
│ └── run_tests.sh # 执行完整测试周期
└── sdk/ # 原始SDK (挂载到板端)
├── include/
└── lib/

脚本使用说明

1. 分析SDK头文件

python
scripts/analyze_sdk.py sdk/include/

提取内容:函数、枚举、结构体、错误码

2. 生成Proto + 服务端

python
scripts/generategrpcserver.py --sdk sdk/ --output server/

创建内容:proto文件、server.cpp、CMakeLists.txt

3. 构建

bash
cd server/build && cmake .. && make

生成内容:grpc_server可执行文件、service.protobin

4. 部署到板端

bash
scripts/deploytoboard.sh --board localhost:9999 --sdk sdk/ --server server/build/

5. 运行测试

bash
scripts/runtests.sh --jmx jmeter/testplans/test.jmx --output jmeter/results/

关键实现细节

SDK分析模式

cpp
// SDK头文件
vencerrort vencgetdeviceinfo(vencdeviceinfot *info);
typedef struct { char deviceid[64]; ... } vencdeviceinfot;
typedef enum { VENCOK=0, VENCERRPARAM=1001 } vencerror_t;

↓ 分析 ↓

// Proto定义
service VencService {
rpc GetDeviceInfo(GetDeviceInfoRequest) returns (GetDeviceInfoResponse);
}

message GetDeviceInfoResponse {
string device_id = 1;
ErrorCode error = 2;
}

服务端封装模式

cpp
// gRPC服务端封装SDK调用
Status GetDeviceInfo(ServerContext* ctx,
const GetDeviceInfoRequest* req,
GetDeviceInfoResponse* resp) override {
vencdeviceinfo_t info;
vencerrort err = vencgetdevice_info(&info); // 调用SDK

if (err == VENC_OK) {
resp->setdeviceid(info.device_id);
return Status::OK;
}
return Status(StatusCode::INTERNAL, SDK错误);
}

串口通信协议

json
// 命令
{command: MOUNT, source_path: /path/to/sdk}
{command: UPLOAD, filename: grpc_server, content: ...}
{command: START_SERVER, port: 8080}
{command: STATUS}
{command: STOP_SERVER}

参见

  • - references/sdk-analysis.md - SDK头文件解析模式
  • references/cpp-server.md - C++ gRPC服务端实现
  • references/serial-protocol.md - 串口通信详情
  • references/jmeter-config.md - JMeter gRPC插件配置

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 grpc-test-automation-1775933795 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 grpc-test-automation-1775933795 技能

通过命令行安装

skillhub install grpc-test-automation-1775933795

下载

⬇ 下载 grpc-test-automation v1.0.0(免费)

文件大小: 24.59 KB | 发布时间: 2026-4-12 10:09

v1.0.0 最新 2026-4-12 10:09
Initial release of grpc-test-automation.

- Provides a full gRPC test automation framework for C/C++ SDKs on embedded devices.
- Automatically analyzes SDK headers, generates gRPC interfaces, and wraps SDK calls with a C++ gRPC server.
- Integrates with JMeter to create and run test plans using generated proto descriptors.
- Simulates serial communication for resource deployment and service control on the embedded board.
- Generates Excel-format test reports summarizing test results, performance metrics, and errors.
- Includes scripts for each step: analysis, server generation, build, deployment, test execution, and reporting.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部