arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.04583cs.SE
收藏

基于强化学习的自适应 REST API 测试

Adaptive REST API Testing with Reinforcement Learning

Myeongsoo Kim, Saurabh Sinha, Alessandro Orso

AI总结:

提出一种结合强化学习的自适应 REST API 测试技术,通过动态分析请求与响应数据并对操作和参数进行优先级排序,在代码覆盖率、效率和故障发现能力上优于现有工具。

摘要:

现代 Web 服务越来越依赖 REST API。由于需要探索巨大的搜索空间(包括选择 API 操作以创建序列、从可能很大的参数集中为每个操作选择参数,以及从几乎无限的参数输入空间中采样值),有效测试这些 API 具有挑战性。当前的测试工具缺乏高效的探索机制,将所有操作和参数同等对待(即不考虑其重要性或复杂性)且缺乏优先级策略。此外,当规范中缺少响应模式或响应模式表现出变体时,这些工具会陷入困境。为了解决这些局限性,我们提出了一种自适应 REST API 测试技术,该技术结合了强化学习,在探索过程中对操作和参数进行优先级排序。我们的方法动态分析请求和响应数据以确定依赖参数,并采用基于采样的策略来高效处理动态 API 反馈。我们在十个 RESTful 服务上评估了我们的技术,在实现的代码覆盖率、生成的请求、覆盖的操作和触发的服务故障方面,将其与最先进的 REST 测试工具进行了比较。此外,我们对优先级排序、动态反馈分析和采样进行了消融研究,以评估它们各自的效果。我们的研究结果表明,我们的方法在有效性、效率和故障发现能力方面优于现有的 REST API 测试工具。

英文摘要:

Modern web services increasingly rely on REST APIs. Effectively testing these APIs is challenging due to the vast search space to be explored, which involves selecting API operations for sequence creation, choosing parameters for each operation from a potentially large set of parameters, and sampling values from the virtually infinite parameter input space. Current testing tools lack efficient exploration mechanisms, treating all operations and parameters equally (i.e., not considering their importance or complexity) and lacking prioritization strategies. Furthermore, these tools struggle when response schemas are absent in the specification or exhibit variants. To address these limitations, we present an adaptive REST API testing technique that incorporates reinforcement learning to prioritize operations and parameters during exploration. Our approach dynamically analyzes request and response data to inform dependent parameters and adopts a sampling-based strategy for efficient processing of dynamic API feedback. We evaluated our technique on ten RESTful services, comparing it against state-of-the-art REST testing tools with respect to code coverage achieved, requests generated, operations covered, and service failures triggered. Additionally, we performed an ablation study on prioritization, dynamic feedback analysis, and sampling to assess their individual effects. Our findings demonstrate that our approach outperforms existing REST API testing tools in terms of effectiveness, efficiency, and fault-finding ability.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑