Ceph make check 在 docker 中
在从源代码构建 Ceph 之后,可以使用 make check 运行单元和功能测试。将执行委托给容器可以
- 在不中断运行的情况下继续处理源代码
- 在不修改开发环境的情况下运行需要 root 权限的功能测试
- 检查各种操作系统
可以使用 src/test/docker-test-helper.sh 库 从命令行
$ test/docker-test.sh --os-type ubuntu --os-version 14.04 make check & $ test/docker-test.sh --os-type centos --os-version centos7 make check &
每次运行都会克隆当前仓库并在执行命令之前从 origin 拉取。例如,如果从 /srv/ceph 运行,centos 运行将在 /srv/ceph-centos-centos7 中运行 make check,该目录 绑定挂载 在容器中。一个可能的流程是
- 工作
- 提交
- test/docker-test.sh make check,它会拉取最新的提交
- 继续工作
- 检查 make check 的输出
如果发生错误,调试从在容器中运行 shell 开始
$ test/docker-test.sh --os-type ubuntu --os-version 14.04 --shell remote: Counting objects: 10, done. remote: Compressing objects: 100% (10/10), done. remote: Total 10 (delta 8), reused 0 (delta 0) Unpacking objects: 100% (10/10), done. From /home/loic/software/ceph/ceph
- 15046fe...8a39cad wip-9665 -> origin/wip-9665 HEAD is now at 8a39cad autotools: add --enable-docker loic@203c085f3dc1:/srv/ceph-ubuntu-14.04$
第一次运行 test/docker-test.sh 时,它会创建 一个填充了 编译和运行 Ceph 所需软件包的 docker 镜像。这降低了在容器中运行测试的开销
$ time test/docker-test.sh --os-type ubuntu --os-version 14.04 unittest_str_map HEAD is now at 8a39cad autotools: add --enable-docker Running main() from gtest_main.cc [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from str_map [ RUN ] str_map.json [ OK ] str_map.json (1 ms) [ RUN ] str_map.plaintext [ OK ] str_map.plaintext (0 ms) [----------] 2 tests from str_map (1 ms total)
[----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (1 ms total) [ PASSED ] 2 tests.
real 0m3.340s user 0m0.071s sys 0m0.046s