|
24 | 24 | [sets :as sets]
|
25 | 25 | [counter :as counter]]))
|
26 | 26 |
|
| 27 | +(def minimal-concurrency |
| 28 | + 10) |
| 29 | + |
27 | 30 | (def workloads
|
28 | 31 | "A map of workload names to functions that can take opts and construct
|
29 | 32 | workloads.
|
|
49 | 52 | ;:pages pages/workload
|
50 | 53 | :register register/workload})
|
51 | 54 |
|
| 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 | + |
52 | 63 | (def workload-options
|
53 | 64 | "For each workload, a map of workload options to all the values that option
|
54 | 65 | supports."
|
|
73 | 84 | [nil "--mvcc"
|
74 | 85 | "Enable MVCC engine"
|
75 | 86 | :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)]] |
80 | 87 | ["-e" "--engine NAME"
|
81 | 88 | "What Tarantool data engine should we use?"
|
82 | 89 | :default "memtx"]])
|
83 | 90 |
|
| 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 | + |
84 | 108 | (def crash-pattern
|
85 | 109 | "An egrep pattern we use to find crashes in the Tarantool logs."
|
86 | 110 | (str/join "|"
|
|
139 | 163 | :engine (:engine opts)
|
140 | 164 | :mvcc (:mvcc opts)
|
141 | 165 | :pure-generators true
|
| 166 | + :concurrency (if (and (< (:concurrency opts) minimal-concurrency) |
| 167 | + (= (:workload opts) :register)) |
| 168 | + 10 |
| 169 | + (:concurrency opts)) |
142 | 170 | :generator gen
|
143 | 171 | :checker (checker/compose {:perf (checker/perf)
|
144 | 172 | :clock-skew (checker/clock-plot)
|
|
148 | 176 | :exceptions (checker/unhandled-exceptions)
|
149 | 177 | :workload (:checker workload)})})))
|
150 | 178 |
|
| 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 | + |
151 | 198 | (defn -main
|
152 | 199 | "Handles command line arguments."
|
153 | 200 | [& args]
|
154 | 201 | (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)}) |
156 | 205 | (cli/serve-cmd))
|
157 | 206 | args))
|
0 commit comments