warden-protocol 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +6 -0
- data/README.md +13 -0
- data/Rakefile +40 -0
- data/lib/warden/protocol.rb +4 -0
- data/lib/warden/protocol/base.rb +168 -0
- data/lib/warden/protocol/buffer.rb +69 -0
- data/lib/warden/protocol/build.sh +13 -0
- data/lib/warden/protocol/message.rb +50 -0
- data/lib/warden/protocol/pb.rb +497 -0
- data/lib/warden/protocol/pb/copy_in.proto +35 -0
- data/lib/warden/protocol/pb/copy_out.proto +39 -0
- data/lib/warden/protocol/pb/create.proto +65 -0
- data/lib/warden/protocol/pb/destroy.proto +33 -0
- data/lib/warden/protocol/pb/echo.proto +26 -0
- data/lib/warden/protocol/pb/error.proto +19 -0
- data/lib/warden/protocol/pb/info.proto +95 -0
- data/lib/warden/protocol/pb/limit_bandwidth.proto +30 -0
- data/lib/warden/protocol/pb/limit_disk.proto +70 -0
- data/lib/warden/protocol/pb/limit_memory.proto +34 -0
- data/lib/warden/protocol/pb/link.proto +40 -0
- data/lib/warden/protocol/pb/list.proto +25 -0
- data/lib/warden/protocol/pb/message.proto +36 -0
- data/lib/warden/protocol/pb/net_in.proto +39 -0
- data/lib/warden/protocol/pb/net_out.proto +35 -0
- data/lib/warden/protocol/pb/ping.proto +24 -0
- data/lib/warden/protocol/pb/resource_limits.proto +30 -0
- data/lib/warden/protocol/pb/run.proto +29 -0
- data/lib/warden/protocol/pb/spawn.proto +37 -0
- data/lib/warden/protocol/pb/stop.proto +40 -0
- data/lib/warden/protocol/pb/stream.proto +41 -0
- data/lib/warden/protocol/version.rb +7 -0
- data/spec/base_spec.rb +150 -0
- data/spec/buffer_spec.rb +65 -0
- data/spec/copy_in_spec.rb +51 -0
- data/spec/copy_out_spec.rb +56 -0
- data/spec/create_spec.rb +70 -0
- data/spec/destroy_spec.rb +36 -0
- data/spec/echo_spec.rb +42 -0
- data/spec/error_spec.rb +33 -0
- data/spec/info_spec.rb +122 -0
- data/spec/limit_bandwidth_spec.rb +57 -0
- data/spec/limit_disk_spec.rb +103 -0
- data/spec/limit_memory_spec.rb +47 -0
- data/spec/link_spec.rb +67 -0
- data/spec/list_spec.rb +41 -0
- data/spec/net_in_spec.rb +57 -0
- data/spec/net_out_spec.rb +47 -0
- data/spec/ping_spec.rb +32 -0
- data/spec/resource_limits_spec.rb +84 -0
- data/spec/run_spec.rb +79 -0
- data/spec/spawn_spec.rb +55 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/stop_spec.rb +46 -0
- data/spec/stream_spec.rb +65 -0
- data/spec/support/examples/wrappable_reply.rb +26 -0
- data/spec/support/examples/wrappable_request.rb +26 -0
- data/spec/support/helper.rb +122 -0
- data/spec/support/matchers.rb +22 -0
- data/warden-protocol.gemspec +21 -0
- metadata +166 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Warden::Protocol::LimitBandwidthRequest do
|
6
|
+
subject(:request) do
|
7
|
+
described_class.new(:handle => "handle", :rate => 1, :burst => 1)
|
8
|
+
end
|
9
|
+
|
10
|
+
it_should_behave_like "wrappable request"
|
11
|
+
|
12
|
+
its("class.type_camelized") { should == "LimitBandwidth" }
|
13
|
+
its("class.type_underscored") { should == "limit_bandwidth" }
|
14
|
+
|
15
|
+
field :handle do
|
16
|
+
it_should_be_required
|
17
|
+
it_should_be_typed_as_string
|
18
|
+
end
|
19
|
+
|
20
|
+
field :rate do
|
21
|
+
it_should_be_required
|
22
|
+
it_should_be_typed_as_uint64
|
23
|
+
end
|
24
|
+
|
25
|
+
field :burst do
|
26
|
+
it_should_be_required
|
27
|
+
it_should_be_typed_as_uint64
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should respond to #create_response" do
|
31
|
+
request.create_response.should be_a(Warden::Protocol::LimitBandwidthResponse)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe Warden::Protocol::LimitBandwidthResponse do
|
36
|
+
subject(:response) do
|
37
|
+
described_class.new(:rate => 1, :burst => 1)
|
38
|
+
end
|
39
|
+
|
40
|
+
it_should_behave_like "wrappable response"
|
41
|
+
|
42
|
+
its("class.type_camelized") { should == "LimitBandwidth" }
|
43
|
+
its("class.type_underscored") { should == "limit_bandwidth" }
|
44
|
+
|
45
|
+
it { should be_ok }
|
46
|
+
it { should_not be_error }
|
47
|
+
|
48
|
+
field :rate do
|
49
|
+
it_should_be_required
|
50
|
+
it_should_be_typed_as_uint64
|
51
|
+
end
|
52
|
+
|
53
|
+
field :burst do
|
54
|
+
it_should_be_required
|
55
|
+
it_should_be_typed_as_uint64
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
shared_examples "disk limiting" do
|
6
|
+
field :block_limit do
|
7
|
+
it_should_be_optional
|
8
|
+
it_should_be_typed_as_uint64
|
9
|
+
end
|
10
|
+
|
11
|
+
field :block do
|
12
|
+
it_should_be_optional
|
13
|
+
it_should_be_typed_as_uint64
|
14
|
+
end
|
15
|
+
|
16
|
+
field :block_soft do
|
17
|
+
it_should_be_optional
|
18
|
+
it_should_be_typed_as_uint64
|
19
|
+
end
|
20
|
+
|
21
|
+
field :block_hard do
|
22
|
+
it_should_be_optional
|
23
|
+
it_should_be_typed_as_uint64
|
24
|
+
end
|
25
|
+
|
26
|
+
field :inode_limit do
|
27
|
+
it_should_be_optional
|
28
|
+
it_should_be_typed_as_uint64
|
29
|
+
end
|
30
|
+
|
31
|
+
field :inode do
|
32
|
+
it_should_be_optional
|
33
|
+
it_should_be_typed_as_uint64
|
34
|
+
end
|
35
|
+
|
36
|
+
field :inode_soft do
|
37
|
+
it_should_be_optional
|
38
|
+
it_should_be_typed_as_uint64
|
39
|
+
end
|
40
|
+
|
41
|
+
field :inode_hard do
|
42
|
+
it_should_be_optional
|
43
|
+
it_should_be_typed_as_uint64
|
44
|
+
end
|
45
|
+
|
46
|
+
field :byte_limit do
|
47
|
+
it_should_be_optional
|
48
|
+
it_should_be_typed_as_uint64
|
49
|
+
end
|
50
|
+
|
51
|
+
field :byte do
|
52
|
+
it_should_be_optional
|
53
|
+
it_should_be_typed_as_uint64
|
54
|
+
end
|
55
|
+
|
56
|
+
field :byte_soft do
|
57
|
+
it_should_be_optional
|
58
|
+
it_should_be_typed_as_uint64
|
59
|
+
end
|
60
|
+
|
61
|
+
field :byte_hard do
|
62
|
+
it_should_be_optional
|
63
|
+
it_should_be_typed_as_uint64
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe Warden::Protocol::LimitDiskRequest do
|
68
|
+
subject(:request) do
|
69
|
+
described_class.new(:handle => "handle")
|
70
|
+
end
|
71
|
+
|
72
|
+
it_should_behave_like "wrappable request"
|
73
|
+
|
74
|
+
its("class.type_camelized") { should == "LimitDisk" }
|
75
|
+
its("class.type_underscored") { should == "limit_disk" }
|
76
|
+
|
77
|
+
field :handle do
|
78
|
+
it_should_be_required
|
79
|
+
it_should_be_typed_as_string
|
80
|
+
end
|
81
|
+
|
82
|
+
it_should_behave_like "disk limiting"
|
83
|
+
|
84
|
+
it "should respond to #create_response" do
|
85
|
+
request.create_response.should be_a(Warden::Protocol::LimitDiskResponse)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe Warden::Protocol::LimitDiskResponse do
|
90
|
+
subject(:response) do
|
91
|
+
described_class.new
|
92
|
+
end
|
93
|
+
|
94
|
+
it_should_behave_like "wrappable response"
|
95
|
+
|
96
|
+
its("class.type_camelized") { should == "LimitDisk" }
|
97
|
+
its("class.type_underscored") { should == "limit_disk" }
|
98
|
+
|
99
|
+
it { should be_ok }
|
100
|
+
it { should_not be_error }
|
101
|
+
|
102
|
+
it_should_behave_like "disk limiting"
|
103
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Warden::Protocol::LimitMemoryRequest do
|
6
|
+
subject(:request) do
|
7
|
+
described_class.new(:handle => "handle")
|
8
|
+
end
|
9
|
+
|
10
|
+
it_should_behave_like "wrappable request"
|
11
|
+
|
12
|
+
its("class.type_camelized") { should == "LimitMemory" }
|
13
|
+
its("class.type_underscored") { should == "limit_memory" }
|
14
|
+
|
15
|
+
field :handle do
|
16
|
+
it_should_be_required
|
17
|
+
it_should_be_typed_as_string
|
18
|
+
end
|
19
|
+
|
20
|
+
field :limit_in_bytes do
|
21
|
+
it_should_be_optional
|
22
|
+
it_should_be_typed_as_uint64
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should respond to #create_response" do
|
26
|
+
request.create_response.should be_a(Warden::Protocol::LimitMemoryResponse)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Warden::Protocol::LimitMemoryResponse do
|
31
|
+
subject(:response) do
|
32
|
+
described_class.new
|
33
|
+
end
|
34
|
+
|
35
|
+
it_should_behave_like "wrappable response"
|
36
|
+
|
37
|
+
its("class.type_camelized") { should == "LimitMemory" }
|
38
|
+
its("class.type_underscored") { should == "limit_memory" }
|
39
|
+
|
40
|
+
it { should be_ok }
|
41
|
+
it { should_not be_error }
|
42
|
+
|
43
|
+
field :limit_in_bytes do
|
44
|
+
it_should_be_optional
|
45
|
+
it_should_be_typed_as_uint64
|
46
|
+
end
|
47
|
+
end
|
data/spec/link_spec.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
module Warden::Protocol
|
6
|
+
describe LinkRequest do
|
7
|
+
subject(:request) do
|
8
|
+
described_class.new(:handle => "handle", :job_id => 1)
|
9
|
+
end
|
10
|
+
|
11
|
+
it_should_behave_like "wrappable request"
|
12
|
+
|
13
|
+
its("class.type_camelized") { should == "Link" }
|
14
|
+
its("class.type_underscored") { should == "link" }
|
15
|
+
|
16
|
+
field :handle do
|
17
|
+
it_should_be_required
|
18
|
+
it_should_be_typed_as_string
|
19
|
+
end
|
20
|
+
|
21
|
+
field :job_id do
|
22
|
+
it_should_be_required
|
23
|
+
it_should_be_typed_as_uint
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should respond to #create_response" do
|
27
|
+
request.create_response.should be_a(Warden::Protocol::LinkResponse)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe Warden::Protocol::LinkResponse do
|
32
|
+
subject(:response) do
|
33
|
+
described_class.new
|
34
|
+
end
|
35
|
+
|
36
|
+
it_should_behave_like "wrappable response"
|
37
|
+
|
38
|
+
its("class.type_camelized") { should == "Link" }
|
39
|
+
its("class.type_underscored") { should == "link" }
|
40
|
+
|
41
|
+
it { should be_ok }
|
42
|
+
it { should_not be_error }
|
43
|
+
|
44
|
+
field :exit_status do
|
45
|
+
it_should_be_optional
|
46
|
+
it_should_be_typed_as_uint
|
47
|
+
end
|
48
|
+
|
49
|
+
field :stdout do
|
50
|
+
it_should_be_optional
|
51
|
+
it_should_be_typed_as_string
|
52
|
+
end
|
53
|
+
|
54
|
+
field :stderr do
|
55
|
+
it_should_be_optional
|
56
|
+
it_should_be_typed_as_string
|
57
|
+
end
|
58
|
+
|
59
|
+
field :info do
|
60
|
+
it_should_be_optional
|
61
|
+
|
62
|
+
it "should be a InfoResponse" do
|
63
|
+
field.type.should == InfoResponse
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/spec/list_spec.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Warden::Protocol::ListRequest do
|
6
|
+
subject(:request) do
|
7
|
+
described_class.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it_should_behave_like "wrappable request"
|
11
|
+
|
12
|
+
its("class.type_camelized") { should == "List" }
|
13
|
+
its("class.type_underscored") { should == "list" }
|
14
|
+
|
15
|
+
it "should respond to #create_response" do
|
16
|
+
request.create_response.should be_a(Warden::Protocol::ListResponse)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Warden::Protocol::ListResponse do
|
21
|
+
subject(:response) do
|
22
|
+
described_class.new
|
23
|
+
end
|
24
|
+
|
25
|
+
it_should_behave_like "wrappable response"
|
26
|
+
|
27
|
+
its("class.type_camelized") { should == "List" }
|
28
|
+
its("class.type_underscored") { should == "list" }
|
29
|
+
|
30
|
+
it { should be_ok }
|
31
|
+
it { should_not be_error }
|
32
|
+
|
33
|
+
field :handles do
|
34
|
+
it_should_be_optional
|
35
|
+
|
36
|
+
it "should allow one or more handles" do
|
37
|
+
subject.handles = ["a", "b"]
|
38
|
+
subject.should be_valid
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/net_in_spec.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Warden::Protocol::NetInRequest do
|
6
|
+
subject(:request) do
|
7
|
+
described_class.new(:handle => "handle")
|
8
|
+
end
|
9
|
+
|
10
|
+
it_should_behave_like "wrappable request"
|
11
|
+
|
12
|
+
its("class.type_camelized") { should == "NetIn" }
|
13
|
+
its("class.type_underscored") { should == "net_in" }
|
14
|
+
|
15
|
+
field :handle do
|
16
|
+
it_should_be_required
|
17
|
+
it_should_be_typed_as_string
|
18
|
+
end
|
19
|
+
|
20
|
+
field :container_port do
|
21
|
+
it_should_be_optional
|
22
|
+
it_should_be_typed_as_uint
|
23
|
+
end
|
24
|
+
|
25
|
+
field :host_port do
|
26
|
+
it_should_be_optional
|
27
|
+
it_should_be_typed_as_uint
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should respond to #create_response" do
|
31
|
+
request.create_response.should be_a(Warden::Protocol::NetInResponse)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe Warden::Protocol::NetInResponse do
|
36
|
+
subject(:response) do
|
37
|
+
described_class.new(:host_port => 1234, :container_port => 1234)
|
38
|
+
end
|
39
|
+
|
40
|
+
it_should_behave_like "wrappable response"
|
41
|
+
|
42
|
+
its("class.type_camelized") { should == "NetIn" }
|
43
|
+
its("class.type_underscored") { should == "net_in" }
|
44
|
+
|
45
|
+
it { should be_ok }
|
46
|
+
it { should_not be_error }
|
47
|
+
|
48
|
+
field :host_port do
|
49
|
+
it_should_be_required
|
50
|
+
it_should_be_typed_as_uint
|
51
|
+
end
|
52
|
+
|
53
|
+
field :container_port do
|
54
|
+
it_should_be_required
|
55
|
+
it_should_be_typed_as_uint
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Warden::Protocol::NetOutRequest do
|
6
|
+
subject(:request) do
|
7
|
+
described_class.new(:handle => "handle")
|
8
|
+
end
|
9
|
+
|
10
|
+
it_should_behave_like "wrappable request"
|
11
|
+
|
12
|
+
its("class.type_camelized") { should == "NetOut" }
|
13
|
+
its("class.type_underscored") { should == "net_out" }
|
14
|
+
|
15
|
+
field :handle do
|
16
|
+
it_should_be_required
|
17
|
+
it_should_be_typed_as_string
|
18
|
+
end
|
19
|
+
|
20
|
+
field :network do
|
21
|
+
it_should_be_optional
|
22
|
+
it_should_be_typed_as_string
|
23
|
+
end
|
24
|
+
|
25
|
+
field :port do
|
26
|
+
it_should_be_optional
|
27
|
+
it_should_be_typed_as_uint
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should respond to #create_response" do
|
31
|
+
request.create_response.should be_a(Warden::Protocol::NetOutResponse)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe Warden::Protocol::NetOutResponse do
|
36
|
+
subject(:response) do
|
37
|
+
described_class.new
|
38
|
+
end
|
39
|
+
|
40
|
+
it_should_behave_like "wrappable response"
|
41
|
+
|
42
|
+
its("class.type_camelized") { should == "NetOut" }
|
43
|
+
its("class.type_underscored") { should == "net_out" }
|
44
|
+
|
45
|
+
it { should be_ok }
|
46
|
+
it { should_not be_error }
|
47
|
+
end
|
data/spec/ping_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Warden::Protocol::PingRequest do
|
6
|
+
subject(:request) do
|
7
|
+
described_class.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it_should_behave_like "wrappable request"
|
11
|
+
|
12
|
+
its("class.type_camelized") { should == "Ping" }
|
13
|
+
its("class.type_underscored") { should == "ping" }
|
14
|
+
|
15
|
+
it "should respond to #create_response" do
|
16
|
+
request.create_response.should be_a(Warden::Protocol::PingResponse)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe Warden::Protocol::PingResponse do
|
21
|
+
subject(:response) do
|
22
|
+
described_class.new
|
23
|
+
end
|
24
|
+
|
25
|
+
it_should_behave_like "wrappable response"
|
26
|
+
|
27
|
+
its("class.type_camelized") { should == "Ping" }
|
28
|
+
its("class.type_underscored") { should == "ping" }
|
29
|
+
|
30
|
+
it { should be_ok }
|
31
|
+
it { should_not be_error }
|
32
|
+
end
|