Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Updates so rake should work when secure environment variables are not…
Browse files Browse the repository at this point in the history
… available on travis.
  • Loading branch information
maxlinc committed Jun 6, 2013
1 parent 7b8eaa0 commit ec305a8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
16 changes: 13 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@ Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => [:spec, 'integration:live']
task :default => [:credentials, :spec, 'integration:live']

task :credentials do
if ENV['TRAVIS_SECURE_ENV_VARS'] == 'false'
puts "Setting vars"
ENV['OS_USERNAME'] = '_RAX_USERNAME_'
ENV['OS_PASSWORD'] = '_RAX_PASSWORD_'
ENV['RS_TENANT_ID'] = '000000'
ENV['RS_CDN_TENANT_NAME'] = '_CDN-TENANT-NAME_'
end
fail "Not all required variables detected" unless ENV['OS_USERNAME'] && ENV['OS_PASSWORD'] && ENV['RS_CDN_TENANT_NAME'] && ENV['RS_TENANT_ID']
end

namespace :integration do
desc 'Run the integration tests'
Expand All @@ -33,9 +44,8 @@ namespace :integration do
desc 'Run the integration tests live (no VCR cassettes)'
task :live do
unless ENV['TRAVIS'] == 'true' && ENV['TRAVIS_SECURE_ENV_VARS'] == 'false'
fail "Not all required variables detected" unless ENV['OS_USERNAME'] && ENV['OS_PASSWORD'] && ENV['RS_CDN_TENANT_NAME'] && ENV['RS_TENANT_ID']
ENV['INTEGRATION_TESTS'] = 'live'
Rake::Task['integration:test'].invoke
end
end
end
end
10 changes: 5 additions & 5 deletions spec/integration/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

it 'should list server flavors', :vcr do
stdout, stderr, status = knife_capture('rackspace flavor list')
status.should == 0
status.should be(0), "Non-zero exit code.\n#{stdout}\n#{stderr}"

expected_output = {
:v1 => """
Expand Down Expand Up @@ -50,8 +50,8 @@
}

stdout, stderr, status = knife_capture('rackspace image list')
status.should == 0
stdout = ANSI.unansi stdout
status.should be(0), "Non-zero exit code.\n#{stdout}\n#{stderr}"
stdout = clean_output(stdout)
stdout.should match /^ID\s*Name\s*$/
stdout.should include sample_image[api]
end
Expand All @@ -68,7 +68,7 @@

args = %W{rackspace server create -I #{image[api]} -f #{flavor} -N test-node -S test-server}
stdout, stderr, status = knife_capture(args)
status.should == 0
status.should be(0), "Non-zero exit code.\n#{stdout}\n#{stderr}"
instance_data = capture_instance_data(stdout, {
:name => 'Name',
:instance_id => 'Instance ID',
Expand All @@ -81,7 +81,7 @@

args = %W{rackspace server delete #{instance_data[:instance_id]} -y}
stdout, stderr, status = knife_capture(args)
status.should == 0
status.should be(0), "Non-zero exit code.\n#{stdout}\n#{stderr}"

# Need to deal with deleting vs deleted states before we can check this
# server_list.should_not match /#{instance_data[:instance_id]}\s*#{instance_data[:name]}\s*#{instance_data[:public_ip]}\s*#{instance_data[:private_ip]}\s*#{flavor}\s*#{image}/
Expand Down
11 changes: 9 additions & 2 deletions spec/integration_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
c.filter_sensitive_data('_RAX_USERNAME_') { Chef::Config[:knife][:rackspace_api_username] }
c.filter_sensitive_data('_RAX_PASSWORD_') { Chef::Config[:knife][:rackspace_api_key] }
c.filter_sensitive_data('_CDN-TENANT-NAME_') { ENV['RS_CDN_TENANT_NAME'] }
c.filter_sensitive_data('_TENANT-ID_') { ENV['RS_TENANT_ID'] }
c.filter_sensitive_data('000000') { ENV['RS_TENANT_ID'] }

c.before_record do |interaction|
# Sensitive data
Expand All @@ -38,6 +38,10 @@
end
end

c.before_playback do | interaction |
interaction.filter!('_TENANT-ID_', '0000000')
end

c.default_cassette_options = {
# :record => :none,
# Ignores cache busting parameters.
Expand All @@ -62,7 +66,10 @@ def filter_headers(interaction, pattern, placeholder)
end

def clean_output(output)
ANSI.unansi(output).gsub(/\s+$/,'')
output = ANSI.unansi(output)
output.gsub!(/\s+$/,'')
output.gsub!("\e[0G", '')
output
end

RSpec::Matchers.define :match_output do |expected_output|
Expand Down

0 comments on commit ec305a8

Please sign in to comment.