From 31a51eafe1577347c66ada33a792dfe5f1e565db Mon Sep 17 00:00:00 2001 From: Tim Labeeuw Date: Mon, 25 Nov 2013 18:02:18 -0800 Subject: [PATCH] Fixed warden for 1.8.7 @Signed-by Eric Malm --- warden-client/lib/warden/client/v1.rb | 2 +- warden-client/spec/client/v1_spec.rb | 55 +++++++++++++------------ warden-protocol/.rspec | 4 +- warden-protocol/spec/buffer_spec.rb | 6 ++- warden-protocol/spec/copy_in_spec.rb | 2 +- warden-protocol/spec/copy_out_spec.rb | 2 +- warden-protocol/warden-protocol.gemspec | 2 +- 7 files changed, 39 insertions(+), 34 deletions(-) diff --git a/warden-client/lib/warden/client/v1.rb b/warden-client/lib/warden/client/v1.rb index 8b7aada4..b6b3cba7 100644 --- a/warden-client/lib/warden/client/v1.rb +++ b/warden-client/lib/warden/client/v1.rb @@ -17,7 +17,7 @@ def self.request_from_v1(args) def self.response_to_v1(response) klass_name = response.class.name.split("::").last klass_name = klass_name.gsub(/Response$/, "") - klass_name = klass_name.gsub(/(.)([A-Z])/) { |m| "#{m[0]}_#{m[1]}" } + klass_name = klass_name.gsub(/(.)([A-Z])/) { |m| "#{m[0].chr}_#{m[1].chr}" } klass_name = klass_name.downcase m = "convert_#{klass_name}_response".downcase diff --git a/warden-client/spec/client/v1_spec.rb b/warden-client/spec/client/v1_spec.rb index aa4e28bd..25b2af21 100644 --- a/warden-client/spec/client/v1_spec.rb +++ b/warden-client/spec/client/v1_spec.rb @@ -89,8 +89,7 @@ def to_response(response) describe "response" do it "should return the handle" do - response = to_response \ - Warden::Protocol::CreateResponse.new(:handle => "handle") + response = to_response(Warden::Protocol::CreateResponse.new(:handle => "handle")) response.should == "handle" end end @@ -106,8 +105,7 @@ def to_response(response) describe "response" do it "should always be ok" do - response = to_response \ - Warden::Protocol::StopResponse.new + response = to_response(Warden::Protocol::StopResponse.new) response.should == "ok" end end @@ -123,8 +121,7 @@ def to_response(response) describe "response" do it "should always be ok" do - response = to_response \ - Warden::Protocol::DestroyResponse.new + response = to_response(Warden::Protocol::DestroyResponse.new) response.should == "ok" end end @@ -140,7 +137,7 @@ def to_response(response) describe "response" do let(:response) do - to_response \ + to_response( Warden::Protocol::InfoResponse.new({ :state => "state", :memory_stat => Warden::Protocol::InfoResponse::MemoryStat.new({ @@ -148,6 +145,7 @@ def to_response(response) :rss => 2, }) }) + ) end it "should return a hash" do @@ -176,8 +174,7 @@ def to_response(response) describe "response" do it "should return job_id" do - response = to_response \ - Warden::Protocol::SpawnResponse.new(:job_id => 3) + response = to_response(Warden::Protocol::SpawnResponse.new(:job_id => 3)) response.should == 3 end end @@ -194,12 +191,13 @@ def to_response(response) describe "response" do it "should return a 3-element tuple" do - response = to_response \ + response = to_response( Warden::Protocol::LinkResponse.new( :exit_status => 255, :stdout => "stdout", :stderr => "stderr" ) + ) response[0].should == 255 response[1].should == "stdout" @@ -219,12 +217,13 @@ def to_response(response) describe "response" do it "should return a 3-element tuple" do - response = to_response \ + response = to_response( Warden::Protocol::StreamResponse.new( :name => "stdout", :data => "data", - :exit_status => 25, + :exit_status => 25 ) + ) response[0].should == "stdout" response[1].should == "data" @@ -244,12 +243,13 @@ def to_response(response) describe "response" do it "should return a 3-element tuple" do - response = to_response \ + response = to_response( Warden::Protocol::RunResponse.new( :exit_status => 255, :stdout => "stdout", :stderr => "stderr" ) + ) response[0].should == 255 response[1].should == "stdout" @@ -277,11 +277,12 @@ def to_response(response) describe "response (in)" do it "should return a hash with both properties" do - response = to_response \ + response = to_response( Warden::Protocol::NetInResponse.new( :host_port => 1234, - :container_port => 2345, + :container_port => 2345 ) + ) response["host_port"].should == 1234 response["container_port"].should == 2345 @@ -290,8 +291,7 @@ def to_response(response) describe "response (out)" do it "should always be ok" do - response = to_response \ - Warden::Protocol::NetOutResponse.new + response = to_response(Warden::Protocol::NetOutResponse.new) response.should == "ok" end end @@ -319,16 +319,14 @@ def to_response(response) describe "response (in)" do it "should always be ok" do - response = to_response \ - Warden::Protocol::CopyInResponse.new + response = to_response(Warden::Protocol::CopyInResponse.new) response.should == "ok" end end describe "response (out)" do it "should always be ok" do - response = to_response \ - Warden::Protocol::CopyOutResponse.new + response = to_response(Warden::Protocol::CopyOutResponse.new) response.should == "ok" end end @@ -355,10 +353,11 @@ def to_response(response) describe "response (mem)" do it "should return #limit_in_bytes" do - response = to_response \ + response = to_response( Warden::Protocol::LimitMemoryResponse.new({ :limit_in_bytes => 1234 }) + ) response.should == 1234 end end @@ -383,10 +382,11 @@ def to_response(response) describe "response (disk)" do it "should return #byte" do - response = to_response \ + response = to_response( Warden::Protocol::LimitDiskResponse.new({ :byte => 1234 }) + ) response.should == 1234 end end @@ -401,8 +401,7 @@ def to_response(response) describe "response" do it "should return pong" do - response = to_response \ - Warden::Protocol::PingResponse.new + response = to_response(Warden::Protocol::PingResponse.new) response.should == "pong" end end @@ -417,10 +416,11 @@ def to_response(response) describe "response" do it "should return an array with handles" do - response = to_response \ + response = to_response( Warden::Protocol::ListResponse.new({ :handles => ["h1", "h2"] }) + ) response.should == ["h1", "h2"] end end @@ -436,10 +436,11 @@ def to_response(response) describe "response" do it "should return #message" do - response = to_response \ + response = to_response( Warden::Protocol::EchoResponse.new({ :message => "hello world" }) + ) response.should == "hello world" end end diff --git a/warden-protocol/.rspec b/warden-protocol/.rspec index bc1dc4c0..d347ce9a 100644 --- a/warden-protocol/.rspec +++ b/warden-protocol/.rspec @@ -1 +1,3 @@ ---fail-fast --backtrace --color +--backtrace +--color +--order rand diff --git a/warden-protocol/spec/buffer_spec.rb b/warden-protocol/spec/buffer_spec.rb index 8828fc81..36e6525e 100644 --- a/warden-protocol/spec/buffer_spec.rb +++ b/warden-protocol/spec/buffer_spec.rb @@ -7,6 +7,8 @@ let(:request) { Warden::Protocol::EchoRequest.new(:message => "request") } let(:response) { Warden::Protocol::EchoResponse.new(:message => "response") } + subject { described_class.new } + it "should support iterating over requests" do subject << Warden::Protocol::Buffer.request_to_wire(request) subject.each_request do |request| @@ -28,7 +30,7 @@ data = Warden::Protocol::Buffer.request_to_wire(request) loop do - chunk = data.slice!(0) + chunk = data.slice!(0).chr subject << chunk break if data.empty? @@ -47,7 +49,7 @@ data = Warden::Protocol::Buffer.response_to_wire(response) loop do - chunk = data.slice!(0) + chunk = data.slice!(0).chr subject << chunk break if data.empty? diff --git a/warden-protocol/spec/copy_in_spec.rb b/warden-protocol/spec/copy_in_spec.rb index 7ff491bf..4798a560 100644 --- a/warden-protocol/spec/copy_in_spec.rb +++ b/warden-protocol/spec/copy_in_spec.rb @@ -7,7 +7,7 @@ described_class.new( :handle => "handle", :src_path => "/src", - :dst_path => "/dst", + :dst_path => "/dst" ) end diff --git a/warden-protocol/spec/copy_out_spec.rb b/warden-protocol/spec/copy_out_spec.rb index 91167f50..1ec9f69e 100644 --- a/warden-protocol/spec/copy_out_spec.rb +++ b/warden-protocol/spec/copy_out_spec.rb @@ -7,7 +7,7 @@ described_class.new( :handle => "handle", :src_path => "/src", - :dst_path => "/dst", + :dst_path => "/dst" ) end diff --git a/warden-protocol/warden-protocol.gemspec b/warden-protocol/warden-protocol.gemspec index d78fcad0..8db25293 100644 --- a/warden-protocol/warden-protocol.gemspec +++ b/warden-protocol/warden-protocol.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |gem| gem.require_paths = ["lib"] gem.version = Warden::Protocol::VERSION - gem.add_dependency "beefcake" + gem.add_dependency "beefcake", "~> 0.3.0" gem.add_development_dependency "rspec", "~> 2.11" end