maestro_plugin 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -1
- data/lib/maestro_plugin/logging.rb +7 -4
- data/lib/maestro_plugin/maestro_worker.rb +6 -1
- data/lib/maestro_plugin/version.rb +1 -1
- data/spec/maestro_worker_spec.rb +83 -110
- metadata +132 -145
- checksums.yaml +0 -7
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jruby-1.
|
1
|
+
jruby-1.6.8
|
@@ -3,12 +3,15 @@ require 'logging'
|
|
3
3
|
|
4
4
|
module Maestro
|
5
5
|
|
6
|
-
|
6
|
+
unless Maestro.const_defined?('Logging')
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
module Logging
|
9
|
+
|
10
|
+
def log
|
11
|
+
::Logging::Logger.new(STDOUT)
|
12
|
+
end
|
11
13
|
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
class << self
|
@@ -202,7 +202,12 @@ module Maestro
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def output
|
205
|
-
|
205
|
+
if MaestroWorker.mock?
|
206
|
+
workitem[OUTPUT_META]
|
207
|
+
else
|
208
|
+
Maestro.log.warn "Output is only accessible when mock is enabled in tests. Otherwise is directly sent to Maestro"
|
209
|
+
nil
|
210
|
+
end
|
206
211
|
end
|
207
212
|
|
208
213
|
def error
|
data/spec/maestro_worker_spec.rb
CHANGED
@@ -2,168 +2,149 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Maestro::MaestroWorker do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
Maestro::MaestroWorker.mock!
|
9
|
-
end
|
5
|
+
let(:workitem) {{'fields' => {}}}
|
6
|
+
before { subject.workitem = workitem }
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
describe 'Mock' do
|
9
|
+
before { Maestro::MaestroWorker.mock! }
|
10
|
+
after { Maestro::MaestroWorker.unmock! }
|
14
11
|
|
15
12
|
it 'should mock send_workitem_message calls' do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@worker.write_output('Some test string')
|
23
|
-
|
13
|
+
subject.should_not_receive(:ruote_participant)
|
14
|
+
subject.write_output('Some test string')
|
15
|
+
end
|
16
|
+
context 'when accessing output' do
|
17
|
+
before { subject.write_output("xxx") }
|
18
|
+
its(:output) { should eq("xxx") }
|
24
19
|
end
|
25
|
-
|
26
20
|
end
|
27
21
|
|
28
22
|
describe 'Messaging' do
|
29
|
-
|
30
|
-
@workitem = {'fields' => {}}
|
31
|
-
@ruote_participants = double("ruote_participants")
|
32
|
-
@ruote_participants.should_receive(:send_workitem_message).at_least(:once).with(@workitem)
|
33
|
-
|
34
|
-
@worker = Maestro::MaestroWorker.new
|
35
|
-
@worker.stub(:ruote_participants => @ruote_participants)
|
36
|
-
@worker.stub(:workitem => @workitem)
|
37
|
-
@worker.should_receive(:send_workitem_message).at_least(:once).and_call_original
|
23
|
+
let(:ruote_participants) { double("ruote_participants") }
|
38
24
|
|
25
|
+
before :each do
|
26
|
+
ruote_participants.should_receive(:send_workitem_message).at_least(:once).with(workitem)
|
27
|
+
subject.stub(:ruote_participants => ruote_participants)
|
28
|
+
subject.should_receive(:send_workitem_message).at_least(:once).and_call_original
|
39
29
|
end
|
40
30
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
31
|
+
context 'when sending a write_output message' do
|
32
|
+
before { subject.write_output('Some Silly String') }
|
33
|
+
it { subject.workitem['__output__'].should eql('Some Silly String') }
|
34
|
+
it { subject.workitem['__streaming__'].should be_nil }
|
35
|
+
it("output should not be accesible without mock!") { expect(subject.output).to be_nil }
|
45
36
|
end
|
46
37
|
|
47
38
|
it 'should aggregate output' do
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
subject.write_output('Some Silly String')
|
40
|
+
subject.workitem['__output__'].should eql('Some Silly String')
|
41
|
+
subject.workitem['__streaming__'].should be_nil
|
51
42
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
43
|
+
subject.write_output("1", :buffer => true)
|
44
|
+
subject.workitem['__output__'].should eql('Some Silly String')
|
45
|
+
subject.workitem['__streaming__'].should be_nil
|
46
|
+
subject.write_output("22", :buffer => true)
|
47
|
+
subject.workitem['__output__'].should eql('Some Silly String')
|
48
|
+
subject.workitem['__streaming__'].should be_nil
|
58
49
|
|
59
50
|
# Should auto-send after 2 second delay
|
60
51
|
sleep 3
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
52
|
+
subject.write_output("333", :buffer => true)
|
53
|
+
subject.workitem['__output__'].should eql('122333')
|
54
|
+
subject.workitem['__streaming__'].should be_nil
|
55
|
+
subject.write_output("4444", :buffer => true)
|
56
|
+
subject.workitem['__output__'].should eql('122333')
|
57
|
+
subject.workitem['__streaming__'].should be_nil
|
67
58
|
|
68
59
|
# When called without aggregate, should purge
|
69
|
-
|
70
|
-
|
71
|
-
|
60
|
+
subject.write_output("5555")
|
61
|
+
subject.workitem['__output__'].should eql('44445555')
|
62
|
+
subject.workitem['__streaming__'].should be_nil
|
72
63
|
end
|
73
64
|
|
74
65
|
it 'should send a not needed message' do
|
75
|
-
|
76
|
-
|
66
|
+
subject.not_needed
|
67
|
+
subject.workitem['__not_needed__'].should be_nil
|
77
68
|
end
|
78
69
|
|
79
70
|
it 'should send a cancel message' do
|
80
|
-
|
81
|
-
|
71
|
+
subject.cancel
|
72
|
+
subject.workitem['__cancel__'].should be_nil
|
82
73
|
end
|
83
74
|
|
84
75
|
it 'should send a set_waiting message' do
|
85
76
|
# expects already in before :each block, so putting it here too causes test fail
|
86
|
-
#
|
87
|
-
|
88
|
-
|
77
|
+
# ruote_participants.should_receive(:send_workitem_message).with(@workitem)
|
78
|
+
subject.set_waiting(true)
|
79
|
+
subject.workitem['__waiting__'].should be_true
|
89
80
|
|
90
|
-
|
91
|
-
|
81
|
+
subject.set_waiting(false)
|
82
|
+
subject.workitem['__waiting__'].should be_nil
|
92
83
|
end
|
93
84
|
|
94
85
|
it 'should send a create record message' do
|
95
|
-
|
86
|
+
subject.create_record_with_fields('cars', ['manu', 'date', 'name'], ['ferrari', '1964', '250 GTO'])
|
96
87
|
|
97
|
-
|
98
|
-
|
99
|
-
|
88
|
+
subject.workitem['__model__'].should eql('cars')
|
89
|
+
subject.workitem['__record_fields__'].should eql('manu,date,name')
|
90
|
+
subject.workitem['__record_values__'].should eql('ferrari,1964,250 GTO')
|
100
91
|
end
|
101
92
|
|
102
93
|
it 'should send a create record message with a hash' do
|
103
94
|
fields = {'manu' => 'ferrari', 'date' => '1964', 'name' => 'GTO'}
|
104
|
-
|
105
|
-
|
106
|
-
|
95
|
+
subject.create_record_with_fields('cars', fields)
|
96
|
+
subject.workitem['__model__'].should eql('cars')
|
97
|
+
subject.workitem['__record_fields__'].should eql(fields)
|
107
98
|
end
|
108
99
|
|
109
100
|
it 'should send an update record-field message' do
|
110
|
-
|
101
|
+
subject.update_fields_in_record('animal', 'donkey', 'name', 'e-or')
|
111
102
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
103
|
+
subject.workitem['__model__'].should eql('animal')
|
104
|
+
subject.workitem['__record_id__'].should eql('donkey')
|
105
|
+
subject.workitem['__record_field__'].should eql('name')
|
106
|
+
subject.workitem['__record_value__'].should eql('e-or')
|
116
107
|
end
|
117
108
|
|
118
109
|
it 'should send a delete record message' do
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
110
|
+
subject.delete_record('animal', 1)
|
111
|
+
subject.workitem['__model__'].should eql('animal')
|
112
|
+
subject.workitem['__name__'].should eql('1')
|
113
|
+
subject.workitem['__filter__'].should be_nil
|
123
114
|
end
|
124
115
|
|
125
116
|
it 'should send a delete record message with a filter' do
|
126
117
|
filter = {'type' => 1}
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
118
|
+
subject.delete_record('animal', filter)
|
119
|
+
subject.workitem['__model__'].should eql('animal')
|
120
|
+
subject.workitem['__filter__'].should eql(filter)
|
121
|
+
subject.workitem['__name__'].should be_nil
|
131
122
|
end
|
132
123
|
end
|
133
124
|
|
134
125
|
describe 'Field handling' do
|
135
|
-
|
136
|
-
@worker = Maestro::MaestroWorker.new
|
137
|
-
@worker.workitem = {'fields' => {}}
|
138
|
-
end
|
126
|
+
let(:workitem) {{'fields' => {'a' => 'a'}}}
|
139
127
|
|
140
128
|
it 'should set and get errors' do
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
129
|
+
subject.workitem['__error__'].should be_nil
|
130
|
+
subject.error?.should be_false
|
131
|
+
subject.set_error 'myerror'
|
132
|
+
subject.error?.should be_true
|
133
|
+
subject.workitem['fields']['__error__'].should eq('myerror')
|
146
134
|
end
|
147
135
|
|
148
136
|
it 'should set fields' do
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
@worker.fields['b'].should eq('b')
|
137
|
+
subject.fields['a'].should eq('a')
|
138
|
+
subject.fields['b'] = 'b'
|
139
|
+
subject.fields['b'].should eq('b')
|
153
140
|
end
|
154
141
|
end
|
155
142
|
|
156
143
|
describe 'Helpers' do
|
157
|
-
before :each do
|
158
|
-
@worker = Maestro::MaestroWorker.new
|
159
|
-
@worker.workitem = {'fields' => {}}
|
160
|
-
end
|
161
|
-
|
162
144
|
it 'should validate JSON data contained in strings' do
|
163
|
-
|
164
|
-
|
145
|
+
subject.is_json?('{"key": "a string"}').should be_true
|
146
|
+
subject.is_json?('a string').should be_false
|
165
147
|
end
|
166
|
-
|
167
148
|
end
|
168
149
|
|
169
150
|
describe 'Errors' do
|
@@ -181,30 +162,22 @@ describe Maestro::MaestroWorker do
|
|
181
162
|
end
|
182
163
|
end
|
183
164
|
|
184
|
-
|
185
|
-
@worker = ErrorTestWorker.new
|
186
|
-
end
|
165
|
+
subject { ErrorTestWorker.new }
|
187
166
|
|
188
167
|
it 'should handle a ConfigError for bad config' do
|
189
|
-
workitem
|
190
|
-
|
191
|
-
@worker.perform(:configerror_test, workitem)
|
168
|
+
subject.perform(:configerror_test, workitem)
|
192
169
|
workitem['fields']['__error__'].should include('Bad Config')
|
193
170
|
workitem['__output__'].should be_nil
|
194
171
|
end
|
195
172
|
|
196
173
|
it 'should handle a PluginError' do
|
197
|
-
workitem
|
198
|
-
|
199
|
-
@worker.perform(:pluginerror_test, workitem)
|
174
|
+
subject.perform(:pluginerror_test, workitem)
|
200
175
|
workitem['fields']['__error__'].should include('PluginError - I had a problem')
|
201
176
|
workitem['__output__'].should be_nil
|
202
177
|
end
|
203
178
|
|
204
179
|
it 'should handle an unexpected Error' do
|
205
|
-
workitem
|
206
|
-
|
207
|
-
@worker.perform(:error_test, workitem)
|
180
|
+
subject.perform(:error_test, workitem)
|
208
181
|
workitem['fields']['__error__'].should include('Unexpected error executing task: Exception noooo')
|
209
182
|
workitem['__output__'].should be_nil
|
210
183
|
end
|
metadata
CHANGED
@@ -1,157 +1,144 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: maestro_plugin
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.16
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
- Etienne Pelletier
|
8
|
-
autorequire:
|
7
|
+
authors:
|
8
|
+
- Etienne Pelletier
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
requirements:
|
92
|
-
- - '>='
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '0'
|
95
|
-
prerelease: false
|
96
|
-
type: :development
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rspec
|
99
|
-
version_requirements: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 2.13.0
|
104
|
-
requirement: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - ~>
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: 2.13.0
|
109
|
-
prerelease: false
|
110
|
-
type: :development
|
12
|
+
|
13
|
+
date: 2013-08-11 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: logging
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.0
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rubyzip
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - "="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.9.8
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: json
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.4.6
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bundler
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "1.3"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rake
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: jruby-openssl
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id006
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.13.0
|
90
|
+
type: :development
|
91
|
+
version_requirements: *id007
|
111
92
|
description: A ruby library to help with the creation of Maestro plugins
|
112
|
-
email:
|
113
|
-
- epelletier@maestrodev.com
|
93
|
+
email:
|
94
|
+
- epelletier@maestrodev.com
|
114
95
|
executables: []
|
96
|
+
|
115
97
|
extensions: []
|
98
|
+
|
116
99
|
extra_rdoc_files: []
|
117
|
-
|
118
|
-
|
119
|
-
- .
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
- lib/maestro_plugin
|
126
|
-
- lib/maestro_plugin/
|
127
|
-
- lib/maestro_plugin/
|
128
|
-
- maestro_plugin.
|
129
|
-
-
|
130
|
-
- spec/
|
100
|
+
|
101
|
+
files:
|
102
|
+
- .gitignore
|
103
|
+
- .ruby-version
|
104
|
+
- Gemfile
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- lib/maestro_plugin.rb
|
109
|
+
- lib/maestro_plugin/logging.rb
|
110
|
+
- lib/maestro_plugin/maestro_worker.rb
|
111
|
+
- lib/maestro_plugin/version.rb
|
112
|
+
- maestro_plugin.gemspec
|
113
|
+
- spec/maestro_worker_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
131
115
|
homepage: https://github.com/maestrodev/maestro-ruby-plugin
|
132
|
-
licenses:
|
133
|
-
- Apache 2.0
|
134
|
-
|
135
|
-
post_install_message:
|
116
|
+
licenses:
|
117
|
+
- Apache 2.0
|
118
|
+
post_install_message:
|
136
119
|
rdoc_options: []
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
120
|
+
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: "0"
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: "0"
|
149
135
|
requirements: []
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
136
|
+
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 1.8.24
|
139
|
+
signing_key:
|
140
|
+
specification_version: 3
|
154
141
|
summary: Maestro ruby plugin
|
155
|
-
test_files:
|
156
|
-
- spec/maestro_worker_spec.rb
|
157
|
-
- spec/spec_helper.rb
|
142
|
+
test_files:
|
143
|
+
- spec/maestro_worker_spec.rb
|
144
|
+
- spec/spec_helper.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: e11866b367ab7fa42da98d6b51d1ecd4c23f988e
|
4
|
-
data.tar.gz: a4ad35e37e462e1659ae1e1fa72852af5ababe28
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: b40fdcdec594bb9d6b56445322788dff8eb697b512cc1b2372bfe030eb242b3ca16424692099534f857b070e712a960e58a1e54400e9fd832e5606c397c6b7bc
|
7
|
-
data.tar.gz: e9adec57b9053b60c76badc0b6aa1a240d28188a0cedaa8f0addf48cdcdcd8f6dce7aef67eda8ca80657a72915506e2107bcd89566be43130c266a24d3c9a4f8
|