0

I'm trying to write a ServerSpec test to run against a deployed instance. The following is the relevant test:

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

When I attempt to run this test I first found out that ncat was not installed (Centos 7 minimal). I installed that package and now when I try to run the test I get the following response:

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

Is this just a bug with ServerSpec? Is there a workaround known?

localhostv6
  • 47
  • 1
  • 5

1 Answers1

0

This appears to be hardwired in specinfra so I presume it is a bug. Unfortunately the serverspec project has recently disabled issue tracking on their repos so there isn't a great way to check if it is known. It sounds like your netcat may be too old to support this option, or has it patched out. The workaround would be to not use this matcher, should be_listening combined with an iptables check should be equivalent. You could also use a command type with nc or curl to check the same thing.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • I figured something like that would need to be done. Thank you for the further background on the current situation. – localhostv6 Oct 07 '14 at 20:48