specwrk 0.4.0 → 0.4.2
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/cli.rb +6 -2
- data/lib/specwrk/queue.rb +6 -2
- data/lib/specwrk/version.rb +1 -1
- data/lib/specwrk/web/endpoints.rb +9 -2
- data/lib/specwrk/worker.rb +2 -1
- 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: 9d76f2f9716e7c7e613bc0b341f89e42caf9375dfe0d48083afb908146d1374b
|
4
|
+
data.tar.gz: 36136d67829a41b39f4e9de4fff45ea1a614111f9556a523eefde1b35cceba51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7fd2a78d6019864949e6847f09474ad357b04614dd1a2cc3f563ec95f915e7958bfdf211c9d60213d61bea517e59e200ad3e7898963fe0cdd49df114941a786
|
7
|
+
data.tar.gz: 6b1836bb1a50ba0d853689ec5b7f169c83883a39c134caf93b4a70637a81c3b4f6e4f8112285dca4b30065d0c6a816807e13e65ff748dc7b16d5c5d03064e52c
|
data/lib/specwrk/cli.rb
CHANGED
@@ -37,11 +37,13 @@ module Specwrk
|
|
37
37
|
base.unique_option :id, type: :string, default: "specwrk-worker", desc: "The identifier for this worker. Default specwrk-worker(-COUNT_INDEX)."
|
38
38
|
base.unique_option :count, type: :integer, default: 1, aliases: ["-c"], desc: "The number of worker processes you want to start. Default 1."
|
39
39
|
base.unique_option :output, type: :string, default: ENV.fetch("SPECWRK_OUT", ".specwrk/"), aliases: ["-o"], desc: "Directory where worker output is stored. Overrides SPECWRK_OUT. Default '.specwrk/'."
|
40
|
+
base.unique_option :seed_waits, type: :integer, default: ENV.fetch("SPECWRK_SEED_WAITS", "10"), aliases: ["-w"], desc: "Number of times the worker will wait for examples to be seeded to the server. 1sec between attempts. Overrides SPECWRK_SEED_WAITS. Default '10'."
|
40
41
|
end
|
41
42
|
|
42
|
-
on_setup do |id:, count:, output:, **|
|
43
|
+
on_setup do |id:, count:, output:, seed_waits:, **|
|
43
44
|
ENV["SPECWRK_ID"] = id
|
44
45
|
ENV["SPECWRK_COUNT"] = count.to_s
|
46
|
+
ENV["SPECWRK_SEED_WAITS"] = seed_waits.to_s
|
45
47
|
ENV["SPECWRK_OUT"] = Pathname.new(output).expand_path(Dir.pwd).to_s
|
46
48
|
FileUtils.mkdir_p(ENV["SPECWRK_OUT"])
|
47
49
|
end
|
@@ -75,10 +77,11 @@ module Specwrk
|
|
75
77
|
base.unique_option :output, type: :string, default: ENV.fetch("SPECWRK_OUT", ".specwrk/"), aliases: ["-o"], desc: "Directory where worker output is stored. Overrides SPECWRK_OUT. Default '.specwrk/'."
|
76
78
|
base.unique_option :group_by, values: %w[file timings], default: ENV.fetch("SPECWERK_SRV_GROUP_BY", "timings"), desc: "How examples will be grouped for workers; fallback to file if no timings are found. Overrides SPECWERK_SRV_GROUP_BY. Default timings."
|
77
79
|
base.unique_option :single_run, type: :boolean, default: false, desc: "Act on shutdown requests from clients. Default: false."
|
80
|
+
base.unique_option :single_seed_per_run, type: :boolean, default: false, desc: "Only allow one seed per run. Useful for CI where many nodes may seed at the same time. Default: false."
|
78
81
|
base.unique_option :verbose, type: :boolean, default: false, desc: "Run in verbose mode. Default false."
|
79
82
|
end
|
80
83
|
|
81
|
-
on_setup do |port:, bind:, output:, key:, single_run:, group_by:, verbose:, **|
|
84
|
+
on_setup do |port:, bind:, output:, key:, single_run:, single_seed_per_run:, group_by:, verbose:, **|
|
82
85
|
ENV["SPECWRK_OUT"] = Pathname.new(output).expand_path(Dir.pwd).to_s
|
83
86
|
FileUtils.mkdir_p(ENV["SPECWRK_OUT"])
|
84
87
|
|
@@ -88,6 +91,7 @@ module Specwrk
|
|
88
91
|
ENV["SPECWRK_SRV_BIND"] = bind
|
89
92
|
ENV["SPECWRK_SRV_KEY"] = key
|
90
93
|
ENV["SPECWRK_SRV_SINGLE_RUN"] = "1" if single_run
|
94
|
+
ENV["SPECWRK_SRV_SINGLE_SEED_PER_RUN"] = "1" if single_seed_per_run
|
91
95
|
ENV["SPECWRK_SRV_GROUP_BY"] = group_by
|
92
96
|
end
|
93
97
|
end
|
data/lib/specwrk/queue.rb
CHANGED
@@ -19,7 +19,11 @@ module Specwrk
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def synchronize(&blk)
|
22
|
-
@mutex.
|
22
|
+
if @mutex.owned?
|
23
|
+
yield(@hash)
|
24
|
+
else
|
25
|
+
@mutex.synchronize { yield(@hash) }
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
def method_missing(name, *args, &block)
|
@@ -70,7 +74,7 @@ module Specwrk
|
|
70
74
|
end
|
71
75
|
|
72
76
|
def merge_with_previous_run_times!(h2)
|
73
|
-
|
77
|
+
synchronize do
|
74
78
|
h2.each { |_id, example| merge_example(example) }
|
75
79
|
|
76
80
|
# Sort by exepcted run time, slowest to fastest
|
data/lib/specwrk/version.rb
CHANGED
@@ -58,8 +58,15 @@ module Specwrk
|
|
58
58
|
|
59
59
|
class Seed < Base
|
60
60
|
def response
|
61
|
-
|
62
|
-
|
61
|
+
pending_queue.synchronize do |pending_queue_hash|
|
62
|
+
unless ENV["SPECWRK_SRV_SINGLE_SEED_PER_RUN"] && pending_queue_hash.length.positive?
|
63
|
+
examples = payload.map { |hash| [hash[:id], hash] }.to_h
|
64
|
+
|
65
|
+
pending_queue.merge_with_previous_run_times!(examples)
|
66
|
+
|
67
|
+
ok
|
68
|
+
end
|
69
|
+
end
|
63
70
|
|
64
71
|
ok
|
65
72
|
end
|
data/lib/specwrk/worker.rb
CHANGED
@@ -17,6 +17,7 @@ module Specwrk
|
|
17
17
|
@running = true
|
18
18
|
@client = Client.new
|
19
19
|
@executor = Executor.new
|
20
|
+
@seed_waits = ENV.fetch("SPECWRK_SEED_WAITS", "10").to_i
|
20
21
|
@heartbeat_thread ||= Thread.new do
|
21
22
|
thump
|
22
23
|
end
|
@@ -40,7 +41,7 @@ module Specwrk
|
|
40
41
|
@seed_wait_count ||= 0
|
41
42
|
@seed_wait_count += 1
|
42
43
|
|
43
|
-
if @seed_wait_count <=
|
44
|
+
if @seed_wait_count <= @seed_waits
|
44
45
|
warn "No examples seeded yet, waiting..."
|
45
46
|
sleep 1
|
46
47
|
else
|