Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improved rackspace and cuke testing, #1

  • Loading branch information...
commit 49708876c62234a1afbbb5df0b9e58a6d307fef7 1 parent 0279b7c
@simpsonjulian simpsonjulian authored
View
2  Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- skewer (0.0.1)
+ skewer (0.1.0)
fog (~> 1.1.2)
GEM
View
32 features/hooks.feature
@@ -3,13 +3,27 @@ Feature: Hooks
As a user
I want it to execute a command when it's finihsed
-Scenario: accept hook on CLI
- Given a file named "/tmp/skewer_hook" with:
- """
- #!/bin/bash
- echo $1 > /tmp/skewer_hook_result
- """
- And I run `chmod +x /tmp/skewer_hook`
- When I run `./bin/skewer provision --cloud stub --image foo --role bar --hook /tmp/skewer_hook`
- Then the file "/tmp/skewer_hook_result" should exist
+ Scenario: accept hook on CLI
+ Given a file named "/tmp/skewer_hook" with:
+ """
+ #!/bin/bash
+ echo $1 > /tmp/skewer_hook_result
+ """
+ And I run `chmod +x /tmp/skewer_hook`
+ When I run `./bin/skewer provision --cloud stub --image foo --role bar --hook /tmp/skewer_hook`
+ Then the file "/tmp/skewer_hook_result" should exist
+
+
+ Scenario: run cucumber on completion
+ Given I have puppet code in "/tmp/skewer_test_code"
+ When I run `./bin/skewer provision --cloud ec2 --role apache --image ami-5c9b4935 --key testytesty --puppetcode /tmp/skewer_test_code --features skewercukes/features`
+ Then the exit status should be 0
+ And the stdout should contain "Puppet run succeeded"
+
+@announce-stdout
+@announce-stderr
+Scenario: failed cucumber should fail the run
+ Given I have puppet code in "/tmp/skewer_test_code"
+ When I run `./bin/skewer provision --cloud stub --role foobar --image ami-5c9b4935 --key testytesty --puppetcode /tmp/skewer_test_code --features skewercukes/features`
+ Then the exit status should not be 0
View
6 features/rackspace.feature
@@ -15,7 +15,7 @@ Feature: provisioning a node on Rackspace
"image_id":"112"
}
"""
- When I run `./bin/skewer provision --cloud rackspace --role foobar --image 112`
+ When I run `./bin/skewer provision --cloud rackspace --role foobar --image 112 --region lon`
Then the stdout should contain "Evaluating cloud rackspace"
And the stdout should contain "Launching a Rackspace node"
And the exit status should be 0
@@ -23,7 +23,7 @@ Feature: provisioning a node on Rackspace
@announce-stdout
@announce-stderr
Scenario: Build a machine with a specific flavor (RAM size)
- Given I run `./bin/skewer provision --cloud rackspace --role foobar --image 112 --flavor 3`
+ Given I run `./bin/skewer provision --cloud rackspace --role foobar --image 112 --flavor 3 --region lon`
Then the stdout should contain "Evaluating cloud rackspace"
And the stdout should contain "Launching a Rackspace node"
And the exit status should be 0
@@ -31,7 +31,7 @@ Feature: provisioning a node on Rackspace
@announce-stdout
@announce-stderr
Scenario: Build a machine with a symbolic image ID
- Given I run `./bin/skewer provision --cloud rackspace --role foobar --image ubuntu1104 --flavor 2`
+ Given I run `./bin/skewer provision --cloud rackspace --role foobar --image ubuntu1104 --flavor 2 --region lon`
Then the stdout should contain "Evaluating cloud rackspace"
And the stdout should contain "Launching a Rackspace node"
And the exit status should be 0
View
3  features/support/puppetcode/manifests/classes/apache.pp
@@ -0,0 +1,3 @@
+class apache {
+ include apache::install
+}
View
16 features/support/puppetcode/modules/apache/manifests/install.pp
@@ -0,0 +1,16 @@
+class apache::install {
+ package {
+ 'apache2': ensure => present
+ }
+ file {
+ '/var/www/index.html':
+ ensure => present,
+ content => 'Puppet Run Success',
+ require => Package['apache2'];
+ }
+ service {
+ 'apache2':
+ ensure => running,
+ require => Package['apache2'];
+ }
+}
View
2  features/update.feature
@@ -22,7 +22,7 @@ Scenario: pass in a hostname user and role on broken puppet code
Given I have access to the internet
And I have puppet code in "/tmp/skewer_test_code"
When I run `./bin/skewer update --host default --user vagrant --role foobroken --puppetcode /tmp/skewer_test_code/`
- Then the exit status should be 0
+ Then the exit status should not be 0
And the stdout should contain "Using Puppet Code from /tmp/skewer_test_code/"
And the stdout should contain "Puppet failed"
View
4 lib/cli.rb
@@ -78,10 +78,12 @@ def go
Puppet.run(node, @options)
location = @util.get_location(node)
Hooks.new(location).run
- Skewer.logger.debug "Node ready\n open http://#{location} or \n ssh -l #{node.username} #{location}"
+
Cuke.new(@config.get(:cuke_dir)).run if @config.get(:cuke_dir)
+ Skewer.logger.debug "Node ready\n open http://#{location} or \n ssh -l #{node.username} #{location}"
rescue Exception => exception
Skewer.logger.debug exception
+ raise "Something went wrong, and we killed the node"
ensure
destroy
end
View
3  lib/cuke.rb
@@ -6,6 +6,7 @@ module Skewer
# built.
class Cuke
class CukeError < RuntimeError; end
+ include Skewer
def initialize(dir = nil)
raise "you must provide a valid directory for features to be executed within" if dir.nil? or dir.class != String or !directory_exists?(dir)
@@ -17,6 +18,8 @@ def directory_exists?(dir)
end
def run
+ Skewer.logger.debug("Running cucumber hook")
+ `cd #{@dir}/.. && bundle install` if File.join(@dir, '..', 'Gemfile')
result = `cucumber #{@dir}`
parsed = result.match(/failed/)[0] rescue false
raise CukeError, "One of the cuke features failed!\n\n#{result}" if parsed
View
7 lib/rackspace/node.rb
@@ -9,7 +9,8 @@ class Node
# By default, boot an Ubuntu 10.04 LTS (lucid) server.
def initialize(flavor = 1, image = 112, name = 'my_server', instance = nil)
- connection = self.class.find_service
+ region = SkewerConfig.get('region')
+ connection = self.class.find_service(region)
# Get our SSH key to attach it to the server.
if instance
@@ -19,8 +20,8 @@ def initialize(flavor = 1, image = 112, name = 'my_server', instance = nil)
end
end
- def self.find_service(region = :usa)
- region = region == :usa ? "auth.api.rackspacecloud.com" : "lon.auth.api.rackspacecloud.com"
+ def self.find_service(short_region = 'usa')
+ region = short_region != 'lon' ? "auth.api.rackspacecloud.com" : "lon.auth.api.rackspacecloud.com"
Fog::Compute.new(
:provider => 'Rackspace',
:rackspace_api_key => Fog.credentials[:rackspace_api_key],
View
18 spec/rackspace/node_spec.rb
@@ -27,4 +27,22 @@
Skewer::Rackspace::Node.new(nil, nil, nil,node).node.delete.should == true
end
+
+ it "should find a uk service" do
+ Fog.unmock!
+ service = Skewer::Rackspace::Node.find_service('lon')
+ service.class.should == Fog::Compute::Rackspace::Real
+ puts service.inspect
+ service.instance_variable_get(:@rackspace_auth_url).should == 'lon.auth.api.rackspacecloud.com'
+ end
+
+ it "should find a the other service" do
+ Fog.unmock!
+ begin
+ Skewer::Rackspace::Node.find_service('usa')
+ rescue Exception => e
+ puts e.message
+ e.message.should match /auth.api.rackspacecloud.com/
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.