specwrk 0.12.0 → 0.13.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/lib/specwrk/client.rb +7 -8
- data/lib/specwrk/store/file_adapter.rb +1 -1
- data/lib/specwrk/store.rb +1 -1
- data/lib/specwrk/version.rb +1 -1
- data/lib/specwrk/web/app.rb +0 -2
- data/lib/specwrk/web/endpoints.rb +24 -25
- data/lib/specwrk/worker/completion_formatter.rb +1 -6
- data/lib/specwrk/worker/executor.rb +0 -7
- data/lib/specwrk/worker.rb +2 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7b5abc9ec00673b175314cce03016affa2e47b7ca9f445235ea93fdadb7c79a
|
4
|
+
data.tar.gz: 7f30c131e7bbce5c787c527af0e1b58acb16345cc85c5cf22671be1281e8106e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75d4427606c9491a4344d95713f2062df258e7aea660e520ee126dc2233b8b2bd2b24ca9f56c15d696b0b35b9c0a6211ac05c2b4e63af950df5723e0c625816e
|
7
|
+
data.tar.gz: '0885f9962b4cc30f84d72d8e0a99dbb3541588f6aefc292657d95f52576c80251c2cfc4d04af2f35f74df74ca09ebb5385493d55f67ff905cd7cb1522c99f1b4'
|
data/lib/specwrk/client.rb
CHANGED
@@ -44,12 +44,13 @@ module Specwrk
|
|
44
44
|
raise Errno::ECONNREFUSED unless connected
|
45
45
|
end
|
46
46
|
|
47
|
-
attr_reader :last_request_at, :retry_count
|
47
|
+
attr_reader :last_request_at, :retry_count, :worker_status
|
48
48
|
|
49
49
|
def initialize
|
50
50
|
@mutex = Mutex.new
|
51
51
|
@http = self.class.build_http
|
52
52
|
@http.start
|
53
|
+
@worker_status = 1
|
53
54
|
end
|
54
55
|
|
55
56
|
def close
|
@@ -99,12 +100,6 @@ module Specwrk
|
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
102
|
-
def complete_examples(examples)
|
103
|
-
response = post "/complete", body: examples.to_json
|
104
|
-
|
105
|
-
(response.code == "200") ? true : raise(UnhandledResponseError.new("#{response.code}: #{response.body}"))
|
106
|
-
end
|
107
|
-
|
108
103
|
def complete_and_fetch_examples(examples)
|
109
104
|
response = post "/complete_and_pop", body: examples.to_json
|
110
105
|
|
@@ -171,7 +166,11 @@ module Specwrk
|
|
171
166
|
def make_request(request)
|
172
167
|
@mutex.synchronize do
|
173
168
|
@last_request_at = Time.now
|
174
|
-
@http.request(request).tap
|
169
|
+
@http.request(request).tap do |response|
|
170
|
+
@retry_count = 0
|
171
|
+
|
172
|
+
@worker_status = response["x-specwrk-status"].to_i if response["x-specwrk-status"]
|
173
|
+
end
|
175
174
|
end
|
176
175
|
end
|
177
176
|
|
data/lib/specwrk/store.rb
CHANGED
data/lib/specwrk/version.rb
CHANGED
data/lib/specwrk/web/app.rb
CHANGED
@@ -33,6 +33,8 @@ module Specwrk
|
|
33
33
|
|
34
34
|
after_lock
|
35
35
|
|
36
|
+
final_response[1]["x-specwrk-status"] = worker_status.to_s
|
37
|
+
|
36
38
|
final_response
|
37
39
|
end
|
38
40
|
|
@@ -102,6 +104,12 @@ module Specwrk
|
|
102
104
|
@worker ||= Store.new(ENV.fetch("SPECWRK_SRV_STORE_URI", "memory:///"), File.join(run_id, "workers", request.get_header("HTTP_X_SPECWRK_ID").to_s))
|
103
105
|
end
|
104
106
|
|
107
|
+
def worker_status
|
108
|
+
return 0 if worker[:failed].nil? && completed.any? # worker starts after run has completed
|
109
|
+
|
110
|
+
worker[:failed] || 1
|
111
|
+
end
|
112
|
+
|
105
113
|
def run_id
|
106
114
|
request.get_header("HTTP_X_SPECWRK_RUN")
|
107
115
|
end
|
@@ -190,29 +198,6 @@ module Specwrk
|
|
190
198
|
end
|
191
199
|
end
|
192
200
|
|
193
|
-
class Complete < Base
|
194
|
-
def with_response
|
195
|
-
warn "[DEPRECATED] This endpoint will be retired in favor of CompleteAndPop. Upgrade your clients."
|
196
|
-
completed.merge!(completed_examples)
|
197
|
-
processing.delete(*completed_examples.keys)
|
198
|
-
|
199
|
-
ok
|
200
|
-
end
|
201
|
-
|
202
|
-
private
|
203
|
-
|
204
|
-
def completed_examples
|
205
|
-
@completed_data ||= payload.map { |example| [example[:id], example] if processing[example[:id]] }.compact.to_h
|
206
|
-
end
|
207
|
-
|
208
|
-
# We don't care about exact values here, just approximate run times are fine
|
209
|
-
# So if we overwrite run times from another process it is nbd
|
210
|
-
def after_lock
|
211
|
-
run_time_data = payload.map { |example| [example[:id], example[:run_time]] }.to_h
|
212
|
-
run_times.merge! run_time_data
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
201
|
class Popable < Base
|
217
202
|
private
|
218
203
|
|
@@ -261,6 +246,8 @@ module Specwrk
|
|
261
246
|
end
|
262
247
|
|
263
248
|
class CompleteAndPop < Popable
|
249
|
+
EXAMPLE_STATUSES = %w[passed failed pending]
|
250
|
+
|
264
251
|
def with_response
|
265
252
|
completed.merge!(completed_examples)
|
266
253
|
processing.delete(*completed_examples.keys)
|
@@ -274,10 +261,22 @@ module Specwrk
|
|
274
261
|
@completed_data ||= payload.map { |example| [example[:id], example] if processing[example[:id]] }.compact.to_h
|
275
262
|
end
|
276
263
|
|
277
|
-
|
278
|
-
|
264
|
+
def completed_examples_status_counts
|
265
|
+
@completed_examples_status_counts ||= completed_examples.values.map { |example| example[:status] }.tally
|
266
|
+
end
|
267
|
+
|
279
268
|
def after_lock
|
269
|
+
# We don't care about exact values here, just approximate run times are fine
|
270
|
+
# So if we overwrite run times from another process it is nbd
|
280
271
|
run_times.merge! run_time_data
|
272
|
+
|
273
|
+
# workers are single proces, single-threaded, so safe to do this work without the lock
|
274
|
+
existing_status_counts = worker.multi_read(*EXAMPLE_STATUSES)
|
275
|
+
new_status_counts = EXAMPLE_STATUSES.map do |status|
|
276
|
+
[status, existing_status_counts.fetch(status, 0) + completed_examples_status_counts.fetch(status, 0)]
|
277
|
+
end.to_h
|
278
|
+
|
279
|
+
worker.merge!(new_status_counts)
|
281
280
|
end
|
282
281
|
|
283
282
|
def run_time_data
|
@@ -5,19 +5,14 @@ module Specwrk
|
|
5
5
|
class CompletionFormatter
|
6
6
|
RSpec::Core::Formatters.register self, :stop
|
7
7
|
|
8
|
-
attr_reader :examples
|
8
|
+
attr_reader :examples
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@examples = []
|
12
|
-
@failure = false
|
13
12
|
end
|
14
13
|
|
15
14
|
def stop(group_notification)
|
16
15
|
group_notification.notifications.map do |notification|
|
17
|
-
unless failure
|
18
|
-
@failure = notification.example.execution_result.status == :failed
|
19
|
-
end
|
20
|
-
|
21
16
|
examples << {
|
22
17
|
id: notification.example.id,
|
23
18
|
full_description: notification.example.full_description,
|
@@ -11,12 +11,6 @@ require "specwrk/worker/null_formatter"
|
|
11
11
|
module Specwrk
|
12
12
|
class Worker
|
13
13
|
class Executor
|
14
|
-
attr_reader :example_processed
|
15
|
-
|
16
|
-
def failure
|
17
|
-
completion_formatter.failure
|
18
|
-
end
|
19
|
-
|
20
14
|
def examples
|
21
15
|
completion_formatter.examples
|
22
16
|
end
|
@@ -29,7 +23,6 @@ module Specwrk
|
|
29
23
|
reset!
|
30
24
|
|
31
25
|
example_ids = examples.map { |example| example[:id] }
|
32
|
-
@example_processed ||= true unless example_ids.size.zero? # only ever toggle from nil => true
|
33
26
|
|
34
27
|
options = RSpec::Core::ConfigurationOptions.new rspec_options + example_ids
|
35
28
|
RSpec::Core::Runner.new(options).run($stderr, $stdout)
|
data/lib/specwrk/worker.rb
CHANGED
@@ -110,11 +110,10 @@ module Specwrk
|
|
110
110
|
attr_reader :running, :client, :executor
|
111
111
|
|
112
112
|
def status
|
113
|
-
return
|
114
|
-
return 1 if executor.failure
|
113
|
+
return 0 if @all_examples_completed && client.worker_status.zero?
|
115
114
|
return 1 if Specwrk.force_quit
|
116
115
|
|
117
|
-
|
116
|
+
client.worker_status
|
118
117
|
end
|
119
118
|
|
120
119
|
def warn(msg)
|