HOWTO 测试 teuthology 任务

loic

Ceph 集成测试运行的 teuthology 使用 ceph-qa-suite 仓库中的 YAML 文件进行描述。实际工作是在 teuthology 通过 tasks 提供的机器上进行的。例如,workunit 任务运行在 qa/workunits 目录中的脚本,该目录位于 Ceph 仓库 中。
虽然 workunit.py 脚本很小,但复杂度足以值得测试。创建单元测试需要大量的模拟,并且无法捕获要在实际机器上运行的 shell 命令中的拼写错误。另一种方法是在 ceph-qa-suite 仓库本身内创建轻量级的集成测试。例如,tests/workunit 旨在最大程度地覆盖 workunit.py 脚本并尽快运行。

修改 workunit.py 脚本后,目标(即机器)将以以下方式放置在 target.yaml 文件中

$ ./virtualenv/bin/teuthology-lock --list-targets \ --owner loic@dachary.org | tee target.yaml targets: vpm027.feph.com: ssh-rsa AAAAB...UNwN

它将被用于使用以下命令从 tests/workunit 运行测试

PYTHONPATH=/home/loic/software/ceph/ceph-qa-suite \ ./virtualenv/bin/teuthology --owner loic@dachary.org \ ~/software/ceph/ceph-qa-suite/tests/workunit/*.yaml \ target.yaml

它将按字母顺序连接文件,并在目标机器上开始运行,使用本地副本 workunit.py 脚本来驱动测试。但是,目标机器将从网络中提取文件,为了方便起见,可以覆盖它从中提取资源的地址,以便在不实际修改 ceph 仓库(因为每次都会触发 gitbuilder.cgi,这会消耗资源)或经过审查过程(这需要太多的时间)的情况下进行实验。以下 override.yaml 文件

overrides: workunit: branch: wip-workunits get_workunits: >- curl -L https://github.com/dachary/ceph/archive/{branch}.tar.gz | tar -C {srcdir} -zxvf- --transform s:ceph-{branch}/qa/workunits:: ceph-{branch}/qa/workunits

将从 https://github.com/dachary/ceph/ 的一个临时分支中提取 workunits。当专注于代码的特定区域时,可以通过选择要连接的 YAML 文件来运行部分测试。例如

PYTHONPATH=/home/loic/software/ceph/ceph-qa-suite \ ./virtualenv/bin/teuthology --owner loic@dachary.org \ ~/software/ceph/ceph-qa-suite/tests/workunit/{01-cluster,04-inline-workunit}.yaml \ target.yaml

将不会安装 Ceph 或提取 workunits,只会检查处理 inline_workunit 配置选项的代码是否按预期工作。如果成功,teuthology 的输出将以

{duration: 251.9832820892334, flavor: basic, owner: loic@dachary.org, success: true}

结尾,否则,Trackback 附近的行应包含与问题相关的提示。