invoker 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/.gitignore +3 -0
- data/Gemfile +0 -1
- data/TODO +5 -0
- data/bin/invoker +0 -3
- data/invoker.gemspec +6 -1
- data/lib/invoker.rb +26 -1
- data/lib/invoker/command_listener/client.rb +1 -1
- data/lib/invoker/command_worker.rb +2 -2
- data/lib/invoker/commander.rb +34 -18
- data/lib/invoker/errors.rb +1 -0
- data/lib/invoker/parsers/config.rb +68 -4
- data/lib/invoker/parsers/option_parser.rb +18 -5
- data/lib/invoker/power.rb +6 -0
- data/lib/invoker/power/balancer.rb +118 -0
- data/lib/invoker/power/config.rb +53 -0
- data/lib/invoker/power/dns.rb +37 -0
- data/lib/invoker/power/port_finder.rb +49 -0
- data/lib/invoker/power/powerup.rb +26 -0
- data/lib/invoker/power/setup.rb +134 -0
- data/lib/invoker/runner.rb +8 -2
- data/lib/invoker/version.rb +1 -1
- data/readme.md +29 -0
- data/spec/invoker/commander_spec.rb +2 -2
- data/spec/invoker/config_spec.rb +106 -2
- data/spec/invoker/invoker_spec.rb +53 -0
- data/spec/invoker/power/config_spec.rb +24 -0
- data/spec/invoker/power/port_finder_spec.rb +16 -0
- data/spec/invoker/power/setup_spec.rb +87 -0
- metadata +104 -18
@@ -0,0 +1,53 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Invoker" do
|
4
|
+
describe "#darwin?" do
|
5
|
+
it "should return true on osx" do
|
6
|
+
Invoker.expects(:ruby_platform).returns("x86_64-darwin12.4.0")
|
7
|
+
Invoker.darwin?.should == true
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return false on linux" do
|
11
|
+
Invoker.expects(:ruby_platform).returns("i686-linux")
|
12
|
+
Invoker.darwin?.should == false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#can_run_balancer?" do
|
17
|
+
before {
|
18
|
+
File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
|
19
|
+
File.delete(Invoker::Power::Config::CONFIG_LOCATION)
|
20
|
+
}
|
21
|
+
|
22
|
+
after {
|
23
|
+
File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
|
24
|
+
File.delete(Invoker::Power::Config::CONFIG_LOCATION)
|
25
|
+
}
|
26
|
+
|
27
|
+
it "should return false if setup command was not run on osx" do
|
28
|
+
Invoker.expects(:ruby_platform).returns("x86_64-darwin12.4.0")
|
29
|
+
Invoker.can_run_balancer?.should ==false
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return false if platform is not osx" do
|
33
|
+
Invoker.expects(:ruby_platform).returns("i686-linux")
|
34
|
+
Invoker.can_run_balancer?.should == false
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return true if setup was run properly" do
|
38
|
+
Invoker.expects(:ruby_platform).returns("x86_64-darwin12.4.0")
|
39
|
+
File.open(Invoker::Power::Config::CONFIG_LOCATION, "w") {|fl|
|
40
|
+
fl.write("hello")
|
41
|
+
}
|
42
|
+
|
43
|
+
Invoker.can_run_balancer?.should === true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should not print warning if setup is not run when flag is false" do
|
47
|
+
Invoker.expects(:ruby_platform).returns("x86_64-darwin12.4.0")
|
48
|
+
Invoker::Logger.expects(:puts).never()
|
49
|
+
Invoker.can_run_balancer?(false)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Invoker Power configuration" do
|
4
|
+
describe "#create" do
|
5
|
+
it "should create a config file given a hash" do
|
6
|
+
begin
|
7
|
+
File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
|
8
|
+
File.delete(Invoker::Power::Config::CONFIG_LOCATION)
|
9
|
+
config = Invoker::Power::Config.create(
|
10
|
+
dns_port: 1200, http_port: 1201, ipfw_rule_number: 010
|
11
|
+
)
|
12
|
+
File.exists?(Invoker::Power::Config::CONFIG_LOCATION).should == true
|
13
|
+
|
14
|
+
config = Invoker::Power::Config.load_config()
|
15
|
+
config.dns_port.should == 1200
|
16
|
+
config.http_port.should == 1201
|
17
|
+
config.ipfw_rule_number.should == 010
|
18
|
+
ensure
|
19
|
+
File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
|
20
|
+
File.delete(Invoker::Power::Config::CONFIG_LOCATION)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "PortFinder" do
|
4
|
+
before do
|
5
|
+
@port_finder = Invoker::Power::PortFinder.new()
|
6
|
+
@port_finder.find_ports
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should find a http port" do
|
10
|
+
@port_finder.http_port.should.not == nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should find a dns port" do
|
14
|
+
@port_finder.dns_port.should.not == nil
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Setup" do
|
4
|
+
before {
|
5
|
+
@old_config = Invoker::Power::Config::CONFIG_LOCATION
|
6
|
+
Invoker::Power::Config.const_set(:CONFIG_LOCATION, "/tmp/.invoker")
|
7
|
+
|
8
|
+
File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
|
9
|
+
File.delete(Invoker::Power::Config::CONFIG_LOCATION)
|
10
|
+
|
11
|
+
@old_resolver = Invoker::Power::Setup::RESOLVER_FILE
|
12
|
+
Invoker::Power::Setup.const_set(:RESOLVER_FILE, "/tmp/invoker-dev")
|
13
|
+
|
14
|
+
File.exists?(Invoker::Power::Setup::RESOLVER_FILE) &&
|
15
|
+
File.delete(Invoker::Power::Setup::RESOLVER_FILE)
|
16
|
+
}
|
17
|
+
|
18
|
+
after {
|
19
|
+
File.exists?(Invoker::Power::Config::CONFIG_LOCATION) &&
|
20
|
+
File.delete(Invoker::Power::Config::CONFIG_LOCATION)
|
21
|
+
|
22
|
+
Invoker::Power::Config.const_set(:CONFIG_LOCATION, @old_config)
|
23
|
+
|
24
|
+
File.exists?(Invoker::Power::Setup::RESOLVER_FILE) &&
|
25
|
+
File.delete(Invoker::Power::Setup::RESOLVER_FILE)
|
26
|
+
Invoker::Power::Setup.const_set(:RESOLVER_FILE, @old_resolver)
|
27
|
+
}
|
28
|
+
|
29
|
+
describe "When no setup exists" do
|
30
|
+
it "should create a config file with port etc" do
|
31
|
+
setup = Invoker::Power::Setup.new()
|
32
|
+
setup.expects(:install_resolver).returns(true)
|
33
|
+
setup.expects(:flush_dns_rules).returns(true)
|
34
|
+
setup.expects(:drop_to_normal_user).returns(true)
|
35
|
+
setup.expects(:install_firewall).once()
|
36
|
+
|
37
|
+
setup.setup_invoker
|
38
|
+
|
39
|
+
config = Invoker::Power::Config.load_config()
|
40
|
+
config.http_port.should.not == nil
|
41
|
+
config.dns_port.should.not == nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when a setup file exists" do
|
46
|
+
it "should throw error about existing file" do
|
47
|
+
File.open(Invoker::Power::Config::CONFIG_LOCATION, "w") {|fl|
|
48
|
+
fl.write("foo test")
|
49
|
+
}
|
50
|
+
Invoker::Power::Setup.any_instance.expects(:setup_invoker).never
|
51
|
+
Invoker::Power::Setup.install()
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "when pow like setup exists" do
|
56
|
+
before {
|
57
|
+
File.open(Invoker::Power::Setup::RESOLVER_FILE, "w") {|fl|
|
58
|
+
fl.write("hello")
|
59
|
+
}
|
60
|
+
@setup = Invoker::Power::Setup.new
|
61
|
+
}
|
62
|
+
|
63
|
+
describe "when user selects to overwrite it" do
|
64
|
+
it "should run setup normally" do
|
65
|
+
@setup.expects(:setup_resolver_file).returns(true)
|
66
|
+
@setup.expects(:drop_to_normal_user).returns(true)
|
67
|
+
@setup.expects(:install_resolver).returns(true)
|
68
|
+
@setup.expects(:flush_dns_rules).returns(true)
|
69
|
+
@setup.expects(:install_firewall).once()
|
70
|
+
|
71
|
+
@setup.setup_invoker
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "when user chose not to overwrite it" do
|
76
|
+
it "should abort the setup process" do
|
77
|
+
@setup.expects(:setup_resolver_file).returns(false)
|
78
|
+
|
79
|
+
@setup.expects(:install_resolver).never
|
80
|
+
@setup.expects(:flush_dns_rules).never
|
81
|
+
@setup.expects(:install_firewall).never
|
82
|
+
|
83
|
+
@setup.setup_invoker
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invoker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hemant Kumar
|
@@ -39,87 +39,157 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.1.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: formatador
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.2.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.2.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: eventmachine
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 1.0.3
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 1.0.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: em-proxy
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.8
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.8
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubydns
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.6.5
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.6.5
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: uuid
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.3.7
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.3.7
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: highline
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.6.19
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.6.19
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: http-parser-lite
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.6.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.6.0
|
69
139
|
- !ruby/object:Gem::Dependency
|
70
140
|
name: bacon
|
71
141
|
requirement: !ruby/object:Gem::Requirement
|
72
142
|
requirements:
|
73
|
-
- - '>='
|
143
|
+
- - ! '>='
|
74
144
|
- !ruby/object:Gem::Version
|
75
145
|
version: '0'
|
76
146
|
type: :development
|
77
147
|
prerelease: false
|
78
148
|
version_requirements: !ruby/object:Gem::Requirement
|
79
149
|
requirements:
|
80
|
-
- - '>='
|
150
|
+
- - ! '>='
|
81
151
|
- !ruby/object:Gem::Version
|
82
152
|
version: '0'
|
83
153
|
- !ruby/object:Gem::Dependency
|
84
154
|
name: mocha
|
85
155
|
requirement: !ruby/object:Gem::Requirement
|
86
156
|
requirements:
|
87
|
-
- - '>='
|
157
|
+
- - ! '>='
|
88
158
|
- !ruby/object:Gem::Version
|
89
159
|
version: '0'
|
90
160
|
type: :development
|
91
161
|
prerelease: false
|
92
162
|
version_requirements: !ruby/object:Gem::Requirement
|
93
163
|
requirements:
|
94
|
-
- - '>='
|
164
|
+
- - ! '>='
|
95
165
|
- !ruby/object:Gem::Version
|
96
166
|
version: '0'
|
97
167
|
- !ruby/object:Gem::Dependency
|
98
168
|
name: mocha-on-bacon
|
99
169
|
requirement: !ruby/object:Gem::Requirement
|
100
170
|
requirements:
|
101
|
-
- - '>='
|
171
|
+
- - ! '>='
|
102
172
|
- !ruby/object:Gem::Version
|
103
173
|
version: '0'
|
104
174
|
type: :development
|
105
175
|
prerelease: false
|
106
176
|
version_requirements: !ruby/object:Gem::Requirement
|
107
177
|
requirements:
|
108
|
-
- - '>='
|
178
|
+
- - ! '>='
|
109
179
|
- !ruby/object:Gem::Version
|
110
180
|
version: '0'
|
111
181
|
- !ruby/object:Gem::Dependency
|
112
182
|
name: rake
|
113
183
|
requirement: !ruby/object:Gem::Requirement
|
114
184
|
requirements:
|
115
|
-
- - '>='
|
185
|
+
- - ! '>='
|
116
186
|
- !ruby/object:Gem::Version
|
117
187
|
version: '0'
|
118
188
|
type: :development
|
119
189
|
prerelease: false
|
120
190
|
version_requirements: !ruby/object:Gem::Requirement
|
121
191
|
requirements:
|
122
|
-
- - '>='
|
192
|
+
- - ! '>='
|
123
193
|
- !ruby/object:Gem::Version
|
124
194
|
version: '0'
|
125
195
|
description: Something small for process management
|
@@ -134,6 +204,7 @@ files:
|
|
134
204
|
- Gemfile
|
135
205
|
- MIT-LICENSE
|
136
206
|
- Rakefile
|
207
|
+
- TODO
|
137
208
|
- bin/invoker
|
138
209
|
- invoker.gemspec
|
139
210
|
- lib/invoker.rb
|
@@ -146,6 +217,13 @@ files:
|
|
146
217
|
- lib/invoker/logger.rb
|
147
218
|
- lib/invoker/parsers/config.rb
|
148
219
|
- lib/invoker/parsers/option_parser.rb
|
220
|
+
- lib/invoker/power.rb
|
221
|
+
- lib/invoker/power/balancer.rb
|
222
|
+
- lib/invoker/power/config.rb
|
223
|
+
- lib/invoker/power/dns.rb
|
224
|
+
- lib/invoker/power/port_finder.rb
|
225
|
+
- lib/invoker/power/powerup.rb
|
226
|
+
- lib/invoker/power/setup.rb
|
149
227
|
- lib/invoker/process_printer.rb
|
150
228
|
- lib/invoker/reactor.rb
|
151
229
|
- lib/invoker/runner.rb
|
@@ -156,6 +234,10 @@ files:
|
|
156
234
|
- spec/invoker/commander_spec.rb
|
157
235
|
- spec/invoker/config_spec.rb
|
158
236
|
- spec/invoker/event/manager_spec.rb
|
237
|
+
- spec/invoker/invoker_spec.rb
|
238
|
+
- spec/invoker/power/config_spec.rb
|
239
|
+
- spec/invoker/power/port_finder_spec.rb
|
240
|
+
- spec/invoker/power/setup_spec.rb
|
159
241
|
- spec/spec_helper.rb
|
160
242
|
homepage: http://github.com/code-mancers/invoker
|
161
243
|
licenses:
|
@@ -167,17 +249,17 @@ require_paths:
|
|
167
249
|
- lib
|
168
250
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
251
|
requirements:
|
170
|
-
- - '>='
|
252
|
+
- - ! '>='
|
171
253
|
- !ruby/object:Gem::Version
|
172
254
|
version: '0'
|
173
255
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
256
|
requirements:
|
175
|
-
- - '>='
|
257
|
+
- - ! '>='
|
176
258
|
- !ruby/object:Gem::Version
|
177
259
|
version: '0'
|
178
260
|
requirements: []
|
179
261
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.0.
|
262
|
+
rubygems_version: 2.0.7
|
181
263
|
signing_key:
|
182
264
|
specification_version: 4
|
183
265
|
summary: Something small for Process management
|
@@ -187,4 +269,8 @@ test_files:
|
|
187
269
|
- spec/invoker/commander_spec.rb
|
188
270
|
- spec/invoker/config_spec.rb
|
189
271
|
- spec/invoker/event/manager_spec.rb
|
272
|
+
- spec/invoker/invoker_spec.rb
|
273
|
+
- spec/invoker/power/config_spec.rb
|
274
|
+
- spec/invoker/power/port_finder_spec.rb
|
275
|
+
- spec/invoker/power/setup_spec.rb
|
190
276
|
- spec/spec_helper.rb
|