libis-workflow 2.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,231 @@
1
+ require_relative 'spec_helper'
2
+
3
+ require 'stringio'
4
+
5
+ describe 'TestWorkflow' do
6
+
7
+ DIRNAME = File.absolute_path(File.join(File.dirname(__FILE__), 'items'))
8
+
9
+ before :all do
10
+
11
+ puts DIRNAME
12
+
13
+ @logoutput = StringIO.new
14
+
15
+ ::Libis::Workflow.configure do |cfg|
16
+ cfg.itemdir = File.join(File.dirname(__FILE__), 'items')
17
+ cfg.taskdir = File.join(File.dirname(__FILE__), 'tasks')
18
+ cfg.workdir = File.join(File.dirname(__FILE__), 'work')
19
+ cfg.logger = Logger.new @logoutput
20
+ cfg.logger.level = Logger::DEBUG
21
+ end
22
+
23
+ @workflow = ::Libis::Workflow::Workflow.new
24
+ @workflow.configure(
25
+ name: 'TestWorkflow',
26
+ description: 'Workflow for testing',
27
+ tasks: [
28
+ {class: 'CollectFiles', recursive: true},
29
+ {
30
+ name: 'ProcessFiles',
31
+ subitems: true,
32
+ recursive: false,
33
+ tasks: [
34
+ {class: 'ChecksumTester', recursive: true},
35
+ {class: 'CamelizeName', recursive: true}
36
+ ]
37
+ }
38
+ ],
39
+ run_object: 'TestRun',
40
+ input: {
41
+ dirname: {default: '.', propagate_to: 'CollectFiles#location'},
42
+ checksum_type: {default: 'SHA1', propagate_to: 'ChecksumTester'}
43
+ }
44
+ )
45
+
46
+ # noinspection RubyStringKeysInHashInspection
47
+ @run = @workflow.run(dirname: DIRNAME, checksum_type: 'SHA256')
48
+ puts @logoutput.string
49
+
50
+ end
51
+
52
+ it 'should contain three tasks' do
53
+
54
+ expect(@workflow.config[:tasks].size).to eq 3
55
+ expect(@workflow.config[:tasks].first[:class]).to eq 'CollectFiles'
56
+ expect(@workflow.config[:tasks].last[:class]).to eq '::Libis::Workflow::Tasks::Analyzer'
57
+
58
+ end
59
+
60
+ # noinspection RubyResolve
61
+ it 'should camelize the workitem name' do
62
+
63
+ expect(@run.options[:dirname]).to eq DIRNAME
64
+ expect(@run.items.count).to eq 1
65
+ expect(@run.items.first.class).to eq TestDirItem
66
+ expect(@run.items.first.count).to eq 3
67
+ expect(@run.items.first.first.class).to eq TestFileItem
68
+
69
+ expect(@run.items.first.name).to eq 'Items'
70
+
71
+ @run.items.first.each_with_index do |x, i|
72
+ expect(x.name).to eq %w'TestDirItem.rb TestFileItem.rb TestRun.rb'[i]
73
+ end
74
+ end
75
+
76
+ it 'should return expected debug output' do
77
+
78
+ sample_out = <<STR
79
+ DEBUG -- CollectFiles - TestRun : Started
80
+ DEBUG -- CollectFiles - TestRun : Processing subitem (1/1): items
81
+ DEBUG -- CollectFiles - items : Started
82
+ DEBUG -- CollectFiles - items : Processing subitem (1/3): test_dir_item.rb
83
+ DEBUG -- CollectFiles - items/test_dir_item.rb : Started
84
+ DEBUG -- CollectFiles - items/test_dir_item.rb : Completed
85
+ DEBUG -- CollectFiles - items : Processing subitem (2/3): test_file_item.rb
86
+ DEBUG -- CollectFiles - items/test_file_item.rb : Started
87
+ DEBUG -- CollectFiles - items/test_file_item.rb : Completed
88
+ DEBUG -- CollectFiles - items : Processing subitem (3/3): test_run.rb
89
+ DEBUG -- CollectFiles - items/test_run.rb : Started
90
+ DEBUG -- CollectFiles - items/test_run.rb : Completed
91
+ DEBUG -- CollectFiles - items : 3 of 3 subitems passed
92
+ DEBUG -- CollectFiles - items : Completed
93
+ DEBUG -- CollectFiles - TestRun : 1 of 1 subitems passed
94
+ DEBUG -- CollectFiles - TestRun : Completed
95
+ DEBUG -- ProcessFiles - TestRun : Started
96
+ DEBUG -- ProcessFiles - TestRun : Processing subitem (1/1): items
97
+ DEBUG -- ProcessFiles - items : Started
98
+ DEBUG -- ProcessFiles - items : Running subtask (1/2): ChecksumTester
99
+ DEBUG -- ProcessFiles/ChecksumTester - items : Started
100
+ DEBUG -- ProcessFiles/ChecksumTester - items : Processing subitem (1/3): test_dir_item.rb
101
+ DEBUG -- ProcessFiles/ChecksumTester - items/test_dir_item.rb : Started
102
+ DEBUG -- ProcessFiles/ChecksumTester - items/test_dir_item.rb : Completed
103
+ DEBUG -- ProcessFiles/ChecksumTester - items : Processing subitem (2/3): test_file_item.rb
104
+ DEBUG -- ProcessFiles/ChecksumTester - items/test_file_item.rb : Started
105
+ DEBUG -- ProcessFiles/ChecksumTester - items/test_file_item.rb : Completed
106
+ DEBUG -- ProcessFiles/ChecksumTester - items : Processing subitem (3/3): test_run.rb
107
+ DEBUG -- ProcessFiles/ChecksumTester - items/test_run.rb : Started
108
+ DEBUG -- ProcessFiles/ChecksumTester - items/test_run.rb : Completed
109
+ DEBUG -- ProcessFiles/ChecksumTester - items : 3 of 3 subitems passed
110
+ DEBUG -- ProcessFiles/ChecksumTester - items : Completed
111
+ DEBUG -- ProcessFiles - items : Running subtask (2/2): CamelizeName
112
+ DEBUG -- ProcessFiles/CamelizeName - items : Started
113
+ DEBUG -- ProcessFiles/CamelizeName - Items : Processing subitem (1/3): test_dir_item.rb
114
+ DEBUG -- ProcessFiles/CamelizeName - Items/test_dir_item.rb : Started
115
+ DEBUG -- ProcessFiles/CamelizeName - Items/TestDirItem.rb : Completed
116
+ DEBUG -- ProcessFiles/CamelizeName - Items : Processing subitem (2/3): test_file_item.rb
117
+ DEBUG -- ProcessFiles/CamelizeName - Items/test_file_item.rb : Started
118
+ DEBUG -- ProcessFiles/CamelizeName - Items/TestFileItem.rb : Completed
119
+ DEBUG -- ProcessFiles/CamelizeName - Items : Processing subitem (3/3): test_run.rb
120
+ DEBUG -- ProcessFiles/CamelizeName - Items/test_run.rb : Started
121
+ DEBUG -- ProcessFiles/CamelizeName - Items/TestRun.rb : Completed
122
+ DEBUG -- ProcessFiles/CamelizeName - Items : 3 of 3 subitems passed
123
+ DEBUG -- ProcessFiles/CamelizeName - Items : Completed
124
+ DEBUG -- ProcessFiles - Items : Completed
125
+ DEBUG -- ProcessFiles - TestRun : 1 of 1 subitems passed
126
+ DEBUG -- ProcessFiles - TestRun : Completed
127
+ STR
128
+ sample_out = sample_out.lines.to_a
129
+ output = @logoutput.string.lines
130
+
131
+ puts output.join '\n'
132
+ expect(sample_out.count).to eq output.count
133
+ output.each_with_index do |o, i|
134
+ expect(o[/(?<=\] ).*/]).to eq sample_out[i].strip
135
+ end
136
+
137
+ expect(@run.summary['DEBUG']).to eq 48
138
+ expect(@run.log_history.count).to eq 8
139
+ expect(@run.status_log.count).to eq 6
140
+ expect(@run.items.first.log_history.count).to eq 22
141
+ expect(@run.items.first.status_log.count).to eq 8
142
+
143
+ [
144
+ {tasklist: nil, text: :STARTED},
145
+ {tasklist: %w'CollectFiles', text: :Started},
146
+ {tasklist: %w'CollectFiles', text: :Done},
147
+ {tasklist: %w'ProcessFiles', text: :Started},
148
+ {tasklist: %w'ProcessFiles', text: :Done},
149
+ {tasklist: nil, :text => :DONE},
150
+ ].each_with_index do |h, i|
151
+ h.keys.each { |key| expect(@run.status_log[i][key]).to eq h[key] }
152
+ end
153
+
154
+ [
155
+ {tasklist: %w'CollectFiles', text: :Started},
156
+ {tasklist: %w'CollectFiles', text: :Done},
157
+ {tasklist: %w'ProcessFiles', text: :Started},
158
+ {tasklist: %w'ProcessFiles ChecksumTester', text: :Started},
159
+ {tasklist: %w'ProcessFiles ChecksumTester', text: :Done},
160
+ {tasklist: %w'ProcessFiles CamelizeName', text: :Started},
161
+ {tasklist: %w'ProcessFiles CamelizeName', text: :Done},
162
+ {tasklist: %w'ProcessFiles', text: :Done},
163
+ ].each_with_index do |h, i|
164
+ h.keys.each { |key| expect(@run.items.first.status_log[i][key]).to eq h[key] }
165
+ end
166
+
167
+ [
168
+ {tasklist: %w'CollectFiles', text: :Started},
169
+ {tasklist: %w'CollectFiles', text: :Done},
170
+ {tasklist: %w'ProcessFiles ChecksumTester', text: :Started},
171
+ {tasklist: %w'ProcessFiles ChecksumTester', text: :Done},
172
+ {tasklist: %w'ProcessFiles CamelizeName', text: :Started},
173
+ {tasklist: %w'ProcessFiles CamelizeName', text: :Done},
174
+ ].each_with_index do |h, i|
175
+ h.keys.each { |key| expect(@run.items.first.first.status_log[i][key]).to eq h[key] }
176
+ end
177
+
178
+ [
179
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Started'},
180
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Processing subitem (1/1): items'},
181
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: '1 of 1 subitems passed'},
182
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Completed'},
183
+ {severity: 'DEBUG', task: 'ProcessFiles', id: 0, message: 'Started'},
184
+ {severity: 'DEBUG', task: 'ProcessFiles', id: 0, message: 'Processing subitem (1/1): items'},
185
+ {severity: 'DEBUG', task: 'ProcessFiles', id: 0, message: '1 of 1 subitems passed'},
186
+ {severity: 'DEBUG', task: 'ProcessFiles', id: 0, message: 'Completed'},
187
+ ].each_with_index do |h, i|
188
+ h.keys.each { |key| expect(@run.log_history[i][key]).to eq h[key] }
189
+ end
190
+
191
+ [
192
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Started'},
193
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Processing subitem (1/3): test_dir_item.rb'},
194
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Processing subitem (2/3): test_file_item.rb'},
195
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Processing subitem (3/3): test_run.rb'},
196
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: '3 of 3 subitems passed'},
197
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Completed'},
198
+ {severity: 'DEBUG', task: 'ProcessFiles', id: 0, message: 'Started'},
199
+ {severity: 'DEBUG', task: 'ProcessFiles', id: 0, message: 'Running subtask (1/2): ChecksumTester'},
200
+ {severity: 'DEBUG', task: 'ProcessFiles/ChecksumTester', id: 0, message: 'Started'},
201
+ {severity: 'DEBUG', task: 'ProcessFiles/ChecksumTester', id: 0, message: 'Processing subitem (1/3): test_dir_item.rb'},
202
+ {severity: 'DEBUG', task: 'ProcessFiles/ChecksumTester', id: 0, message: 'Processing subitem (2/3): test_file_item.rb'},
203
+ {severity: 'DEBUG', task: 'ProcessFiles/ChecksumTester', id: 0, message: 'Processing subitem (3/3): test_run.rb'},
204
+ {severity: 'DEBUG', task: 'ProcessFiles/ChecksumTester', id: 0, message: '3 of 3 subitems passed'},
205
+ {severity: 'DEBUG', task: 'ProcessFiles/ChecksumTester', id: 0, message: 'Completed'},
206
+ {severity: 'DEBUG', task: 'ProcessFiles', id: 0, message: 'Running subtask (2/2): CamelizeName'},
207
+ {severity: 'DEBUG', task: 'ProcessFiles/CamelizeName', id: 0, message: 'Started'},
208
+ {severity: 'DEBUG', task: 'ProcessFiles/CamelizeName', id: 0, message: 'Processing subitem (1/3): test_dir_item.rb'},
209
+ {severity: 'DEBUG', task: 'ProcessFiles/CamelizeName', id: 0, message: 'Processing subitem (2/3): test_file_item.rb'},
210
+ {severity: 'DEBUG', task: 'ProcessFiles/CamelizeName', id: 0, message: 'Processing subitem (3/3): test_run.rb'},
211
+ {severity: 'DEBUG', task: 'ProcessFiles/CamelizeName', id: 0, message: '3 of 3 subitems passed'},
212
+ {severity: 'DEBUG', task: 'ProcessFiles/CamelizeName', id: 0, message: 'Completed'},
213
+ {severity: 'DEBUG', task: 'ProcessFiles', id: 0, message: 'Completed'},
214
+ ].each_with_index do |h, i|
215
+ h.keys.each { |key| expect(@run.items.first.log_history[i][key]).to eq h[key] }
216
+ end
217
+
218
+ [
219
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Started'},
220
+ {severity: 'DEBUG', task: 'CollectFiles', id: 0, message: 'Completed'},
221
+ {severity: 'DEBUG', task: 'ProcessFiles/ChecksumTester', id: 0, message: 'Started'},
222
+ {severity: 'DEBUG', task: 'ProcessFiles/ChecksumTester', id: 0, message: 'Completed'},
223
+ {severity: 'DEBUG', task: 'ProcessFiles/CamelizeName', id: 0, message: 'Started'},
224
+ {severity: 'DEBUG', task: 'ProcessFiles/CamelizeName', id: 0, message: 'Completed'},
225
+ ].each_with_index do |h, i|
226
+ h.keys.each { |key| expect(@run.items.first.first.log_history[i][key]).to eq h[key] }
227
+ end
228
+
229
+ end
230
+
231
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libis-workflow
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.beta.3
5
+ platform: ruby
6
+ authors:
7
+ - Kris Dekeyser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: libis-tools
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.9'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sidekiq
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.3'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.3'
111
+ description: A simple framework to build custom task/workflow solutions.
112
+ email: kris.dekeyser@libis.be
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - ".coveralls.yml"
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
+ - Gemfile
121
+ - LICENSE
122
+ - README.md
123
+ - Rakefile
124
+ - lib/libis-workflow.rb
125
+ - lib/libis/exceptions.rb
126
+ - lib/libis/workflow.rb
127
+ - lib/libis/workflow/base/logger.rb
128
+ - lib/libis/workflow/base/run.rb
129
+ - lib/libis/workflow/base/workflow.rb
130
+ - lib/libis/workflow/config.rb
131
+ - lib/libis/workflow/message_registry.rb
132
+ - lib/libis/workflow/run.rb
133
+ - lib/libis/workflow/task.rb
134
+ - lib/libis/workflow/tasks/analyzer.rb
135
+ - lib/libis/workflow/version.rb
136
+ - lib/libis/workflow/worker.rb
137
+ - lib/libis/workflow/workflow.rb
138
+ - lib/libis/workflow/workitems.rb
139
+ - lib/libis/workflow/workitems/dir_item.rb
140
+ - lib/libis/workflow/workitems/file_item.rb
141
+ - lib/libis/workflow/workitems/work_item.rb
142
+ - libis-workflow.gemspec
143
+ - spec/items.rb
144
+ - spec/items/test_dir_item.rb
145
+ - spec/items/test_file_item.rb
146
+ - spec/items/test_run.rb
147
+ - spec/spec_helper.rb
148
+ - spec/task_spec.rb
149
+ - spec/tasks/camelize_name.rb
150
+ - spec/tasks/checksum_tester.rb
151
+ - spec/tasks/collect_files.rb
152
+ - spec/workflow_spec.rb
153
+ homepage: https://github.com/Kris-LIBIS/workflow
154
+ licenses:
155
+ - MIT
156
+ metadata: {}
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">"
169
+ - !ruby/object:Gem::Version
170
+ version: 1.3.1
171
+ requirements: []
172
+ rubyforge_project:
173
+ rubygems_version: 2.4.6
174
+ signing_key:
175
+ specification_version: 4
176
+ summary: LIBIS Workflow framework.
177
+ test_files:
178
+ - spec/items.rb
179
+ - spec/items/test_dir_item.rb
180
+ - spec/items/test_file_item.rb
181
+ - spec/items/test_run.rb
182
+ - spec/spec_helper.rb
183
+ - spec/task_spec.rb
184
+ - spec/tasks/camelize_name.rb
185
+ - spec/tasks/checksum_tester.rb
186
+ - spec/tasks/collect_files.rb
187
+ - spec/workflow_spec.rb