Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Test Kitchen #37

Open
englishm opened this issue Aug 22, 2014 · 8 comments
Open

Support for Test Kitchen #37

englishm opened this issue Aug 22, 2014 · 8 comments

Comments

@englishm
Copy link
Contributor

It would be really great if we could integrate infrataster with our existing test-kitchen-based tests.
We often use Test Kitchen with the kitchen-digitalocean driver so that we can launch tests in the cloud from a VM. Being able to run infrataster against that same instance would allow us to use infrataster as part of our existing CI system. Currently, I am only able to run infrataster tests locally where I have control over the IP address assigned to a VM (e.g. w/ Vagrant).

Thoughts?

@ryotarai
Copy link
Owner

@englishm Sorry for very late reply.
I think integrating Infrataster and Test Kitchen is very good idea.
You can run Infrataster against the same instance like the following:

Infrataster::Server.define(
  :web,
  '127.0.0.1',
)

@estahn
Copy link

estahn commented Mar 2, 2015

👍

@estahn
Copy link

estahn commented Mar 2, 2015

@englishm I tested @ryotarai suggestion and it works just fine.

Add a Gemfile to test/integration/default/serverspec with the following content:

source 'https://rubygems.org'

gem 'infrataster'

Add to your spec_helper.rb the above mentioned code. Here is an example of mine:

require 'serverspec'
require 'infrataster/rspec'

set :backend, :exec

Infrataster::Server.define(:app, '127.0.0.1')

Start writing your tests along with your serverspecs. Example

require 'spec_helper'

(9000..9002).each do |port|
  describe port(port) do
    it { should be_listening.on('127.0.0.1').with('tcp') }
  end

  describe server(:app) do
    describe http("http://127.0.0.1:#{port}/healthcheck") do
      it "responds content including 'WORKING'" do
        expect(response.body).to include('WORKING')
      end
    end
  end
end

Let me know if you have any issues. It's working fine for me.

@tknerr
Copy link

tknerr commented Apr 23, 2015

@estahn but this would again test from the inside, not outside-in, right?

@tknerr
Copy link

tknerr commented Apr 23, 2015

FYI - @LordCope is taking a similar approach with https://github.com/Atalanta/leibniz/

It's also outside-in, acceptance level infrastructure testing, but cucumber/gherkin.

@nrvale0
Copy link

nrvale0 commented Nov 3, 2015

@estahn, thanks for providing that info about what worked for you. Can you provide a little color around why the spec_helper.rb + Gemfile in the serverspec directory should work? I've tried to reproduce what you have but I'm getting this:

/opt/chef/embedded/bin/ruby -I/tmp/verifier/suites/serverspec -I/tmp/verifier/gems/gems/rspec-support-3.3.0/lib:/tmp/verifier/gems/gems/rspec-core-3.3.2/lib /opt/chef/embedded/bin/rspec --pattern /tmp/verifier/suites/serverspec/\*\*/\*_spec.rb --color --format documentation --default-path /tmp/verifier/suites/serverspecd such file -- infrataster (LoadError)

which to me seems to indicate that TK isn't finding the infrataster gem.

On a side note, I had to modify the 'require' in spec_helper.rb to be just "require 'infrataster'" , no "/rspec" because Ruby was complaining about the ability to load that file.

@nrvale0
Copy link

nrvale0 commented Nov 5, 2015

Just to loop back on this for anyone else who happens along later...

The busser-servespec code allows for a Gemfile to be dropped in the serverspec directory and it will run a 'bundle install' automagically.

@awiddersheim
Copy link

awiddersheim commented Sep 8, 2016

I'm having issues with the suggestions here. Atleast on CentOS:

-----> Bundle Installing..
                run  /opt/chef/embedded/bin/ruby /tmp/verifier/gems/bin/bundle install --gemfile /tmp/verifier/suites/serverspec/Gemfile --local || /opt/chef/embedded/bin/ruby /tmp/verifier/gems/bin/bundle install --gemfile /tmp/verifier/suites/serverspec/Gemfile from "."
       Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
       installing your bundle as root will break this application for all non-root
       users on this machine.
       Could not find gem 'infrataster' in any of the gem sources listed in your
       Gemfile or available on this machine.
       Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
       installing your bundle as root will break this application for all non-root
       users on this machine.
       Fetching gem metadata from https://rubygems.org/
       Fetching version metadata from https://rubygems.org/
       Fetching dependency metadata from https://rubygems.org/
       Resolving dependencies...
       Using addressable 2.4.0
       Using mime-types-data 3.2016.0521
       Using mini_portile2 2.1.0
       Using pkg-config 1.1.7
       Installing rack 2.0.1

       Gem::InstallError: rack requires Ruby version >= 2.2.2.
       Using cliver 0.3.2
       Using diff-lcs 1.2.5
       Using multipart-post 2.0.0
       Using net-ssh 3.2.0
       Using websocket-extensions 0.1.2
       Using rspec-support 3.5.0
       Using thor 0.19.1
       Using bundler 1.12.5
       Using mime-types 3.1
       Using nokogiri 1.6.8
       An error occurred while installing rack (2.0.1), and Bundler cannot continue.
       Make sure that `gem install rack -v '2.0.1'` succeeds before bundling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants