|
1 | 1 | (ns practitest-firecracker.practitest |
2 | 2 | (:require |
3 | 3 | [clojure.string :as string] |
| 4 | + [clojure.pprint :as pprint] |
4 | 5 | [clojure.tools.logging :as log] |
5 | 6 | [practitest-firecracker.utils :refer [print-run-time test-need-update? pformat]] |
6 | 7 | [practitest-firecracker.api :as api] |
|
126 | 127 | (when display-run-time (print-run-time "Time - after update tests: %d:%d:%d" start-time))) |
127 | 128 | [new-all-tests testset-id-to-name ts-id-test-name-num-instances])) |
128 | 129 |
|
| 130 | +(defn split-n-filter-instance-params [test pt-instance-params] |
| 131 | + (into [] |
| 132 | + (filter not-empty |
| 133 | + (string/split |
| 134 | + (eval-query |
| 135 | + (second test) |
| 136 | + (read-query pt-instance-params)) |
| 137 | + #"\|")))) |
| 138 | + |
129 | 139 | (defn create-instances [[all-tests testset-id-to-name ts-id-test-name-num-instances] client {:keys [project-id display-action-logs display-run-time pt-instance-params] :as options} start-time] |
| 140 | + (when display-action-logs (log/infof "pt-instance-params: %s" pt-instance-params)) |
130 | 141 | (let [all-test-ids (map (fn [test] (:id (last test))) all-tests) |
131 | 142 | testname-test (into {} (map (fn [test] {(first test) test}) all-tests)) |
132 | 143 | testid-params (when (not-empty pt-instance-params) |
133 | 144 | (into {} |
134 | 145 | (map |
135 | 146 | (fn [test] |
136 | | - (let [split-params (string/split |
137 | | - (eval-query |
138 | | - (second test) |
139 | | - (read-query pt-instance-params)) |
140 | | - #"\|")] |
| 147 | + (let [split-params (split-n-filter-instance-params test pt-instance-params)] |
141 | 148 | {(Integer/parseInt (:id (last test))) |
142 | | - (when (= (mod (count split-params) 2) 0) |
| 149 | + (when (even? (count split-params)) |
143 | 150 | (apply array-map |
144 | | - (string/split |
145 | | - (eval-query |
146 | | - (second test) |
147 | | - (read-query pt-instance-params)) |
148 | | - #"\|")))})) |
| 151 | + (split-n-filter-instance-params test pt-instance-params)))})) |
149 | 152 | all-tests))) |
| 153 | + log (when display-action-logs (log/infof "testid-params: %s" testid-params)) |
150 | 154 | testset-ids (map (fn [testset] (first (first testset))) testset-id-to-name) |
151 | 155 | ts-ids (string/join "," testset-ids) |
152 | 156 | instances (mapcat (fn [test-ids-bucket] |
|
161 | 165 | (let |
162 | 166 | [{:keys [name bdd-parameters parameters]} (:attributes instance) |
163 | 167 | [_ xml-test test] (get testname-test name) |
164 | | - split-params (string/split |
165 | | - (eval-query xml-test (read-query pt-instance-params)) #"\|") |
| 168 | + split-params (split-n-filter-instance-params test pt-instance-params) |
166 | 169 | xml-params (into {} (map (fn [[key value]] {(keyword key) value}) |
167 | | - (when (= (mod (count split-params) 2) 0) |
| 170 | + (when (even? (count split-params)) |
168 | 171 | (apply array-map split-params)))) |
169 | 172 | test-type (:test-type (:attributes test)) |
170 | 173 | params (if (= test-type "BDDTest") bdd-parameters parameters)] |
171 | 174 | (= xml-params params))) |
172 | 175 | instances) |
173 | 176 | instances) |
| 177 | + log (when display-action-logs (do (log/infof "filter-instances: ") (pprint/pprint filter-instances))) |
174 | 178 |
|
175 | 179 | ts-id-instance-num (into {} (map (fn [testset-id-name] |
176 | 180 | {(first (first testset-id-name)) |
|
0 commit comments