Skip to content

Commit dc51be6

Browse files
committed
Add options to execute all tests at once
Added option `test-all` that will run all workloads with all available nemeses. Workload `register` requires to specify `--concurrency` option with value more or equal to 10, otherwise test will fail, to avoid this added minimal concurrency value for a register workload set by defaul. Option `--only-workloads-expected-to-pass` allows to execute only those tests that expected to pass and ignore others. Needed for #34
1 parent dfb4d45 commit dc51be6

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

src/tarantool/runner.clj

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
[sets :as sets]
2525
[counter :as counter]]))
2626

27+
(def minimal-concurrency
28+
10)
29+
2730
(def workloads
2831
"A map of workload names to functions that can take opts and construct
2932
workloads.
@@ -49,6 +52,14 @@
4952
;:pages pages/workload
5053
:register register/workload})
5154

55+
(def standard-workloads
56+
"The workload names we run for test-all by default."
57+
(remove #{:none} (keys workloads)))
58+
59+
(def workloads-expected-to-pass
60+
"A collection of workload names which we expect should actually pass."
61+
(remove #{:counter-dec} standard-workloads))
62+
5263
(def workload-options
5364
"For each workload, a map of workload options to all the values that option
5465
supports."
@@ -73,14 +84,27 @@
7384
[nil "--mvcc"
7485
"Enable MVCC engine"
7586
:default false]
76-
["-w" "--workload NAME" "Test workload to run"
77-
:parse-fn keyword
78-
:missing (str "--workload " (cli/one-of workloads))
79-
:validate [workloads (cli/one-of workloads)]]
8087
["-e" "--engine NAME"
8188
"What Tarantool data engine should we use?"
8289
:default "memtx"]])
8390

91+
(def test-all-opts
92+
"Command line options for testing everything."
93+
[[nil "--only-workloads-expected-to-pass" "Don't run tests which we know fail."
94+
:default false]
95+
["-w" "--workload NAME"
96+
"Test workload to run. If omitted, runs all workloads."
97+
:parse-fn keyword
98+
:default nil
99+
:validate [workloads (cli/one-of workloads)]]])
100+
101+
(def single-test-opts
102+
"Command line options for single tests."
103+
[["-w" "--workload NAME" "Test workload to run"
104+
:parse-fn keyword
105+
:missing (str "--workload " (cli/one-of workloads))
106+
:validate [workloads (cli/one-of workloads)]]])
107+
84108
(def crash-pattern
85109
"An egrep pattern we use to find crashes in the Tarantool logs."
86110
(str/join "|"
@@ -139,6 +163,10 @@
139163
:engine (:engine opts)
140164
:mvcc (:mvcc opts)
141165
:pure-generators true
166+
:concurrency (if (and (< (:concurrency opts) minimal-concurrency)
167+
(= (:workload opts) :register))
168+
10
169+
(:concurrency opts))
142170
:generator gen
143171
:checker (checker/compose {:perf (checker/perf)
144172
:clock-skew (checker/clock-plot)
@@ -148,10 +176,31 @@
148176
:exceptions (checker/unhandled-exceptions)
149177
:workload (:checker workload)})})))
150178

179+
(defn all-test-options
180+
"Takes base cli options, a collection of workloads, and a test count,
181+
and constructs a sequence of test options."
182+
[cli workloads]
183+
(for [w workloads, i (range (:test-count cli))]
184+
(assoc cli
185+
:workload w)))
186+
187+
(defn all-tests
188+
"Takes parsed CLI options and constructs a sequence of test options, by
189+
combining all workloads."
190+
[test-fn opts]
191+
(let [workloads (if-let [w (:workload opts)] [w]
192+
(if (:only-workloads-expected-to-pass opts)
193+
workloads-expected-to-pass
194+
standard-workloads))]
195+
(->> (all-test-options opts workloads)
196+
(map test-fn))))
197+
151198
(defn -main
152199
"Handles command line arguments."
153200
[& args]
154201
(cli/run! (merge (cli/single-test-cmd {:test-fn tarantool-test
155-
:opt-spec cli-opts})
202+
:opt-spec (concat cli-opts single-test-opts)})
203+
(cli/test-all-cmd {:tests-fn (partial all-tests tarantool-test)
204+
:opt-spec (concat cli-opts test-all-opts)})
156205
(cli/serve-cmd))
157206
args))

0 commit comments

Comments
 (0)