2014-10-07 119 views
0

我想寫一個ServerSpec測試運行部署的實例。以下是相關測試:廚師ServerSpec主機資源不工作

require 'spec_helper' 

describe service('nginx') do 
    it { should be_enabled } 
    it { should be_running } 
end 

describe port(80) do 
    it { should be_listening } 
end 

describe port(8085) do 
    it { should be_listening } 
end 

describe host('localhost') do 
    it { should be_reachable.with(:port => 8085, :proto => 'tcp') } 
end 

當我嘗試運行這個測試我第一次發現,未安裝NCAT(Centos的7最低)。我安裝了包,現在當我嘗試運行測試,我得到如下回應:

Failures: 
    1) Host "localhost" should be reachable 
    Failure/Error: it { should be_reachable.with(:port => 8085, :proto => 'tcp') } 
     expected Host "localhost" to be reachable 
     /bin/sh -c nc\ -vvvvzt\ localhost\ 8085\ -w\ 5 
     nc: invalid option -- 'z' 
Ncat: Try `--help' or man(1) ncat for more information, usage options and help. QUITTING. 
    # /tmp/busser/suites/serverspec/localhost/nginx_spec.rb:17:in `block (2 levels) in <top (required)>' 
Finished in 0.08179 seconds (files took 0.2021 seconds to load) 
5 examples, 1 failure 

這只是ServerSpec一個錯誤?有沒有已知的解決方法?

回答

0

這似乎是hardwired in specinfra所以我認爲這是一個錯誤。不幸的是,serverspec項目最近禁用了其回購問題跟蹤問題,因此沒有一種很好的方法來檢查它是否已知。這聽起來像你的netcat可能太老了,不支持這個選項,或者它已經修補了。解決方法是不使用這個匹配器,should be_listening加上一個iptables檢查應該是等價的。您也可以使用command類型與nccurl來檢查相同的事情。

+0

我覺得這樣的事情需要完成。感謝您瞭解當前情況的進一步背景。 – localhostv6 2014-10-07 20:48:45