dor-workflow-client 3.20.1 → 3.21.0
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/.github/pull_request_template.md +5 -0
- data/README.md +1 -1
- data/lib/dor/workflow/client/lifecycle_routes.rb +76 -12
- data/lib/dor/workflow/client/queues.rb +72 -49
- data/lib/dor/workflow/client/status.rb +1 -1
- data/lib/dor/workflow/client/version.rb +1 -1
- data/lib/dor/workflow/client/workflow_routes.rb +1 -1
- data/spec/workflow/client/lifecycle_routes_spec.rb +151 -24
- data/spec/workflow/client_spec.rb +59 -49
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa44370f3c08db522a5cfba8c511b44f096ea83cd6f3e55b209dc572a08b2922
|
4
|
+
data.tar.gz: 5d59452a5abf0f368f53ed48d78799726c8127795c724773e33d0a77f66ebaa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1465b2aea82e56422aabb3193a0a9d70ae5d1cdd40d086d2369d73c67e477eb0cff7f6ffb92937d59dc5f123b0ad906e8c1ab5f95ff9ef3c9a41532e193797d1
|
7
|
+
data.tar.gz: '095ab0801c5fddda8c554d32f0a537b38bc04dca3c97e50ff1aa396770aee56f2140a9e97d0e1e584b9b5269535649357eeed8be4207d12d0087dced540a8f16'
|
data/README.md
CHANGED
@@ -10,37 +10,102 @@ module Dor
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# Returns the Date for a requested milestone from workflow lifecycle
|
13
|
-
#
|
13
|
+
#
|
14
|
+
# @param [String] repo The repository the object resides in. This parameter is deprecated
|
14
15
|
# @param [String] druid object id
|
15
16
|
# @param [String] milestone_name the name of the milestone being queried for
|
16
17
|
# @param [Number] version the version to query for
|
17
18
|
# @param [Boolean] active_only (false) if true, return only lifecycle steps for versions that have all processes complete
|
18
19
|
# @return [Time] when the milestone was achieved. Returns nil if the milestone does not exist
|
19
20
|
#
|
20
|
-
|
21
|
-
|
21
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
22
|
+
def lifecycle(*args)
|
23
|
+
case args.size
|
24
|
+
when 4
|
25
|
+
Deprecation.warn(self, 'you provided 4 args, but lifecycle now takes kwargs')
|
26
|
+
(repo, druid, milestone_name) = args[0..2]
|
27
|
+
version = args[3][:version]
|
28
|
+
active_only = args[3][:active_only] || false
|
29
|
+
when 3
|
30
|
+
Deprecation.warn(self, 'you provided 3 args, but lifecycle now takes kwargs')
|
31
|
+
(repo, druid, milestone_name) = args
|
32
|
+
version = nil
|
33
|
+
active_only = false
|
34
|
+
when 1
|
35
|
+
opts = args.first
|
36
|
+
repo = opts[:repo]
|
37
|
+
druid = opts[:druid]
|
38
|
+
milestone_name = opts[:milestone_name]
|
39
|
+
version = opts[:version]
|
40
|
+
active_only = opts[:active_only] || false
|
41
|
+
else
|
42
|
+
raise ArgumentError, 'wrong number of arguments, must be 1, or 3-5'
|
43
|
+
end
|
44
|
+
|
45
|
+
Deprecation.warn(self, 'passing the repo parameter to lifecycle is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
|
46
|
+
|
47
|
+
filter_milestone(query_lifecycle(druid, version: version, active_only: active_only), milestone_name)
|
22
48
|
end
|
49
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
23
50
|
|
24
51
|
# Returns the Date for a requested milestone ONLY for the current version.
|
25
52
|
# This is slow as the workflow server will query dor-services-app for the version.
|
26
53
|
# A better approach is #lifecycle with the version tag.
|
27
|
-
# @param [String] repo repository name
|
28
54
|
# @param [String] druid object id
|
29
55
|
# @param [String] milestone_name the name of the milestone being queried for
|
30
56
|
# @param [Number] version the version to query for
|
31
57
|
# @return [Time] when the milestone was achieved. Returns nil if the milestone does not exis
|
32
58
|
#
|
33
|
-
|
34
|
-
|
59
|
+
# rubocop:disable Metrics/MethodLength
|
60
|
+
def active_lifecycle(*args)
|
61
|
+
case args.size
|
62
|
+
when 4
|
63
|
+
Deprecation.warn(self, 'you provided 4 args, but active_lifecycle now takes kwargs')
|
64
|
+
(repo, druid, milestone_name) = args[0..2]
|
65
|
+
version = args[3][:version]
|
66
|
+
when 3
|
67
|
+
Deprecation.warn(self, 'you provided 3 args, but active_lifecycle now takes kwargs')
|
68
|
+
(repo, druid, milestone_name) = args
|
69
|
+
version = nil
|
70
|
+
when 1
|
71
|
+
opts = args.first
|
72
|
+
repo = opts[:repo]
|
73
|
+
druid = opts[:druid]
|
74
|
+
milestone_name = opts[:milestone_name]
|
75
|
+
version = opts[:version]
|
76
|
+
else
|
77
|
+
raise ArgumentError, 'wrong number of arguments, must be 1, 3, or 4'
|
78
|
+
end
|
79
|
+
|
80
|
+
Deprecation.warn(self, 'passing the repo parameter to active_lifecycle is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
|
81
|
+
|
82
|
+
lifecycle(druid: druid, milestone_name: milestone_name, version: version, active_only: true)
|
35
83
|
end
|
84
|
+
# rubocop:enable Metrics/MethodLength
|
85
|
+
|
86
|
+
# @return [Array<Hash>]
|
87
|
+
# rubocop:disable Metrics/MethodLength
|
88
|
+
def milestones(*args)
|
89
|
+
case args.size
|
90
|
+
when 2
|
91
|
+
Deprecation.warn(self, 'you provided 2 args, but active_lifecycle now takes kwargs')
|
92
|
+
(repo, druid) = args
|
93
|
+
when 1
|
94
|
+
opts = args.first
|
95
|
+
repo = opts[:repo]
|
96
|
+
druid = opts.fetch(:druid)
|
97
|
+
else
|
98
|
+
raise ArgumentError, 'wrong number of arguments, must be 1-2'
|
99
|
+
end
|
100
|
+
|
101
|
+
Deprecation.warn(self, 'passing the repo parameter to active_lifecycle is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
|
36
102
|
|
37
|
-
|
38
|
-
def milestones(repo, druid)
|
39
|
-
doc = query_lifecycle(repo, druid, active_only: false)
|
103
|
+
doc = query_lifecycle(druid, active_only: false)
|
40
104
|
doc.xpath('//lifecycle/milestone').collect do |node|
|
41
105
|
{ milestone: node.text, at: Time.parse(node['date']), version: node['version'] }
|
42
106
|
end
|
43
107
|
end
|
108
|
+
# rubocop:enable Metrics/MethodLength
|
44
109
|
|
45
110
|
private
|
46
111
|
|
@@ -51,7 +116,6 @@ module Dor
|
|
51
116
|
Time.parse(milestone['date'])
|
52
117
|
end
|
53
118
|
|
54
|
-
# @param [String] repo repository name
|
55
119
|
# @param [String] druid object id
|
56
120
|
# @param [Boolean] active_only (false) if true, return only lifecycle steps for versions that have all processes complete
|
57
121
|
# @param [Number] version the version to query for
|
@@ -63,8 +127,8 @@ module Dor
|
|
63
127
|
# <milestone date="2010-06-15T16:08:58-0700">released</milestone>
|
64
128
|
# </lifecycle>
|
65
129
|
#
|
66
|
-
def query_lifecycle(
|
67
|
-
req = "
|
130
|
+
def query_lifecycle(druid, active_only:, version: nil)
|
131
|
+
req = "objects/#{druid}/lifecycle"
|
68
132
|
params = []
|
69
133
|
params << "version=#{version}" if version
|
70
134
|
params << 'active-only=true' if active_only
|
@@ -11,39 +11,59 @@ module Dor
|
|
11
11
|
|
12
12
|
# Returns all the distinct laneIds for a given workflow step
|
13
13
|
#
|
14
|
-
# @param [String] repo
|
14
|
+
# @param [String] repo -- deprecated, ignored by workflow service
|
15
15
|
# @param [String] workflow name
|
16
16
|
# @param [String] process name
|
17
17
|
# @return [Array<String>] all of the distinct laneIds. Array will be empty if no lane ids were found
|
18
|
-
def lane_ids(
|
19
|
-
|
18
|
+
def lane_ids(*args)
|
19
|
+
if args.count == 3
|
20
|
+
Deprecation.warn(
|
21
|
+
self,
|
22
|
+
'`#lane_ids` only takes two args: workflow name, & process/step name. This will raise an exception in Dor::Workflow::Client 4.0.0'
|
23
|
+
)
|
24
|
+
args.shift # ditch the `repo` argument
|
25
|
+
end
|
26
|
+
uri = "workflow_queue/lane_ids?step=#{args.first}:#{args.second}"
|
20
27
|
doc = Nokogiri::XML(requestor.request(uri))
|
21
|
-
|
22
|
-
nodes.map { |n| n['id'] }
|
28
|
+
doc.xpath('/lanes/lane').map { |n| n['id'] }
|
23
29
|
end
|
24
30
|
|
25
31
|
# Gets all of the workflow steps that have a status of 'queued' that have a last-updated timestamp older than the number of hours passed in
|
26
32
|
# This will enable re-queueing of jobs that have been lost by the job manager
|
27
|
-
# @param [String] repository
|
33
|
+
# @param [String] repository -- deprecated, ignored by workflow service
|
28
34
|
# @param [Hash] opts optional values for query
|
29
35
|
# @option opts [Integer] :hours_ago steps older than this value will be returned by the query. If not passed in, the service defaults to 0 hours,
|
30
36
|
# meaning you will get all queued workflows
|
31
37
|
# @option opts [Integer] :limit sets the maximum number of workflow steps that can be returned. Defaults to no limit
|
32
38
|
# @return [Array[Hash]] each Hash represents a workflow step. It will have the following keys:
|
33
39
|
# :workflow, :step, :druid, :lane_id
|
34
|
-
def stale_queued_workflows(
|
35
|
-
|
40
|
+
def stale_queued_workflows(*args)
|
41
|
+
if args.count == 2
|
42
|
+
Deprecation.warn(
|
43
|
+
self,
|
44
|
+
'`#stale_queued_workflows` only takes one arg: a hash. This will raise an exception in Dor::Workflow::Client 4.0.0'
|
45
|
+
)
|
46
|
+
args.shift # ditch the `repo` argument
|
47
|
+
end
|
48
|
+
uri_string = build_queued_uri(args.first)
|
36
49
|
parse_queued_workflows_response requestor.request(uri_string)
|
37
50
|
end
|
38
51
|
|
39
52
|
# Returns a count of workflow steps that have a status of 'queued' that have a last-updated timestamp older than the number of hours passed in
|
40
|
-
# @param [String] repository
|
53
|
+
# @param [String] repository -- deprecated, ignored by workflow service
|
41
54
|
# @param [Hash] opts optional values for query
|
42
55
|
# @option opts [Integer] :hours_ago steps older than this value will be returned by the query. If not passed in, the service defaults to 0 hours,
|
43
56
|
# meaning you will get all queued workflows
|
44
57
|
# @return [Integer] number of stale, queued steps if the :count_only option was set to true
|
45
|
-
def count_stale_queued_workflows(
|
46
|
-
|
58
|
+
def count_stale_queued_workflows(*args)
|
59
|
+
if args.count == 2
|
60
|
+
Deprecation.warn(
|
61
|
+
self,
|
62
|
+
'`#count_stale_queued_workflows` only takes one arg: a hash. This will raise an exception in Dor::Workflow::Client 4.0.0'
|
63
|
+
)
|
64
|
+
args.shift # ditch the `repo` argument
|
65
|
+
end
|
66
|
+
uri_string = build_queued_uri(args.first) + '&count-only=true'
|
47
67
|
doc = Nokogiri::XML(requestor.request(uri_string))
|
48
68
|
doc.at_xpath('/objects/@count').value.to_i
|
49
69
|
end
|
@@ -51,13 +71,11 @@ module Dor
|
|
51
71
|
# Returns a list of druids from the workflow service that meet the criteria
|
52
72
|
# of the passed in completed and waiting params
|
53
73
|
#
|
54
|
-
# @param [Array<String>, String] completed An array or single String of the completed steps, should use the qualified format: `
|
74
|
+
# @param [Array<String>, String] completed An array or single String of the completed steps, should use the qualified format: `workflow:step-name`
|
55
75
|
# @param [String] waiting name of the waiting step
|
56
|
-
# @param [String] repository default repository to use if it isn't passed in the qualified-step-name
|
57
76
|
# @param [String] workflow default workflow to use if it isn't passed in the qualified-step-name
|
58
77
|
# @param [String] lane_id issue a query for a specific lane_id for the waiting step
|
59
78
|
# @param [Hash] options
|
60
|
-
# @param options [String] :default_repository repository to query for if not using the qualified format
|
61
79
|
# @param options [String] :default_workflow workflow to query for if not using the qualified format
|
62
80
|
# @option options [Integer] :limit maximum number of druids to return (nil for no limit)
|
63
81
|
# @return [Array<String>] Array of druids
|
@@ -84,11 +102,12 @@ module Dor
|
|
84
102
|
# }
|
85
103
|
#
|
86
104
|
def objects_for_workstep(completed, waiting, lane_id = 'default', options = {})
|
87
|
-
|
105
|
+
Deprecation.warn(self, 'the `:default_repository` option in `#objects_for_workstep` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') if options[:default_repository]
|
106
|
+
waiting_param = qualify_step(options[:default_workflow], waiting)
|
88
107
|
uri_string = "workflow_queue?waiting=#{waiting_param}"
|
89
108
|
if completed
|
90
109
|
Array(completed).each do |step|
|
91
|
-
completed_param = qualify_step(options[:
|
110
|
+
completed_param = qualify_step(options[:default_workflow], step)
|
92
111
|
uri_string += "&completed=#{completed_param}"
|
93
112
|
end
|
94
113
|
end
|
@@ -107,33 +126,39 @@ module Dor
|
|
107
126
|
# convert into:
|
108
127
|
# ['druid:ab123de4567', 'druid:ab123de9012']
|
109
128
|
#
|
110
|
-
|
111
|
-
result.map { |n| n[:id] }
|
129
|
+
Nokogiri::XML(resp).xpath('//object[@id]').map { |n| n[:id] }
|
112
130
|
end
|
113
131
|
|
114
132
|
# Get a list of druids that have errored out in a particular workflow and step
|
115
133
|
#
|
116
134
|
# @param [String] workflow name
|
117
135
|
# @param [String] step name
|
118
|
-
# @param [String] repository --
|
136
|
+
# @param [String] repository -- deprecated, ignored by workflow service
|
119
137
|
#
|
120
138
|
# @return [Hash] hash of results, with key has a druid, and value as the error message
|
121
139
|
# @example
|
122
140
|
# client.errored_objects_for_workstep('accessionWF','content-metadata')
|
123
141
|
# => {"druid:qd556jq0580"=>"druid:qd556jq0580 - Item error; caused by
|
124
142
|
# #<Rubydora::FedoraInvalidRequest: Error modifying datastream contentMetadata for druid:qd556jq0580. See logger for details>"}
|
125
|
-
def errored_objects_for_workstep(workflow, step, repository =
|
126
|
-
|
127
|
-
|
128
|
-
Nokogiri::XML(resp).xpath('//object').
|
129
|
-
|
130
|
-
end
|
131
|
-
result
|
143
|
+
def errored_objects_for_workstep(workflow, step, repository = nil)
|
144
|
+
Deprecation.warn(self, 'the third argument to `#errored_objects_for_workstep` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') unless repository.nil?
|
145
|
+
resp = requestor.request "workflow_queue?workflow=#{workflow}&error=#{step}"
|
146
|
+
Nokogiri::XML(resp).xpath('//object').map do |node|
|
147
|
+
[node['id'], node['errorMessage']]
|
148
|
+
end.to_h
|
132
149
|
end
|
133
150
|
|
134
151
|
# Used by preservation robots stats reporter
|
135
|
-
|
136
|
-
|
152
|
+
#
|
153
|
+
# @param [String] workflow name
|
154
|
+
# @param [String] step name
|
155
|
+
# @param [String] type
|
156
|
+
# @param [String] repo -- deprecated, ignored by workflow service
|
157
|
+
#
|
158
|
+
# @return [Hash] hash of results, with key has a druid, and value as the error message
|
159
|
+
def count_objects_in_step(workflow, step, type, repo = nil)
|
160
|
+
Deprecation.warn(self, 'the fourth argument to `#count_objects_in_step` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') unless repo.nil?
|
161
|
+
resp = requestor.request "workflow_queue?workflow=#{workflow}&#{type}=#{step}"
|
137
162
|
extract_object_count(resp)
|
138
163
|
end
|
139
164
|
|
@@ -141,52 +166,50 @@ module Dor
|
|
141
166
|
#
|
142
167
|
# @param [String] workflow name
|
143
168
|
# @param [String] step name
|
144
|
-
# @param [String] repository --
|
169
|
+
# @param [String] repository -- deprecated, ignored by workflow service
|
145
170
|
#
|
146
171
|
# @return [Integer] Number of objects with this repository:workflow:step that have a status of 'error'
|
147
|
-
def count_errored_for_workstep(workflow, step, repository =
|
148
|
-
|
172
|
+
def count_errored_for_workstep(workflow, step, repository = nil)
|
173
|
+
Deprecation.warn(self, 'the third argument to `#count_errored_for_workstep` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') unless repository.nil?
|
174
|
+
count_objects_in_step(workflow, step, 'error')
|
149
175
|
end
|
150
176
|
|
151
177
|
# Returns the number of objects that have a status of 'queued' in a particular workflow and step
|
152
178
|
#
|
153
179
|
# @param [String] workflow name
|
154
180
|
# @param [String] step name
|
155
|
-
# @param [String] repository --
|
181
|
+
# @param [String] repository -- deprecated, ignored by workflow service
|
156
182
|
#
|
157
183
|
# @return [Integer] Number of objects with this repository:workflow:step that have a status of 'queued'
|
158
|
-
def count_queued_for_workstep(workflow, step, repository =
|
159
|
-
|
184
|
+
def count_queued_for_workstep(workflow, step, repository = nil)
|
185
|
+
Deprecation.warn(self, 'the third argument to `#count_queued_for_workstep` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') unless repository.nil?
|
186
|
+
count_objects_in_step(workflow, step, 'queued')
|
160
187
|
end
|
161
188
|
|
162
189
|
private
|
163
190
|
|
164
191
|
attr_reader :requestor
|
165
192
|
|
166
|
-
def build_queued_uri(
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
uri_string
|
193
|
+
def build_queued_uri(opts = {})
|
194
|
+
query_hash = opts.slice(:hours_ago, :limit).transform_keys { |key| key.to_s.tr('_', '-') }
|
195
|
+
query_string = URI.encode_www_form(query_hash)
|
196
|
+
"workflow_queue/all_queued?#{query_string}"
|
171
197
|
end
|
172
198
|
|
173
|
-
# Converts
|
174
|
-
# @param [String] default_repository
|
199
|
+
# Converts workflow-step into workflow:step
|
175
200
|
# @param [String] default_workflow
|
176
201
|
# @param [String] step if contains colon :, then the value for workflow and/or workflow/repository. For example: 'jp2-create', 'assemblyWF:jp2-create' or 'dor:assemblyWF:jp2-create'
|
177
|
-
# @return [String]
|
202
|
+
# @return [String] workflow:step
|
178
203
|
# @example
|
179
|
-
#
|
180
|
-
def qualify_step(
|
181
|
-
current = step.split(
|
182
|
-
current.unshift(default_workflow)
|
183
|
-
current.unshift(default_repository) if current.length < 3
|
204
|
+
# assemblyWF:jp2-create
|
205
|
+
def qualify_step(default_workflow, step)
|
206
|
+
current = step.split(':').last(2)
|
207
|
+
current.unshift(default_workflow) if current.length < 2
|
184
208
|
current.join(':')
|
185
209
|
end
|
186
210
|
|
187
211
|
def parse_queued_workflows_response(xml)
|
188
|
-
|
189
|
-
doc.xpath('/workflows/workflow').collect do |wf_node|
|
212
|
+
Nokogiri::XML(xml).xpath('/workflows/workflow').collect do |wf_node|
|
190
213
|
{
|
191
214
|
workflow: wf_node['name'],
|
192
215
|
step: wf_node['process'],
|
@@ -274,7 +274,7 @@ module Dor
|
|
274
274
|
workflow(pid: pid, workflow_name: workflow_name).process_for_recent_version(name: process)
|
275
275
|
end
|
276
276
|
|
277
|
-
# Deletes a workflow from a particular repository and druid
|
277
|
+
# Deletes a workflow from a particular repository and druid. This is only used by Hydrus.
|
278
278
|
# @param [String] repo The repository the object resides in. The service recoginzes "dor" and "sdr" at the moment
|
279
279
|
# @param [String] druid The id of the object to delete the workflow from
|
280
280
|
# @param [String] workflow The name of the workflow to be deleted
|
@@ -6,6 +6,8 @@ RSpec.describe Dor::Workflow::Client::LifecycleRoutes do
|
|
6
6
|
let(:requestor) { instance_double(Dor::Workflow::Client::Requestor, request: response) }
|
7
7
|
let(:response) { '<xml />' }
|
8
8
|
let(:routes) { described_class.new(requestor: requestor) }
|
9
|
+
let(:repo) { 'dor' }
|
10
|
+
let(:druid) { 'druid:gv054hp4128' }
|
9
11
|
|
10
12
|
describe '#milestones' do
|
11
13
|
let(:ng_xml) { Nokogiri::XML(xml) }
|
@@ -15,52 +17,177 @@ RSpec.describe Dor::Workflow::Client::LifecycleRoutes do
|
|
15
17
|
|
16
18
|
before do
|
17
19
|
allow(routes).to receive(:query_lifecycle).and_return(ng_xml)
|
20
|
+
allow(Deprecation).to receive(:warn)
|
18
21
|
end
|
19
22
|
|
20
|
-
|
23
|
+
context 'with positional arguments' do
|
24
|
+
subject(:milestones) { routes.milestones(repo, druid) }
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
it 'includes the version in with the milestones' do
|
27
|
+
expect(milestones.first[:milestone]).to eq('published')
|
28
|
+
expect(milestones.first[:version]).to eq('2')
|
29
|
+
expect(Deprecation).to have_received(:warn).twice
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with kwargs' do
|
34
|
+
subject(:milestones) { routes.milestones(druid: druid) }
|
35
|
+
|
36
|
+
it 'includes the version in with the milestones' do
|
37
|
+
expect(milestones.first[:milestone]).to eq('published')
|
38
|
+
expect(milestones.first[:version]).to eq('2')
|
39
|
+
end
|
25
40
|
end
|
26
41
|
end
|
27
42
|
|
28
43
|
describe '#lifecycle' do
|
29
|
-
context '
|
30
|
-
|
44
|
+
context 'with positional arguments' do
|
45
|
+
before do
|
46
|
+
allow(Deprecation).to receive(:warn)
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'without version' do
|
50
|
+
subject(:lifecycle) { routes.lifecycle(repo, druid, 'submitted') }
|
51
|
+
|
52
|
+
it 'make the request' do
|
53
|
+
lifecycle
|
54
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle')
|
55
|
+
expect(Deprecation).to have_received(:warn).twice
|
56
|
+
end
|
57
|
+
end
|
31
58
|
|
32
|
-
|
33
|
-
lifecycle
|
34
|
-
|
59
|
+
context 'with version' do
|
60
|
+
subject(:lifecycle) { routes.lifecycle(repo, druid, 'submitted', version: 3) }
|
61
|
+
|
62
|
+
it 'makes the request with the version' do
|
63
|
+
lifecycle
|
64
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3')
|
65
|
+
expect(Deprecation).to have_received(:warn).twice
|
66
|
+
end
|
35
67
|
end
|
36
68
|
end
|
37
69
|
|
38
|
-
context 'with
|
39
|
-
|
70
|
+
context 'with kwargs' do
|
71
|
+
before do
|
72
|
+
allow(Deprecation).to receive(:warn)
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with deprecated repo arg' do
|
76
|
+
context 'without version' do
|
77
|
+
subject(:lifecycle) { routes.lifecycle(repo: repo, druid: druid, milestone_name: 'submitted') }
|
78
|
+
|
79
|
+
it 'make the request' do
|
80
|
+
lifecycle
|
81
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle')
|
82
|
+
expect(Deprecation).to have_received(:warn)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'with version' do
|
87
|
+
subject(:lifecycle) { routes.lifecycle(repo: repo, druid: druid, milestone_name: 'submitted', version: 3) }
|
40
88
|
|
41
|
-
|
42
|
-
|
43
|
-
|
89
|
+
it 'makes the request with the version' do
|
90
|
+
lifecycle
|
91
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3')
|
92
|
+
expect(Deprecation).to have_received(:warn)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'without version' do
|
98
|
+
subject(:lifecycle) { routes.lifecycle(druid: druid, milestone_name: 'submitted') }
|
99
|
+
|
100
|
+
it 'make the request' do
|
101
|
+
lifecycle
|
102
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle')
|
103
|
+
expect(Deprecation).not_to have_received(:warn)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'with version' do
|
108
|
+
subject(:lifecycle) { routes.lifecycle(druid: druid, milestone_name: 'submitted', version: 3) }
|
109
|
+
|
110
|
+
it 'makes the request with the version' do
|
111
|
+
lifecycle
|
112
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3')
|
113
|
+
expect(Deprecation).not_to have_received(:warn)
|
114
|
+
end
|
44
115
|
end
|
45
116
|
end
|
46
117
|
end
|
47
118
|
|
48
119
|
describe '#active_lifecycle' do
|
49
|
-
context '
|
50
|
-
|
120
|
+
context 'with positional arguments' do
|
121
|
+
before do
|
122
|
+
allow(Deprecation).to receive(:warn)
|
123
|
+
end
|
51
124
|
|
52
|
-
|
53
|
-
active_lifecycle
|
54
|
-
|
125
|
+
context 'without version' do
|
126
|
+
subject(:active_lifecycle) { routes.active_lifecycle(repo, druid, 'submitted') }
|
127
|
+
|
128
|
+
it 'make the request' do
|
129
|
+
active_lifecycle
|
130
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?active-only=true')
|
131
|
+
expect(Deprecation).to have_received(:warn).twice
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'with version' do
|
136
|
+
subject(:active_lifecycle) { routes.active_lifecycle(repo, druid, 'submitted', version: 3) }
|
137
|
+
|
138
|
+
it 'makes the request with the version' do
|
139
|
+
active_lifecycle
|
140
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3&active-only=true')
|
141
|
+
expect(Deprecation).to have_received(:warn).twice
|
142
|
+
end
|
55
143
|
end
|
56
144
|
end
|
57
145
|
|
58
|
-
context 'with
|
59
|
-
|
146
|
+
context 'with kwargs' do
|
147
|
+
before do
|
148
|
+
allow(Deprecation).to receive(:warn)
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'with deprecated repo arg' do
|
152
|
+
context 'without version' do
|
153
|
+
subject(:active_lifecycle) { routes.active_lifecycle(repo: repo, druid: druid, milestone_name: 'submitted') }
|
154
|
+
|
155
|
+
it 'make the request' do
|
156
|
+
active_lifecycle
|
157
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?active-only=true')
|
158
|
+
expect(Deprecation).to have_received(:warn)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'with version' do
|
163
|
+
subject(:active_lifecycle) { routes.active_lifecycle(repo: repo, druid: druid, milestone_name: 'submitted', version: 3) }
|
164
|
+
|
165
|
+
it 'makes the request with the version' do
|
166
|
+
active_lifecycle
|
167
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3&active-only=true')
|
168
|
+
expect(Deprecation).to have_received(:warn)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'without version' do
|
174
|
+
subject(:active_lifecycle) { routes.active_lifecycle(druid: druid, milestone_name: 'submitted') }
|
175
|
+
|
176
|
+
it 'make the request' do
|
177
|
+
active_lifecycle
|
178
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?active-only=true')
|
179
|
+
expect(Deprecation).not_to have_received(:warn)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'with version' do
|
184
|
+
subject(:active_lifecycle) { routes.active_lifecycle(druid: druid, milestone_name: 'submitted', version: 3) }
|
60
185
|
|
61
|
-
|
62
|
-
|
63
|
-
|
186
|
+
it 'makes the request with the version' do
|
187
|
+
active_lifecycle
|
188
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3&active-only=true')
|
189
|
+
expect(Deprecation).not_to have_received(:warn)
|
190
|
+
end
|
64
191
|
end
|
65
192
|
end
|
66
193
|
end
|
@@ -44,7 +44,6 @@ RSpec.describe Dor::Workflow::Client do
|
|
44
44
|
let(:mock_logger) { double('Logger', info: true, debug: true, warn: true) }
|
45
45
|
|
46
46
|
before do
|
47
|
-
@repo = 'dor'
|
48
47
|
@druid = 'druid:123'
|
49
48
|
end
|
50
49
|
|
@@ -84,17 +83,17 @@ RSpec.describe Dor::Workflow::Client do
|
|
84
83
|
end
|
85
84
|
|
86
85
|
it 'requests the workflow by name and return the URL to the workflow' do
|
87
|
-
client.create_workflow(
|
86
|
+
client.create_workflow(nil, @druid, 'etdSubmitWF', wf_xml)
|
88
87
|
expect(Deprecation).to have_received(:warn).twice
|
89
88
|
end
|
90
89
|
|
91
90
|
it 'raises on an unexpected Exception' do
|
92
|
-
expect { client.create_workflow(
|
91
|
+
expect { client.create_workflow(nil, @druid, 'raiseException', wf_xml) }.to raise_error(Exception, 'broken')
|
93
92
|
expect(Deprecation).to have_received(:warn).twice
|
94
93
|
end
|
95
94
|
|
96
95
|
it 'sets the lane_id param if provided in options hash' do
|
97
|
-
client.create_workflow(
|
96
|
+
client.create_workflow(nil, @druid, 'laneIdWF', wf_xml, lane_id: 'foo_lane')
|
98
97
|
expect(Deprecation).to have_received(:warn).twice
|
99
98
|
end
|
100
99
|
end
|
@@ -153,16 +152,16 @@ RSpec.describe Dor::Workflow::Client do
|
|
153
152
|
describe '#update_workflow_status' do
|
154
153
|
let(:stubs) do
|
155
154
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
156
|
-
stub.put("
|
155
|
+
stub.put("objects/#{@druid}/workflows/etdSubmitWF/registrar-approval?current-status=queued") do |_env|
|
157
156
|
[201, {}, '{"next_steps":["submit-marc"]}']
|
158
157
|
end
|
159
158
|
|
160
|
-
stub.put("
|
159
|
+
stub.put("objects/#{@druid}/workflows/etdSubmitWF/registrar-approval") do |env|
|
161
160
|
expect(env.body).to eq "<?xml version=\"1.0\"?>\n<process name=\"registrar-approval\" status=\"completed\" elapsed=\"0\" note=\"annotation\" version=\"2\" laneId=\"lane2\"/>\n"
|
162
161
|
[201, {}, '{"next_steps":["submit-marc"]}']
|
163
162
|
end
|
164
163
|
|
165
|
-
stub.put("
|
164
|
+
stub.put("objects/#{@druid}/workflows/errorWF/registrar-approval") do |_env|
|
166
165
|
[400, {}, '']
|
167
166
|
end
|
168
167
|
end
|
@@ -172,21 +171,21 @@ RSpec.describe Dor::Workflow::Client do
|
|
172
171
|
end
|
173
172
|
|
174
173
|
it 'should update workflow status and return true if successful' do
|
175
|
-
expect(client.update_workflow_status(
|
174
|
+
expect(client.update_workflow_status(nil, @druid, 'etdSubmitWF', 'registrar-approval', 'completed', version: 2, note: 'annotation', lane_id: 'lane2')).to be_kind_of Dor::Workflow::Response::Update
|
176
175
|
end
|
177
176
|
|
178
177
|
it 'should return false if the PUT to the DOR workflow service throws an exception' do
|
179
|
-
expect { client.update_workflow_status(
|
178
|
+
expect { client.update_workflow_status(nil, @druid, 'errorWF', 'registrar-approval', 'completed') }.to raise_error(Dor::WorkflowException, /status 400/)
|
180
179
|
end
|
181
180
|
|
182
181
|
it 'performs a conditional update when current-status is passed as a parameter' do
|
183
|
-
expect(mock_http_connection).to receive(:put).with("
|
182
|
+
expect(mock_http_connection).to receive(:put).with("/objects/#{@druid}/workflows/etdSubmitWF/registrar-approval?current-status=queued").and_call_original
|
184
183
|
|
185
|
-
expect(client.update_workflow_status(
|
184
|
+
expect(client.update_workflow_status(nil, @druid, 'etdSubmitWF', 'registrar-approval', 'completed', version: 2, note: 'annotation', lane_id: 'lane1', current_status: 'queued')).to be_kind_of Dor::Workflow::Response::Update
|
186
185
|
end
|
187
186
|
|
188
187
|
it 'should throw exception if invalid status provided' do
|
189
|
-
expect { client.update_workflow_status(
|
188
|
+
expect { client.update_workflow_status(nil, @druid, 'accessionWF', 'publish', 'NOT_VALID_STATUS') }.to raise_error(ArgumentError)
|
190
189
|
end
|
191
190
|
end
|
192
191
|
|
@@ -209,10 +208,10 @@ RSpec.describe Dor::Workflow::Client do
|
|
209
208
|
end
|
210
209
|
|
211
210
|
it 'should update workflow status to error and return true if successful' do
|
212
|
-
client.update_workflow_error_status(
|
211
|
+
client.update_workflow_error_status(nil, @druid, 'etdSubmitWF', 'reader-approval', 'Some exception', error_text: 'The optional stacktrace')
|
213
212
|
end
|
214
213
|
it 'should return false if the PUT to the DOR workflow service throws an exception' do
|
215
|
-
expect { client.update_workflow_error_status(
|
214
|
+
expect { client.update_workflow_error_status(nil, @druid, 'errorWF', 'reader-approval', 'completed') }.to raise_error(Dor::WorkflowException, /status 400/)
|
216
215
|
end
|
217
216
|
end
|
218
217
|
|
@@ -255,7 +254,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
255
254
|
end
|
256
255
|
|
257
256
|
describe '#workflow_status' do
|
258
|
-
let(:repo) {
|
257
|
+
let(:repo) { nil }
|
259
258
|
let(:druid) { @druid }
|
260
259
|
let(:stubs) do
|
261
260
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
@@ -401,6 +400,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
401
400
|
context 'with keyword args' do
|
402
401
|
subject(:workflow_xml) { client.workflow_xml(druid: 'druid:123', workflow: workflow) }
|
403
402
|
|
403
|
+
# TODO: Remove this `context` block altogether when repos are wiped out for good
|
404
404
|
context 'when a repo is provided' do
|
405
405
|
subject(:workflow_xml) { client.workflow_xml(repo: 'dor', druid: 'druid:123', workflow: workflow) }
|
406
406
|
|
@@ -488,7 +488,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
488
488
|
describe '#lifecycle' do
|
489
489
|
let(:stubs) do
|
490
490
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
491
|
-
stub.get('
|
491
|
+
stub.get('objects/druid:123/lifecycle') do |_env|
|
492
492
|
[200, {}, <<-EOXML]
|
493
493
|
<lifecycle objectId="druid:ct011cv6501">
|
494
494
|
<milestone date="2010-04-27T11:34:17-0700">registered</milestone>
|
@@ -498,7 +498,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
498
498
|
EOXML
|
499
499
|
end
|
500
500
|
|
501
|
-
stub.get('
|
501
|
+
stub.get('objects/druid:abc/lifecycle') do |_env|
|
502
502
|
[200, {}, <<-EOXML]
|
503
503
|
<lifecycle />
|
504
504
|
EOXML
|
@@ -507,18 +507,18 @@ RSpec.describe Dor::Workflow::Client do
|
|
507
507
|
end
|
508
508
|
|
509
509
|
it 'returns a Time object reprenting when the milestone was reached' do
|
510
|
-
expect(client.lifecycle(
|
510
|
+
expect(client.lifecycle(druid: 'druid:123', milestone_name: 'released').beginning_of_day).to eq(Time.parse('2010-06-15T16:08:58-0700').beginning_of_day)
|
511
511
|
end
|
512
512
|
|
513
513
|
it "returns nil if the milestone hasn't been reached yet" do
|
514
|
-
expect(client.lifecycle(
|
514
|
+
expect(client.lifecycle(druid: 'druid:abc', milestone_name: 'inprocess')).to be_nil
|
515
515
|
end
|
516
516
|
end
|
517
517
|
|
518
518
|
describe '#active_lifecycle' do
|
519
519
|
let(:stubs) do
|
520
520
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
521
|
-
stub.get("
|
521
|
+
stub.get("objects/#{@druid}/lifecycle") do |_env|
|
522
522
|
[200, {}, <<-EOXML]
|
523
523
|
<lifecycle objectId="#{@druid}">
|
524
524
|
<milestone date="2010-04-27T11:34:17-0700">registered</milestone>
|
@@ -528,7 +528,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
528
528
|
EOXML
|
529
529
|
end
|
530
530
|
|
531
|
-
stub.get("
|
531
|
+
stub.get("objects/#{@druid}/lifecycle") do |_env|
|
532
532
|
[200, {}, <<-EOXML]
|
533
533
|
<lifecycle />
|
534
534
|
EOXML
|
@@ -537,17 +537,16 @@ RSpec.describe Dor::Workflow::Client do
|
|
537
537
|
end
|
538
538
|
|
539
539
|
it 'parses out the active lifecycle' do
|
540
|
-
expect(client.active_lifecycle(
|
540
|
+
expect(client.active_lifecycle(druid: @druid, milestone_name: 'released').beginning_of_day).to eq(Time.parse('2010-06-15T16:08:58-0700').beginning_of_day)
|
541
541
|
end
|
542
542
|
|
543
543
|
it 'handles missing lifecycle' do
|
544
|
-
expect(client.active_lifecycle(
|
544
|
+
expect(client.active_lifecycle(druid: @druid, milestone_name: 'NOT_FOUND')).to be_nil
|
545
545
|
end
|
546
546
|
end
|
547
547
|
|
548
548
|
context '#objects_for_workstep' do
|
549
549
|
before(:all) do
|
550
|
-
@repository = 'dor'
|
551
550
|
@workflow = 'googleScannedBookWF'
|
552
551
|
@completed = 'google-download'
|
553
552
|
@waiting = 'process-content'
|
@@ -555,7 +554,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
555
554
|
|
556
555
|
let(:stubs) do
|
557
556
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
558
|
-
stub.get("workflow_queue?waiting=#{@
|
557
|
+
stub.get("workflow_queue?waiting=#{@workflow}:#{@waiting}&completed=#{@workflow}:#{@completed}&lane-id=default") do |_env|
|
559
558
|
[200, {}, '<objects count="1"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>']
|
560
559
|
end
|
561
560
|
end
|
@@ -563,7 +562,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
563
562
|
|
564
563
|
describe 'a query with one step completed and one waiting' do
|
565
564
|
it 'creates the URI string with only the one completed step' do
|
566
|
-
expect(client.objects_for_workstep(@completed, @waiting, 'default',
|
565
|
+
expect(client.objects_for_workstep(@completed, @waiting, 'default', default_workflow: @workflow)).to eq(['druid:ab123de4567', 'druid:ab123de9012'])
|
567
566
|
end
|
568
567
|
end
|
569
568
|
|
@@ -571,21 +570,21 @@ RSpec.describe Dor::Workflow::Client do
|
|
571
570
|
it 'creates the URI string with the two completed steps correctly' do
|
572
571
|
second_completed = 'google-convert'
|
573
572
|
xml = %(<objects count="1"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>)
|
574
|
-
allow(mock_http_connection).to receive(:get).with("workflow_queue?waiting=#{@
|
575
|
-
expect(client.objects_for_workstep([@completed, second_completed], @waiting, 'default',
|
573
|
+
allow(mock_http_connection).to receive(:get).with("workflow_queue?waiting=#{@workflow}:#{@waiting}&completed=#{@workflow}:#{@completed}&completed=#{@workflow}:#{second_completed}&lane-id=default").and_return(double(Faraday::Response, body: xml))
|
574
|
+
expect(client.objects_for_workstep([@completed, second_completed], @waiting, 'default', default_workflow: @workflow)).to eq(['druid:ab123de4567', 'druid:ab123de9012'])
|
576
575
|
end
|
577
576
|
end
|
578
577
|
|
579
578
|
context 'a query using qualified workflow names for completed and waiting' do
|
580
579
|
before :each do
|
581
|
-
@qualified_waiting = "#{@
|
582
|
-
@qualified_completed = "#{@
|
580
|
+
@qualified_waiting = "#{@workflow}:#{@waiting}"
|
581
|
+
@qualified_completed = "#{@workflow}:#{@completed}"
|
583
582
|
end
|
584
583
|
|
585
584
|
RSpec.shared_examples 'lane-aware' do
|
586
585
|
it 'creates the URI string with the two completed steps across repositories correctly' do
|
587
|
-
qualified_completed2 = '
|
588
|
-
qualified_completed3 = '
|
586
|
+
qualified_completed2 = 'sdrIngestWF:complete-deposit'
|
587
|
+
qualified_completed3 = 'sdrIngestWF:ingest-transfer'
|
589
588
|
xml = %(<objects count="2"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>)
|
590
589
|
allow(mock_http_connection).to receive(:get).with("workflow_queue?waiting=#{@qualified_waiting}&completed=#{@qualified_completed}&completed=#{qualified_completed2}&completed=#{qualified_completed3}&lane-id=#{laneid}").and_return(double(Faraday::Response, body: xml))
|
591
590
|
args = [[@qualified_completed, qualified_completed2, qualified_completed3], @qualified_waiting]
|
@@ -627,7 +626,6 @@ RSpec.describe Dor::Workflow::Client do
|
|
627
626
|
|
628
627
|
context 'get empty workflow queue' do
|
629
628
|
before(:all) do
|
630
|
-
@repository = 'dor'
|
631
629
|
@workflow = 'googleScannedBookWF'
|
632
630
|
@completed = 'google-download'
|
633
631
|
@waiting = 'process-content'
|
@@ -635,27 +633,26 @@ RSpec.describe Dor::Workflow::Client do
|
|
635
633
|
|
636
634
|
let(:stubs) do
|
637
635
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
638
|
-
stub.get("workflow_queue?waiting=#{@
|
636
|
+
stub.get("workflow_queue?waiting=#{@workflow}:#{@waiting}&completed=#{@workflow}:#{@completed}&lane-id=default") do |_env|
|
639
637
|
[200, {}, '<objects count="0"/>']
|
640
638
|
end
|
641
639
|
end
|
642
640
|
end
|
643
641
|
|
644
642
|
it 'returns an empty list if it encounters an empty workflow queue' do
|
645
|
-
expect(client.objects_for_workstep(@completed, @waiting, 'default',
|
643
|
+
expect(client.objects_for_workstep(@completed, @waiting, 'default', default_workflow: @workflow)).to eq([])
|
646
644
|
end
|
647
645
|
end
|
648
646
|
|
649
647
|
context 'get errored workflow steps' do
|
650
648
|
before(:all) do
|
651
|
-
@repository = 'dor'
|
652
649
|
@workflow = 'accessionWF'
|
653
650
|
@step = 'publish'
|
654
651
|
end
|
655
652
|
|
656
653
|
let(:stubs) do
|
657
654
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
658
|
-
stub.get("/workflow_queue?error=#{@step}&
|
655
|
+
stub.get("/workflow_queue?error=#{@step}&workflow=#{@workflow}") do |_env|
|
659
656
|
[200, {}, <<-EOXML]
|
660
657
|
<objects count="1">
|
661
658
|
<object id="druid:ab123cd4567" errorMessage="This is an error message"/>
|
@@ -667,27 +664,26 @@ RSpec.describe Dor::Workflow::Client do
|
|
667
664
|
|
668
665
|
describe 'errored_objects_for_workstep' do
|
669
666
|
it 'returns error messages for errored objects' do
|
670
|
-
expect(client.errored_objects_for_workstep(@workflow, @step
|
667
|
+
expect(client.errored_objects_for_workstep(@workflow, @step)).to eq('druid:ab123cd4567' => 'This is an error message')
|
671
668
|
end
|
672
669
|
end
|
673
670
|
|
674
671
|
describe 'count_errored_for_workstep' do
|
675
672
|
it 'counts how many steps are errored out' do
|
676
|
-
expect(client.count_errored_for_workstep(@workflow, @step
|
673
|
+
expect(client.count_errored_for_workstep(@workflow, @step)).to eq(1)
|
677
674
|
end
|
678
675
|
end
|
679
676
|
end
|
680
677
|
|
681
678
|
describe '#count_queued_for_workstep' do
|
682
679
|
before(:all) do
|
683
|
-
@repository = 'dor'
|
684
680
|
@workflow = 'accessionWF'
|
685
681
|
@step = 'publish'
|
686
682
|
end
|
687
683
|
|
688
684
|
let(:stubs) do
|
689
685
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
690
|
-
stub.get("/workflow_queue?queued=#{@step}&
|
686
|
+
stub.get("/workflow_queue?queued=#{@step}&workflow=#{@workflow}") do |_env|
|
691
687
|
[200, {}, <<-EOXML]
|
692
688
|
<objects count="1">
|
693
689
|
<object id="druid:ab123cd4567"/>
|
@@ -698,7 +694,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
698
694
|
end
|
699
695
|
|
700
696
|
it 'counts how many steps are errored out' do
|
701
|
-
expect(client.count_queued_for_workstep(@workflow, @step
|
697
|
+
expect(client.count_queued_for_workstep(@workflow, @step)).to eq(1)
|
702
698
|
end
|
703
699
|
end
|
704
700
|
|
@@ -707,12 +703,11 @@ RSpec.describe Dor::Workflow::Client do
|
|
707
703
|
@workflow = 'sdrIngestWF'
|
708
704
|
@step = 'start-ingest'
|
709
705
|
@type = 'waiting'
|
710
|
-
@repository = 'sdr'
|
711
706
|
end
|
712
707
|
|
713
708
|
let(:stubs) do
|
714
709
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
715
|
-
stub.get("/workflow_queue?
|
710
|
+
stub.get("/workflow_queue?workflow=#{@workflow}&#{@type}=#{@step}") do |_env|
|
716
711
|
[200, {}, <<-EOXML]
|
717
712
|
<objects count="1">
|
718
713
|
<object id="druid:oo000ra0001" url="null/fedora/objects/druid:oo000ra0001"/>
|
@@ -723,12 +718,12 @@ RSpec.describe Dor::Workflow::Client do
|
|
723
718
|
end
|
724
719
|
|
725
720
|
it 'counts how many objects are at the type of step' do
|
726
|
-
expect(client.count_objects_in_step(@workflow, @step, @type
|
721
|
+
expect(client.count_objects_in_step(@workflow, @step, @type)).to eq(1)
|
727
722
|
end
|
728
723
|
end
|
729
724
|
|
730
725
|
describe '#delete_workflow' do
|
731
|
-
let(:url) { "
|
726
|
+
let(:url) { "/objects/#{@druid}/workflows/accessionWF" }
|
732
727
|
|
733
728
|
let(:stubs) do
|
734
729
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
@@ -738,14 +733,18 @@ RSpec.describe Dor::Workflow::Client do
|
|
738
733
|
|
739
734
|
it 'sends a delete request to the workflow service' do
|
740
735
|
expect(mock_http_connection).to receive(:delete).with(url).and_call_original
|
741
|
-
client.delete_workflow(
|
736
|
+
client.delete_workflow(nil, @druid, 'accessionWF')
|
742
737
|
end
|
743
738
|
end
|
744
739
|
|
745
740
|
describe '.stale_queued_workflows' do
|
741
|
+
before do
|
742
|
+
allow(Deprecation).to receive(:warn)
|
743
|
+
end
|
744
|
+
|
746
745
|
let(:stubs) do
|
747
746
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
748
|
-
stub.get('workflow_queue/all_queued?
|
747
|
+
stub.get('workflow_queue/all_queued?hours-ago=24&limit=100') do |_env|
|
749
748
|
[200, {}, <<-XML]
|
750
749
|
<workflows>
|
751
750
|
<workflow laneId="lane1" note="annotation" lifecycle="in-process" errorText="stacktrace" errorMessage="NullPointerException" elapsed="1.173" repository="dor" attempts="0" datetime="2008-11-15T13:30:00-0800" status="waiting" process="content-metadata" name="accessionWF" druid="dr:123"/>
|
@@ -758,6 +757,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
758
757
|
|
759
758
|
it 'returns an Array of Hashes containing each workflow step' do
|
760
759
|
ah = client.stale_queued_workflows 'dor', hours_ago: 24, limit: 100
|
760
|
+
expect(Deprecation).to have_received(:warn).once
|
761
761
|
expected = [
|
762
762
|
{ workflow: 'accessionWF', step: 'content-metadata', druid: 'dr:123', lane_id: 'lane1' },
|
763
763
|
{ workflow: 'assemblyWF', step: 'jp2-create', druid: 'dr:456', lane_id: 'lane2' }
|
@@ -767,9 +767,13 @@ RSpec.describe Dor::Workflow::Client do
|
|
767
767
|
end
|
768
768
|
|
769
769
|
describe '.count_stale_queued_workflows' do
|
770
|
+
before do
|
771
|
+
allow(Deprecation).to receive(:warn)
|
772
|
+
end
|
773
|
+
|
770
774
|
let(:stubs) do
|
771
775
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
772
|
-
stub.get('workflow_queue/all_queued?
|
776
|
+
stub.get('workflow_queue/all_queued?hours-ago=48&count-only=true') do |_env|
|
773
777
|
[200, {}, '<objects count="10"/>']
|
774
778
|
end
|
775
779
|
end
|
@@ -777,10 +781,15 @@ RSpec.describe Dor::Workflow::Client do
|
|
777
781
|
|
778
782
|
it 'returns the number of queued workflow steps' do
|
779
783
|
expect(client.count_stale_queued_workflows('dor', hours_ago: 48)).to eq(10)
|
784
|
+
expect(Deprecation).to have_received(:warn).once
|
780
785
|
end
|
781
786
|
end
|
782
787
|
|
783
788
|
describe '.lane_ids' do
|
789
|
+
before do
|
790
|
+
allow(Deprecation).to receive(:warn)
|
791
|
+
end
|
792
|
+
|
784
793
|
let(:stubs) do
|
785
794
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
786
795
|
stub.get('workflow_queue/lane_ids?lane_ids?step=dor:accessionWF:shelve') do |_env|
|
@@ -796,6 +805,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
796
805
|
|
797
806
|
it 'returns the lane ids for a given workflow step' do
|
798
807
|
expect(client.lane_ids('dor', 'accessionWF', 'shelve')).to eq(%w[lane1 lane2])
|
808
|
+
expect(Deprecation).to have_received(:warn).once
|
799
809
|
end
|
800
810
|
end
|
801
811
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-workflow-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willy Mene
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -198,6 +198,7 @@ executables: []
|
|
198
198
|
extensions: []
|
199
199
|
extra_rdoc_files: []
|
200
200
|
files:
|
201
|
+
- ".github/pull_request_template.md"
|
201
202
|
- ".gitignore"
|
202
203
|
- ".rspec"
|
203
204
|
- ".rubocop.yml"
|
@@ -255,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
256
|
- !ruby/object:Gem::Version
|
256
257
|
version: '0'
|
257
258
|
requirements: []
|
258
|
-
rubygems_version: 3.
|
259
|
+
rubygems_version: 3.1.2
|
259
260
|
signing_key:
|
260
261
|
specification_version: 4
|
261
262
|
summary: Provides convenience methods to work with the DOR Workflow Service
|