Category: service
Alibaba Cloud Performance Testing Service (PTS)
Purpose
Use Alibaba Cloud PTS OpenAPI to support:
- - test scene inventory and inspection
- pressure test planning and lifecycle automation
- report and metrics retrieval for verification and troubleshooting
Prerequisites
- - Configure least-privilege Alibaba Cloud credentials.
- Install Python SDKs (virtual environment recommended):
CODEBLOCK0
- - Prefer environment variables:
-
ALICLOUD_ACCESS_KEY_ID
-
ALICLOUD_ACCESS_KEY_SECRET
- optional
ALICLOUD_REGION_ID
- - Before mutating operations, run read-only API discovery and current-state checks.
AccessKey Priority
1) Environment variables: ALICLOUD_ACCESS_KEY_ID / ALICLOUD_ACCESS_KEY_SECRET / ALICLOUD_REGION_ID
2) Shared credentials file: INLINECODE6
If region/environment is unclear, confirm with user before mutating operations.
Workflow
1) Identify target region, test scene identifiers, and operation scope.
2) Run API discovery to confirm API names and required parameters.
3) Execute read-only APIs first (List* / Get* / Describe*).
4) Execute mutating operations only after confirming rollback and change window.
5) Save outputs and evidence to output/aliyun-pts-manage/.
API Discovery
- - Product code: INLINECODE11
- Default API version: INLINECODE12
- Metadata source: INLINECODE13
Minimal Executable Quickstart
CODEBLOCK1
Optional arguments:
CODEBLOCK2
List scenes (read-only):
CODEBLOCK3
Start one scene (mutating):
CODEBLOCK4
Stop one scene (mutating):
CODEBLOCK5
Common Operation Map
- - Scene inventory:
ListPtsScene, GetPtsScene, ListOpenJMeterScenes, INLINECODE17 - Scene lifecycle:
CreatePtsScene, SavePtsScene, ModifyPtsScene, DeletePtsScene, INLINECODE22 - Test execution control:
StartPtsScene, StopPtsScene, StartTestingJMeterScene, INLINECODE26 - Debug control:
StartDebugPtsScene, StopDebugPtsScene, StartDebuggingJMeterScene, INLINECODE30 - Reports/metrics:
ListPtsReports, GetPtsReportDetails, GetPtsSceneRunningData, INLINECODE34
See references/api_quick_map.md for grouped API lists.
Script Catalog
- -
scripts/list_openapi_meta_apis.py: fetch metadata and generate API inventory files. - INLINECODE37 : list PTS scenes with pagination.
- INLINECODE38 : start a scene and optionally poll running status.
- INLINECODE39 : stop a scene and optionally poll until non-running.
Output Policy
Write generated files and execution evidence to:
INLINECODE40
Validation
CODEBLOCK6
Pass criteria: command exits 0 and output/aliyun-pts-manage/validate.txt is generated.
Output And Evidence
- - Save artifacts, command outputs, and API response summaries under
output/aliyun-pts-manage/. - Include key parameters (region/resource id/time range) in evidence files for reproducibility.
References
- - Source list: INLINECODE43
- API quick map: INLINECODE44
- request/response templates: INLINECODE45
技能名称: aliyun-pts-manage
详细描述:
类别: 服务
阿里云性能测试服务 (PTS)
目的
使用阿里云 PTS OpenAPI 支持:
- - 测试场景清单与巡检
- 压力测试规划与生命周期自动化
- 报告与指标检索,用于验证与故障排查
前提条件
- - 配置最小权限的阿里云凭证。
- 安装 Python SDK(建议使用虚拟环境):
bash
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -U alibabacloudpts20201020 alibabacloudtea_openapi
- ALICLOUD
ACCESSKEY_ID
- ALICLOUD
ACCESSKEY_SECRET
- 可选 ALICLOUD
REGIONID
- - 在执行变更操作前,先运行只读 API 发现和当前状态检查。
AccessKey 优先级
1) 环境变量:ALICLOUDACCESSKEYID / ALICLOUDACCESSKEYSECRET / ALICLOUDREGIONID
2) 共享凭证文件:~/.alibabacloud/credentials
如果区域/环境不明确,在执行变更操作前请与用户确认。
工作流程
1) 确定目标区域、测试场景标识符和操作范围。
2) 运行 API 发现以确认 API 名称和所需参数。
3) 先执行只读 API(List / Get / Describe*)。
4) 仅在确认回滚方案和变更窗口后执行变更操作。
5) 将输出和证据保存到 output/aliyun-pts-manage/。
API 发现
- - 产品代码:PTS
- 默认 API 版本:2020-10-20
- 元数据来源:https://api.aliyun.com/meta/v1/products/PTS/versions/2020-10-20/api-docs.json
最小可执行快速入门
bash
python skills/observability/pts/aliyun-pts-manage/scripts/listopenapimeta_apis.py
可选参数:
bash
python skills/observability/pts/aliyun-pts-manage/scripts/listopenapimeta_apis.py \
--product-code PTS \
--version 2020-10-20 \
--output-dir output/aliyun-pts-manage
列出场景(只读):
bash
python skills/observability/pts/aliyun-pts-manage/scripts/listptsscenes.py \
--region cn-hangzhou \
--page-number 1 \
--page-size 10 \
--output output/aliyun-pts-manage/scenes.txt
启动一个场景(变更):
bash
python skills/observability/pts/aliyun-pts-manage/scripts/startptsscene.py \
--region cn-hangzhou \
--scene-id \
--wait \
--output output/aliyun-pts-manage/start-result.json
停止一个场景(变更):
bash
python skills/observability/pts/aliyun-pts-manage/scripts/stopptsscene.py \
--region cn-hangzhou \
--scene-id \
--wait \
--output output/aliyun-pts-manage/stop-result.json
常用操作映射
- - 场景清单:ListPtsScene, GetPtsScene, ListOpenJMeterScenes, GetOpenJMeterScene
- 场景生命周期:CreatePtsScene, SavePtsScene, ModifyPtsScene, DeletePtsScene, DeletePtsScenes
- 测试执行控制:StartPtsScene, StopPtsScene, StartTestingJMeterScene, StopTestingJMeterScene
- 调试控制:StartDebugPtsScene, StopDebugPtsScene, StartDebuggingJMeterScene, StopDebuggingJMeterScene
- 报告/指标:ListPtsReports, GetPtsReportDetails, GetPtsSceneRunningData, GetPtsSceneRunningStatus
参见 references/apiquickmap.md 获取分组后的 API 列表。
脚本目录
- - scripts/listopenapimetaapis.py:获取元数据并生成 API 清单文件。
- scripts/listptsscenes.py:分页列出 PTS 场景。
- scripts/startptsscene.py:启动一个场景,并可选择轮询运行状态。
- scripts/stoppts_scene.py:停止一个场景,并可选择轮询直到非运行状态。
输出策略
将生成的文件和执行证据写入:
output/aliyun-pts-manage/
验证
bash
mkdir -p output/aliyun-pts-manage
for f in skills/observability/pts/aliyun-pts-manage/scripts/*.py; do
python3 -m py_compile $f
done
echo pycompileok > output/aliyun-pts-manage/validate.txt
通过标准:命令退出码为 0 且 output/aliyun-pts-manage/validate.txt 已生成。
输出与证据
- - 将产物、命令输出和 API 响应摘要保存到 output/aliyun-pts-manage/ 下。
- 在证据文件中包含关键参数(区域/资源 ID/时间范围)以确保可重现性。
参考资料
- - 来源列表:references/sources.md
- API 快速映射:references/apiquickmap.md
- 请求/响应模板:references/templates.md