【问题标题】:Chef ServerSpec Host Resource Not WorkingChef ServerSpec 主机资源不工作
【发布时间】:2014-10-07 19:57:51
【问题描述】:

我正在尝试编写一个 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 的一个错误吗?是否有已知的解决方法?

【问题讨论】:

    标签: chef-infra test-kitchen centos7 netcat serverspec


    【解决方案1】:

    这似乎是hardwired in specinfra,所以我认为这是一个错误。不幸的是,serverspec 项目最近在他们的 repos 上禁用了问题跟踪,所以没有一个很好的方法来检查它是否已知。听起来您的 netcat 可能太旧而无法支持此选项,或者已对其进行了修补。解决方法是不使用此匹配器,should be_listening 结合 iptables 检查应该是等效的。您还可以使用 command 类型和 nccurl 来检查相同的内容。

    【讨论】:

    • 我认为需要做类似的事情。感谢您提供有关当前情况的更多背景信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-09
    • 1970-01-01
    • 2014-02-01
    • 1970-01-01
    相关资源
    最近更新 更多