【发布时间】:2018-07-20 09:29:05
【问题描述】:
我正在测试两个平台,cento-7 和 ubuntu-1604。两者都成功收敛。但在验证过程中失败。
Ubuntu:
System Package apache2
✔ should be installed
Service apache2
× should be running
expected that `Service apache2` is running
Command curl localhost
✔ stdout should match /hello/i
✔ exit_status should eq 0
Port 80
✔ should be listening
测试总结:4 次成功,1 次失败,0 次跳过
似乎很奇怪,它在运行 apache2 时失败但 curl localhost 成功。
我登录了厨房
$ sudo systemctl status apache2
Failed to connect to bus: No such file or directory
所以我尝试了
$ ps -eo comm,etime,user | grep apache2
apache2 06:34:11 root
apache2 06:34:11 www-data
apache2 06:34:11 www-data
看起来 apache2 正在运行。
Centos-7
System Package httpd
✔ should be installed
Service httpd
✔ should be running
Command curl localhost
✔ stdout should match /hello/i
✔ exit_status should eq 0
Port 80
× should be listening
expected `Port 80.listening?` to return true, got false
测试总结:4 次成功,1 次失败,0 次跳过
奇怪的是 httpd 正在运行并且 curl 工作但没有监听端口 80?
所以我登录并运行 netstat
$ sudo netstat -tulpn | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 562/httpd
这是我的测试:
package_name =
service_name =
case os[:family]
when 'redhat' then 'httpd'
when 'debian' then 'apache2'
end
describe package(package_name) do
it { should be_installed }
end
describe service(service_name) do
it { should be_running }
end
describe command('curl localhost') do
its('stdout') { should match(/hello/i) }
its('exit_status') { should eq 0 }
end
describe port(80) do
it { should be_listening }
end
这是我的 .kitchen.yml
---
driver:
name: docker
privileged: true
provisioner:
name: chef_zero
verifier:
name: inspec
platforms:
- name: ubuntu-16.04
- name: centos-7
driver:
platform: rhel
run_command: /usr/lib/systemd/systemd
suites:
- name: default
run_list:
- recipe[hello_world_test::default]
- recipe[hello_world_test::deps]
verifier:
inspec_tests:
- test/integration/default
attributes:
知道为什么我会遇到失败,至少在我看来,在测试机器上它们正在按应有的方式工作。
谢谢,
安德鲁
【问题讨论】:
标签: docker chef-infra test-kitchen