Specs running against local machine instead of remote?
matt9949 opened this issue · comments
Hi,
I'm not sure if this is a bug or i haven't configured something correctly, but it seems like my spec files are asserting against my local machine instead of the EC2 instance.
I'm trying to run the following command:
ami_spec
--role mesos
--ami
--subnet-id
--key-name
--key-file
--ssh-user ubuntu
--specs ./spec
--aws-region eu-west-1
It brings up an EC2 instances fine and attempts to run the specs.
However, it seems like it's running the specs against my local (OSX 10.12.3) machine as it is using brew to try and determine if a package is installed. To get around that i tried to run apt list, however i get a mac pop up saying i need to install a jdk if i want to use apt.
It's strange, because in the output it gives me the IP of the EC2 instance.
Excuse me if i am missing something obvious - anyone have any ideas?
spec/mesos/default_spec.rb:
require 'serverspec'
require 'spec_helper'
set :backend, :exec
describe package('mesos') do
it { should be_installed.with_version('1.2.0') }
end
describe command("apt list mesos") do
its(:stdout) { should contain('mesos/now 1.2.0') }
its(:stdout) { should contain('installed') }
end
Output:
ami_spec \
--role mesos \
--ami <amiid>\
--subnet-id <subnetid> \
--key-name <keyname> \
--key-file <keyfile> \
--ssh-user ubuntu \
--specs ./spec \
--aws-region eu-west-1
/usr/local/lib/ruby/gems/2.4.0/gems/net-ssh-2.9.4/lib/net/ssh/transport/session.rb:67:in `initialize': Object#timeout is deprecated, use Timeout.timeout instead.
/usr/local/lib/ruby/gems/2.4.0/gems/net-ssh-2.9.4/lib/net/ssh/transport/session.rb:84:in `initialize': Object#timeout is deprecated, use Timeout.timeout instead.
/usr/local/lib/ruby/gems/2.4.0/gems/net-ssh-2.9.4/lib/net/ssh/transport/cipher_factory.rb:98: warning: constant OpenSSL::Cipher::Cipher is deprecated
/usr/local/lib/ruby/gems/2.4.0/gems/net-ssh-2.9.4/lib/net/ssh/transport/cipher_factory.rb:72: warning: constant OpenSSL::Cipher::Cipher is deprecated
boo!
Running tests for mesos
FFF
Failures:
1) Package "mesos" should be installed with version "1.2.0"
On host `10.185.38.238'
Failure/Error: it { should be_installed.with_version('1.2.0') }
expected Package "mesos" to be installed with version "1.2.0"
/bin/sh -c brew\ info\ mesos\ \|\ grep\ -E\ \"\^\$\(brew\ --prefix\)/Cellar/mesos/1.2.0\"
# ./spec/mesos/default_spec.rb:7:in `block (2 levels) in <top (required)>'
2) Command "apt list mesos" stdout should contain "mesos/now 1.2.0"
On host `10.185.38.238'
Failure/Error: its(:stdout) { should contain('mesos/now 1.2.0') }
expected "" to contain "mesos/now 1.2.0"
/bin/sh -c apt\ list\ mesos
# ./spec/mesos/default_spec.rb:11:in `block (2 levels) in <top (required)>'
Environment details:
ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
OS: OSX 10.12.3
gem list
*** LOCAL GEMS ***
addressable (2.5.2)
ami_spec (0.3.0)
aws-sdk (2.10.54, 2.10.53)
aws-sdk-core (2.10.54, 2.10.53)
aws-sdk-resources (2.10.54, 2.10.53)
aws-sigv4 (1.0.2)
bigdecimal (default: 1.3.0)
bundler (1.15.4)
crack (0.4.3)
did_you_mean (1.1.0)
diff-lcs (1.3)
hashdiff (0.3.6)
hashie (3.5.6)
io-console (default: 0.4.6)
jmespath (1.3.1)
json (default: 2.0.4)
minitest (5.10.1)
multi_json (1.12.2)
net-scp (1.2.1)
net-ssh (2.9.4)
net-telnet (0.1.1)
openssl (default: 2.0.5)
power_assert (0.4.1)
psych (default: 2.2.2)
public_suffix (3.0.0)
rake (12.1.0, 12.0.0)
rdoc (default: 5.0.0)
rspec (3.6.0)
rspec-core (3.6.0)
rspec-expectations (3.6.0)
rspec-its (1.2.0)
rspec-mocks (3.6.0)
rspec-support (3.6.0)
safe_yaml (1.0.4)
serverspec (2.41.0)
sfl (2.3)
specinfra (2.72.0)
test-unit (3.2.3)
timecop (0.9.1)
trollop (2.1.2)
webmock (3.0.1)
xmlrpc (0.2.1)
Please ignore this - I was being silly.
The culprit was set :backend in my spec file. D'oh!