arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.21530cs.SEcs.AI
收藏

通过蒙特卡洛树搜索的基于大语言模型的数据库管理系统测试用例生成

LLM-Based Test Case Generation in DBMS through Monte Carlo Tree Search

Harbin Institute of Technology, Shenzhen(哈尔滨工业大学(深圳));The Chinese University of Hong Kong, Shenzhen(香港中文大学(深圳));Huawei Hong Kong Research Center(华为香港研究中心)

Yujia Chen, Yingli Zhou, Fangyuan Zhang, Cuiyun Gao

AI总结:

本文提出MIST框架,通过蒙特卡洛树搜索生成不同数据库管理系统方言的语法正确且语义多样的测试用例,提升代码覆盖率。

摘要:

数据库管理系统(DBMS)是现代数据驱动应用的基础基础设施,其彻底测试对于确保系统可靠性至关重要。传统方法如模糊测试在特定DBMS中有效,但适应不同专有SQL方言需要大量手动工作。大语言模型(LLMs)为自动化SQL测试生成提供了前景,但在工业环境中面临关键挑战。首先,轻量级模型由于安全和隐私限制被广泛使用,但它们难以生成专有SQL方言的语法有效查询。其次,LLM生成的查询往往语义相似,只测试浅层执行路径,从而快速达到覆盖 plateau。为解决这些问题,我们提出了MIST,一个通过蒙特卡洛树搜索的基于LLM的DBMS测试用例生成框架。MIST包含两个阶段:特征引导的错误驱动测试用例合成,构建层次特征树并利用错误反馈指导LLM生成,旨在生成不同DBMS方言的语法正确且语义多样的查询;蒙特卡洛树搜索基于的测试用例突变,通过覆盖反馈联合优化种子查询选择和突变规则应用,旨在通过探索更深层执行路径提升代码覆盖率。实验表明,MIST在三个广泛使用的DBMS上使用四个轻量级LLM,平均在行覆盖、函数覆盖和分支覆盖上比基线方法提高43.3%、32.3%和46.4%,在优化器模块中最高行覆盖达到69.3%。

英文摘要:

Database Management Systems (DBMSs) are fundamental infrastructure for modern data-driven applications, where thorough testing with high-quality SQL test cases is essential for ensuring system reliability. Traditional approaches such as fuzzing can be effective for specific DBMSs, but adapting them to different proprietary dialects requires substantial manual effort. Large Language Models (LLMs) present promising opportunities for automated SQL test generation, but face critical challenges in industrial environments. First, lightweight models are widely used in organizations due to security and privacy constraints, but they struggle to generate syntactically valid queries for proprietary SQL dialects. Second, LLM-generated queries are often semantically similar and exercise only shallow execution paths, thereby quickly reaching a coverage plateau. To address these challenges, we propose MIST, an LLM-based test case generatIon framework for DBMS through Monte Carlo Tree search. MIST consists of two stages: Feature-Guided Error-Driven Test Case Synthetization, which constructs a hierarchical feature tree and uses error feedback to guide LLM generation, aiming to produce syntactically valid and semantically diverse queries for different DBMS dialects, and Monte Carlo Tree Search-Based Test Case Mutation, which jointly optimizes seed query selection and mutation rule application guided by coverage feedback, aiming at boosting code coverage by exploring deeper execution paths. Experiments on three widely-used DBMSs with four lightweight LLMs show that MIST achieves average improvements of 43.3% in line coverage, 32.3% in function coverage, and 46.4% in branch coverage compared to the baseline approach with the highest line coverage of 69.3% in the Optimizer module.

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

↑