知识卡片
用受控延迟验证客户端
为 mock 响应配置延迟分布可在可控环境观察客户端对长短等待的处理。书中使用 WireMock 的 delayDistribution,将 type 设为 uniform 并给出 50–800 ms;请求脚本打印总时间。观察少量请求可以演示延迟变化,对比客户端在这些条件下的超时与恢复,可把测试集中到消费方。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- API 制品的构建与配置部署 9.2 Build stage: Simulating APIs with mocks · 查看原书依据
Suppose you wanted to test how an API consumer behaves when the API has random delays in response times. Say you wanted to simulate a uniform distribution of latency between 50 and 800 milliseconds. It may be difficult to inject this behavior and produce it on demand in the real service, but you could do this with a mock API.
参考来源
- 位置:《Automating API Delivery APIOps with OpenAPI》《第 09 章 API 制品的构建与配置部署》(9.2 Build stage: Simulating APIs with mocks;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-9.xhtml#p114)
- 结论依据:原文用 WireMock 描述如何人为制造延迟及验证消费方行为。
- 原始内容:Suppose you wanted to test how an API consumer behaves when the API has random delays in response times. Say you wanted to simulate a uniform distribution of latency between 50 and 800 milliseconds. It may be difficult to inject this behavior and produce it on demand in the real service, but you could do this with a mock API.