diff options
author | John Keiser <jkeiser@opscode.com> | 2014-03-12 13:30:24 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-03-12 13:30:24 -0700 |
commit | 95895ae7cdb8c95ac5581d01392e0a090faff4c4 (patch) | |
tree | cf1ff2a729b729a498efa58c1e046a9bd99f251a | |
parent | 8cfb4ace7b5a9df6e64407c6bfddc3aa6496d64c (diff) | |
parent | b16800b77d7414a3194c352471f8be1e26da559a (diff) | |
download | chef-CHEF-4901.tar.gz |
Merge remote-tracking branch 'opscode/sethvargo/upgrade_chef_zero' into CHEF-4901CHEF-4901
-rw-r--r-- | chef.gemspec | 4 | ||||
-rw-r--r-- | spec/integration/knife/raw_spec.rb | 21 | ||||
-rw-r--r-- | spec/integration/knife/redirection_spec.rb | 20 | ||||
-rw-r--r-- | spec/support/shared/integration/app_server_support.rb | 42 | ||||
-rw-r--r-- | spec/support/shared/integration/integration_helper.rb | 1 |
5 files changed, 59 insertions, 29 deletions
diff --git a/chef.gemspec b/chef.gemspec index 2724a2aa2b..b858501fdd 100644 --- a/chef.gemspec +++ b/chef.gemspec @@ -36,8 +36,8 @@ Gem::Specification.new do |s| s.add_dependency "erubis", "~> 2.7" s.add_dependency "diff-lcs", "~> 1.2", ">= 1.2.4" - s.add_dependency "chef-zero", "~> 1.7", ">= 1.7.2" - s.add_dependency "puma", "~> 1.6" + # There's a bug with Chef Zero and IPV6 prior to version 2.0.2 + s.add_dependency "chef-zero", "~> 2.0", ">= 2.0.2" s.add_dependency "pry", "~> 0.9" diff --git a/spec/integration/knife/raw_spec.rb b/spec/integration/knife/raw_spec.rb index 69630061ac..fafd0a47ee 100644 --- a/spec/integration/knife/raw_spec.rb +++ b/spec/integration/knife/raw_spec.rb @@ -22,6 +22,7 @@ require 'chef/knife/show' describe 'knife raw' do extend IntegrationSupport include KnifeSupport + include AppServerSupport when_the_chef_server "has one of each thing" do client 'x', '{}' @@ -55,7 +56,7 @@ EOM end it 'knife raw /blarghle returns 404' do - knife('raw /blarghle').should_fail(/ERROR: Server responded with error 404 "Not Found"/) + knife('raw /blarghle').should_fail(/ERROR: Server responded with error 404 "Not Found\s*"/) end it 'knife raw -m DELETE /roles/x succeeds', :pending => (RUBY_VERSION < "1.9") do @@ -165,19 +166,16 @@ EOM context 'When a server returns raw json' do before :each do - @real_chef_server_url = Chef::Config.chef_server_url Chef::Config.chef_server_url = "http://127.0.0.1:9018" app = lambda do |env| [200, {'Content-Type' => 'application/json' }, ['{ "x": "y", "a": "b" }'] ] end - @raw_server = Puma::Server.new(app, Puma::Events.new(STDERR, STDOUT)) - @raw_server.add_tcp_listener("127.0.0.1", 9018) - @raw_server.run + @raw_server, @raw_server_thread = start_app_server(app, 9018) end after :each do - Chef::Config.chef_server_url = @real_chef_server_url - @raw_server.stop(true) + @raw_server.shutdown if @raw_server + @raw_server_thread.kill if @raw_server_thread end it 'knife raw /blah returns the prettified json', :pending => (RUBY_VERSION < "1.9") do @@ -198,19 +196,16 @@ EOM context 'When a server returns text' do before :each do - @real_chef_server_url = Chef::Config.chef_server_url Chef::Config.chef_server_url = "http://127.0.0.1:9018" app = lambda do |env| [200, {'Content-Type' => 'text' }, ['{ "x": "y", "a": "b" }'] ] end - @raw_server = Puma::Server.new(app, Puma::Events.new(STDERR, STDOUT)) - @raw_server.add_tcp_listener("127.0.0.1", 9018) - @raw_server.run + @raw_server, @raw_server_thread = start_app_server(app, 9018) end after :each do - Chef::Config.chef_server_url = @real_chef_server_url - @raw_server.stop(true) + @raw_server.shutdown if @raw_server + @raw_server_thread.kill if @raw_server_thread end it 'knife raw /blah returns the raw text' do diff --git a/spec/integration/knife/redirection_spec.rb b/spec/integration/knife/redirection_spec.rb index 5af9fd36e1..2ed49a7b24 100644 --- a/spec/integration/knife/redirection_spec.rb +++ b/spec/integration/knife/redirection_spec.rb @@ -15,38 +15,30 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'puma' require 'support/shared/integration/integration_helper' require 'chef/knife/list' describe 'redirection' do extend IntegrationSupport include KnifeSupport + include AppServerSupport when_the_chef_server 'has a role' do role 'x', {} context 'and another server redirects to it with 302' do before :each do - @real_chef_server_url = Chef::Config.chef_server_url + real_chef_server_url = Chef::Config.chef_server_url Chef::Config.chef_server_url = "http://127.0.0.1:9018" app = lambda do |env| - [302, {'Content-Type' => 'text','Location' => "#{@real_chef_server_url}#{env['PATH_INFO']}" }, ['302 found'] ] - end - @redirector_server = Puma::Server.new(app, Puma::Events.new(STDERR, STDOUT)) - @redirector_server.add_tcp_listener("127.0.0.1", 9018) - @redirector_server.run - Timeout::timeout(5) do - until @redirector_server.running - sleep(0.01) - end - raise @server_error if @server_error + [302, {'Content-Type' => 'text','Location' => "#{real_chef_server_url}#{env['PATH_INFO']}" }, ['302 found'] ] end + @redirector_server, @redirector_server_thread = start_app_server(app, 9018) end after :each do - Chef::Config.chef_server_url = @real_chef_server_url - @redirector_server.stop(true) + @redirector_server.shutdown if @redirector_server + @redirector_thread.kill if @redirector_thread end it 'knife list /roles returns the role' do diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb new file mode 100644 index 0000000000..a0d5e7fa5c --- /dev/null +++ b/spec/support/shared/integration/app_server_support.rb @@ -0,0 +1,42 @@ +# +# Author:: John Keiser (<jkeiser@opscode.com>) +# Author:: Ho-Sheng Hsiao (<hosh@opscode.com>) +# Copyright:: Copyright (c) 2012, 2013 Opscode, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'rack' +require 'stringio' + +module AppServerSupport + def start_app_server(app, port) + server = nil + thread = Thread.new do + Rack::Handler::WEBrick.run(app, + :Port => 9018, + :AccessLog => [], + :Logger => WEBrick::Log::new(StringIO.new, 7) + ) do |found_server| + server = found_server + end + end + Timeout::timeout(5) do + until server && server.status == :Running + sleep(0.01) + end + end + [server, thread] + end +end diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index 0c4bf990af..abed4c2715 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -23,6 +23,7 @@ require 'chef/config' require 'chef_zero/rspec' require 'json' require 'support/shared/integration/knife_support' +require 'support/shared/integration/app_server_support' require 'spec_helper' module IntegrationSupport |