robot-controller 0.3.4 → 0.3.5
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Rakefile +5 -0
- data/VERSION +1 -1
- data/bin/controller +6 -0
- data/lib/robot-controller.rb +0 -1
- data/lib/robot-controller/bluepill.rb +4 -1
- data/lib/robot-controller/robots.rb +6 -8
- data/robot-controller.gemspec +1 -0
- data/spec/fixtures/standard.yml +9 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/unit/robots_spec.rb +87 -0
- metadata +23 -4
- data/lib/robot-controller/work_dir.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b6e7b98160ab2e2bafcedeb13febf37519a8b29
|
4
|
+
data.tar.gz: ec59baf962a34f223fb8e7af52f5de9ee76c4818
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c091e368df94d1b6d5f20debecd7a7e450bf0bd3071c4aa026895a8eb882d96ea80d155abd68706735a791854184ca9ceca7080d1b13bcf283d5c6f7e9d44164
|
7
|
+
data.tar.gz: 474170f9cfeed0aa05ff970ae6bc62dfc068e4f94e3942abec40fce7beef5dcbfa6c01d5ce00b417ea719bd1f1e820e3d41c2d65f0c04e86771b41d5af7033d6
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
data/bin/controller
CHANGED
@@ -25,6 +25,12 @@ ENV['ROBOT_ENVIRONMENT'] ||= 'development'
|
|
25
25
|
ENV['BLUEPILL_BASE_DIR'] ||= File.expand_path('run/bluepill')
|
26
26
|
ENV['BLUEPILL_LOGFILE'] ||= File.expand_path('log/bluepill.log')
|
27
27
|
|
28
|
+
unless File.directory?('config') &&
|
29
|
+
File.directory?(File.dirname(ENV['BLUEPILL_BASE_DIR'])) &&
|
30
|
+
File.directory?(File.dirname(ENV['BLUEPILL_LOGFILE']))
|
31
|
+
raise "Run from root directory"
|
32
|
+
end
|
33
|
+
|
28
34
|
cmd = 'bluepill'
|
29
35
|
cmd << ' --no-privileged'
|
30
36
|
cmd << " --base-dir #{ENV['BLUEPILL_BASE_DIR']}"
|
data/lib/robot-controller.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
WORKDIR =
|
1
|
+
WORKDIR = Dir.pwd
|
2
2
|
|
3
3
|
robot_environment = ENV['ROBOT_ENVIRONMENT'] || 'development'
|
4
4
|
require 'robot-controller/robots'
|
5
|
+
ROBOTS = RobotConfigParser.new.load("robots_#{robot_environment}.yml")
|
5
6
|
#
|
6
7
|
# Expect ROBOTS = [
|
7
8
|
# {:robot => 'x', :queues => ['a', 'b'], :n => 1}
|
8
9
|
# {:robot => 'z', :queues => ['b'], :n => 3}
|
9
10
|
# ]
|
10
11
|
#
|
12
|
+
|
13
|
+
# set application name to parent directory name
|
11
14
|
Bluepill.application File.basename(File.dirname(File.dirname(WORKDIR))),
|
12
15
|
:log_file => "#{WORKDIR}/log/bluepill.log" do |app|
|
13
16
|
app.working_dir = WORKDIR
|
@@ -27,7 +27,7 @@ class RobotConfigParser
|
|
27
27
|
# parse_lanes('A-C,E') == ['A-C', 'E']
|
28
28
|
def parse_lanes(lanes_spec)
|
29
29
|
return ['default'] if lanes_spec.split(/,/).collect {|l| l.strip}.join('') == ''
|
30
|
-
lanes_spec.split(/,/).collect {|l| l.strip }
|
30
|
+
lanes_spec.split(/,/).collect {|l| l.strip }.uniq
|
31
31
|
end
|
32
32
|
|
33
33
|
# build_queues('z','A') => ['z_A']
|
@@ -41,19 +41,20 @@ class RobotConfigParser
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# main entry point
|
44
|
-
def load(
|
45
|
-
#
|
46
|
-
robots_fn = File.join(
|
44
|
+
def load(robots_fn, dir = 'config/environments', host = nil)
|
45
|
+
# Validate parameters
|
46
|
+
robots_fn = File.join(dir, robots_fn) if dir
|
47
47
|
unless File.file?(robots_fn)
|
48
48
|
raise RuntimeError, "FileNotFound: #{robots_fn}"
|
49
49
|
end
|
50
50
|
|
51
|
+
# read the YAML file
|
51
52
|
puts "Loading #{robots_fn}"
|
52
53
|
robots = YAML.load_file(robots_fn)
|
53
54
|
# puts robots
|
54
55
|
|
55
56
|
# determine current host
|
56
|
-
host = `hostname -s`.strip
|
57
|
+
host = `hostname -s`.strip unless host
|
57
58
|
# puts host
|
58
59
|
|
59
60
|
# host = 'sul-robots1-dev' # XXX
|
@@ -93,6 +94,3 @@ class RobotConfigParser
|
|
93
94
|
r
|
94
95
|
end
|
95
96
|
end
|
96
|
-
|
97
|
-
ROBOTS = RobotConfigParser.new.load(ENV['ROBOT_ENVIRONMENT'] || 'development')
|
98
|
-
# puts ROBOTS
|
data/robot-controller.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency 'awesome_print'
|
29
29
|
s.add_development_dependency 'pry'
|
30
30
|
s.add_development_dependency 'rake'
|
31
|
+
s.add_development_dependency 'rspec'
|
31
32
|
s.add_development_dependency 'redcarpet' # provides Markdown
|
32
33
|
s.add_development_dependency 'version_bumper'
|
33
34
|
s.add_development_dependency 'yard'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
ENV['ROBOT_ENVIRONMENT'] ||= 'development'
|
4
|
+
ENV['ROBOT_LOG'] ||= '/dev/null'
|
5
|
+
ENV['ROBOT_LOG_LEVEL'] ||= 'debug'
|
6
|
+
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start
|
9
|
+
|
10
|
+
require 'bundler/setup'
|
11
|
+
Bundler.require(:default, :development)
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
end
|
15
|
+
|
16
|
+
Rails = Object.new unless defined? Rails
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'robot-controller/robots'
|
2
|
+
|
3
|
+
describe RobotConfigParser do
|
4
|
+
|
5
|
+
context "simple" do
|
6
|
+
subject {
|
7
|
+
RobotConfigParser.new.load('standard.yml', 'spec/fixtures', 'host1')
|
8
|
+
}
|
9
|
+
|
10
|
+
it "pass1" do
|
11
|
+
expect(subject).to eq [
|
12
|
+
{:robot=>"X", :queues=>["X_default"], :n=>1},
|
13
|
+
{:robot=>"Y", :queues=>["Y_B"], :n=>1},
|
14
|
+
{:robot=>"Z", :queues=>["Z_C"], :n=>3}
|
15
|
+
]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "expanded" do
|
20
|
+
subject {
|
21
|
+
RobotConfigParser.new.load('standard.yml', 'spec/fixtures', 'host2')
|
22
|
+
}
|
23
|
+
|
24
|
+
it "pass2" do
|
25
|
+
expect(subject).to eq [
|
26
|
+
{:robot=>"A", :queues=>["A_*"], :n=>1},
|
27
|
+
{:robot=>"B", :queues=>["B_X", "B_Y"], :n=>1},
|
28
|
+
{:robot=>"C", :queues=>["C_X", "C_Y", "C_Z"], :n=>5},
|
29
|
+
{:robot=>"D", :queues=>["D_default"], :n=>1},
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "parse_instances" do
|
35
|
+
subject {
|
36
|
+
RobotConfigParser.new
|
37
|
+
}
|
38
|
+
it "valid inputs" do
|
39
|
+
expect(subject.parse_instances(0)).to eq 1
|
40
|
+
expect(subject.parse_instances(1)).to eq 1
|
41
|
+
expect(subject.parse_instances(16)).to eq 16
|
42
|
+
end
|
43
|
+
|
44
|
+
it "invalid inputs" do
|
45
|
+
expect {
|
46
|
+
subject.parse_instances(17)
|
47
|
+
}.to raise_error RuntimeError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "parse_lanes" do
|
52
|
+
subject {
|
53
|
+
RobotConfigParser.new
|
54
|
+
}
|
55
|
+
|
56
|
+
it "valid inputs" do
|
57
|
+
expect(subject.parse_lanes('*')).to eq ['*']
|
58
|
+
expect(subject.parse_lanes('')).to eq ['default']
|
59
|
+
expect(subject.parse_lanes('default')).to eq ['default']
|
60
|
+
expect(subject.parse_lanes('A')).to eq ['A']
|
61
|
+
expect(subject.parse_lanes('A,B')).to eq ['A', 'B']
|
62
|
+
end
|
63
|
+
|
64
|
+
it "tricky inputs" do
|
65
|
+
expect(subject.parse_lanes(' ')).to eq ['default']
|
66
|
+
expect(subject.parse_lanes(' , ')).to eq ['default']
|
67
|
+
expect(subject.parse_lanes(' ,,')).to eq ['default']
|
68
|
+
expect(subject.parse_lanes('A , B')).to eq ['A','B']
|
69
|
+
expect(subject.parse_lanes('A-B')).to eq ['A-B']
|
70
|
+
expect(subject.parse_lanes('A,B,A')).to eq ['A','B']
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
context "build_queues" do
|
76
|
+
subject {
|
77
|
+
RobotConfigParser.new
|
78
|
+
}
|
79
|
+
|
80
|
+
it "valid inputs" do
|
81
|
+
expect(subject.build_queues('z','*')).to eq ['z_*']
|
82
|
+
expect(subject.build_queues('z','default')).to eq ['z_default']
|
83
|
+
expect(subject.build_queues('z','A,B,C')).to eq ['z_A','z_B','z_C']
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: robot-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Hardy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bluepill
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: redcarpet
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,9 +158,11 @@ files:
|
|
144
158
|
- lib/robot-controller/bluepill.rb
|
145
159
|
- lib/robot-controller/robots.rb
|
146
160
|
- lib/robot-controller/tasks.rb
|
147
|
-
- lib/robot-controller/work_dir.rb
|
148
161
|
- lib/tasks/doc.rake
|
149
162
|
- robot-controller.gemspec
|
163
|
+
- spec/fixtures/standard.yml
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/unit/robots_spec.rb
|
150
166
|
homepage: http://github.com/sul-dlss/robot-controller
|
151
167
|
licenses:
|
152
168
|
- ALv2
|
@@ -173,5 +189,8 @@ signing_key:
|
|
173
189
|
specification_version: 4
|
174
190
|
summary: Monitors and controls running workflow robots off of priority queues and
|
175
191
|
within a cluster
|
176
|
-
test_files:
|
192
|
+
test_files:
|
193
|
+
- spec/fixtures/standard.yml
|
194
|
+
- spec/spec_helper.rb
|
195
|
+
- spec/unit/robots_spec.rb
|
177
196
|
has_rdoc: true
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class WorkDir
|
2
|
-
|
3
|
-
def self.find base_dir
|
4
|
-
return ROBOT_ROOT if defined? ROBOT_ROOT
|
5
|
-
|
6
|
-
bot_root = base_dir
|
7
|
-
base = Pathname.new base_dir
|
8
|
-
base.ascend do |p|
|
9
|
-
if p.parent.basename.to_s =~ /releases/
|
10
|
-
bot_root = p
|
11
|
-
break
|
12
|
-
end
|
13
|
-
end
|
14
|
-
bot_root
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|