Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Fixed warden for 1.8.7
Browse files Browse the repository at this point in the history
@Signed-By Eric Malm
  • Loading branch information
Tim Labeeuw committed Nov 26, 2013
1 parent 41ba680 commit 31a51ea
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 34 deletions.
2 changes: 1 addition & 1 deletion warden-client/lib/warden/client/v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 28 additions & 27 deletions warden-client/spec/client/v1_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -140,14 +137,15 @@ 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({
:cache => 1,
:rss => 2,
})
})
)
end

it "should return a hash" do
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion warden-protocol/.rspec
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
--fail-fast --backtrace --color
--backtrace
--color
--order rand
6 changes: 4 additions & 2 deletions warden-protocol/spec/buffer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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?

Expand All @@ -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?

Expand Down
2 changes: 1 addition & 1 deletion warden-protocol/spec/copy_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
described_class.new(
:handle => "handle",
:src_path => "/src",
:dst_path => "/dst",
:dst_path => "/dst"
)
end

Expand Down
2 changes: 1 addition & 1 deletion warden-protocol/spec/copy_out_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
described_class.new(
:handle => "handle",
:src_path => "/src",
:dst_path => "/dst",
:dst_path => "/dst"
)
end

Expand Down
2 changes: 1 addition & 1 deletion warden-protocol/warden-protocol.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 31a51ea

Please sign in to comment.