Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Chef infra Chef ServerSpec主机资源不工作_Chef Infra_Test Kitchen_Centos7_Netcat_Serverspec - Fatal编程技术网

Chef infra Chef ServerSpec主机资源不工作

Chef infra Chef ServerSpec主机资源不工作,chef-infra,test-kitchen,centos7,netcat,serverspec,Chef Infra,Test Kitchen,Centos7,Netcat,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_lis

我正在尝试编写一个针对已部署实例运行的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
故障:
1) 主机“localhost”应该是可访问的
失败/错误:它{应该是可访问的。使用(:port=>8085,:proto=>'tcp')}
预期主机“localhost”是可访问的
/bin/sh-c nc \-vvvzt\localhost\8085 \-w\5
nc:无效选项--“z”
Ncat:有关更多信息、用法选项和帮助,请尝试“帮助”或man(1)Ncat。退出。
#/tmp/busser/suites/serverspec/localhost/nginx_spec.rb:17:in'block(2层)in'
完成时间为0.08179秒(文件加载时间为0.2021秒)
5例,1例失败

这只是ServerSpec的一个bug吗?是否有已知的解决方法?

这似乎是,因此我认为这是一个bug。不幸的是,serverspec项目最近禁用了对其回购协议的问题跟踪,因此没有很好的方法来检查问题是否已知。听起来您的netcat可能太旧,无法支持此选项,或者已将其修补。解决方法是不使用此匹配器,
应与iptables检查相结合。您也可以使用
命令
键入
nc
curl
来检查相同的内容。

我认为需要做类似的事情。感谢你提供有关当前局势的进一步背景资料。