Skip to content

Commit 7209cde

Browse files
authored
Merge pull request #10 from PractiTest/multi-testset-preperation
prepare the code for multiple testset runs
2 parents 529118b + 86605e7 commit 7209cde

9 files changed

Lines changed: 340 additions & 261 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ java -jar practitest-firecracker-standalone.jar \
6161
--config-path=CONFIG_FILE \
6262
create-and-populate-testset
6363
```
64+
* In the future config files --testset-name will be defined inside of the config file so there will be no need to define it in the command line
6465
### use Firecracker without config file
6566

6667
You can use all the above commands without the config file. You will need to explicitly define
@@ -92,6 +93,26 @@ You can set various custom fields for tests when they are created (especially us
9293

9394
Replace the field ids with the actual IDs, you can see all your custom fields by calling this API call: [get-all-custom-fields-in-your-project](https://www.practitest.com/api-v2/#get-all-custom-fields-in-your-project)
9495

96+
### Additional options
97+
If you want to use firecracker custom uris you will need to add this --api-uri parameter like this
98+
for stage:
99+
--api-uri=https://stage.practitest.com/
100+
for EU:
101+
--api-uri=https://eu1-prod-api.practitest.app
102+
for local:
103+
--api-uri=http://localhost:PORT_NUM
104+
105+
To display action logs like create/update etc. add --display-action-logs=true (it will make the run slower so only add it for manual runs)
106+
107+
In case you have very big xml test results and it take very long time for firecracker to complete add --max-api-rate=NUM (the default is 30)
108+
!!!important!!! make sure that you add the same limit to of api rate limit to your account.
109+
110+
In case you want the name of the test to take its value from other attribute of testcase(s) add this parameter --pt-test-name=?ATTRIBUTE for example --pt-test-name=?full-class-name you can see the values that acceptable in firecracker UI (default is ?pt-test-name)
111+
112+
Same goes for --pt-test-step-name that will define the name of the steps.
113+
114+
For more information contact our support.
115+
95116
## License
96117

97118
Copyright © 2017 PractiTest.

config.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

deps.edn

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{:paths ["src" "test"]
2-
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
2+
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
33
org.clojure/tools.cli {:mvn/version "1.0.194"}
44
org.clojure/core.async {:mvn/version "1.2.603"}
5-
cheshire {:mvn/version "5.10.0"}
6-
clj-http {:mvn/version "3.10.1"}
7-
throttler {:mvn/version "1.0.0"}
8-
org.apache.maven.surefire/surefire-report-parser {:mvn/version "2.22.2"}
5+
cheshire/cheshire {:mvn/version "5.10.0"}
6+
clj-http/clj-http {:mvn/version "3.12.0"}
7+
throttler/throttler {:mvn/version "1.0.0"}
98
org.clojure/tools.logging {:mvn/version "1.1.0"}
109
ch.qos.logback/logback-classic {:mvn/version "1.2.3"}
11-
github-PractiTest/test-xml-parser {:git/url "git@github.com:PractiTest/test-xml-parser.git" :deps/manifest :deps :sha "342e448009ffb29ed152ea80f02ac803781f3b09"}
10+
clj-time/clj-time {:mvn/version "0.15.2"}
11+
github-PractiTest/firecracker-report-parser {:git/url "git@github.com:PractiTest/firecracker-report-parser.git" :deps/manifest :deps :sha "9fed1ab43b42f1b6d426925eaf159e620e793c56"}
1212
}
1313
:aliases
1414
{:dev {:extra-paths ["dev"]}
1515
:package {:extra-paths ["resources" "target/cljs/"]}
16-
:nrepl {:extra-deps {nrepl {:mvn/version "0.6.0"}}}
17-
:uberdeps {:extra-deps {uberdeps {:mvn/version "0.1.8"}}
16+
:nrepl {:extra-deps {nrepl/nrepl {:mvn/version "0.6.0"}}}
17+
:uberdeps {:extra-deps {uberdeps/uberdeps {:mvn/version "0.1.8"}}
1818
:main-opts ["-m" "uberdeps.uberjar"]}
1919
:depstar {:extra-deps
2020
{seancorfield/depstar {:mvn/version "1.0.94"}}}

src/practitest_firecracker/cli.clj

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,22 @@
4747
"JSON containing the fields that should be added when creating PractiTest TestSet"
4848
:default {}
4949
:parse-fn parse-additional-fields]
50-
[nil "--test-case-as-pt-test" :default true]
51-
[nil "--test-case-as-pt-test-step" :default false]
50+
;; [nil "--test-case-as-pt-test" :default true]
51+
[nil "--test-case-as-pt-test-step" :default true]
5252
#_[nil "--pt-test-name DSL"
5353
:parse-fn read-query
5454
:default (read-query "(concat (join (capitalize (drop 2 (tokenize-package ?package-name)))) \": \" (join (capitalize (drop-last (tokenize-class-name ?test-suite-name)))))")]
5555
[nil "--pt-test-name DSL"
5656
:parse-fn read-query
57-
:default (read-query "?test-suite-name")]
57+
:default (read-query "?pt-test-name")]
5858
#_[nil "--pt-test-step-name DSL"
5959
:parse-fn read-query
6060
:default (read-query "(join (capitalize (tokenize-class-name ?test-case-name)))")]
6161
[nil "--pt-test-step-name DSL"
6262
:parse-fn read-query
6363
:default (read-query "?test-case-name")]
64+
[nil "--display-run-time" :default false]
65+
[nil "--display-action-logs" :default false]
6466
["-h" "--help"]])
6567

6668
(defn usage [options-summary]
@@ -115,19 +117,19 @@
115117
:else
116118
{:action "display-options" :options options})
117119

118-
(= "create-testset" (first arguments))
119-
(cond
120-
(nil? (:project-id options))
121-
{:exit-message (missing-option-msg "create-testset" "project-id")}
120+
;; (= "create-testset" (first arguments))
121+
;; (cond
122+
;; (nil? (:project-id options))
123+
;; {:exit-message (missing-option-msg "create-testset" "project-id")}
122124

123-
(nil? (:author-id options))
124-
{:exit-message (missing-option-msg "create-testset" "author-id")}
125+
;; (nil? (:author-id options))
126+
;; {:exit-message (missing-option-msg "create-testset" "author-id")}
125127

126-
(nil? (:testset-name options))
127-
{:exit-message (missing-option-msg "create-testset" "testset-name")}
128+
;; (nil? (:testset-name options))
129+
;; {:exit-message (missing-option-msg "create-testset" "testset-name")}
128130

129-
:else
130-
{:action "create-testset" :options options})
131+
;; :else
132+
;; {:action "create-testset" :options options})
131133

132134
(= "populate-testset" (first arguments))
133135
(cond
@@ -148,7 +150,7 @@
148150
(nil? (:author-id options))
149151
{:exit-message (missing-option-msg "create-and-populate-testset" "author-id")}
150152

151-
(nil? (:testset-name options))
153+
(and (nil? (:testset-name options)) (not (:multitestset options)))
152154
{:exit-message (missing-option-msg "create-and-populate-testset" "testset-name")}
153155

154156
:else

src/practitest_firecracker/core.clj

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
[practitest-firecracker.cli :refer [parse-args]]
44
[practitest-firecracker.practitest :refer [make-client
55
create-sf-testset
6-
populate-sf-results-old
6+
make-runs
77
populate-sf-results
8-
create-or-update-sf-testset]]
9-
[practitest-firecracker.surefire :refer [parse-reports-dir]]
10-
[test-xml-parser.core :refer [send-directory remove-bom return-files delete-recursively!]]
8+
create-testsets
9+
group-tests
10+
create-or-update-tests
11+
create-instances
12+
create-runs]]
13+
[firecracker-report-parser.core :refer [send-directory parse-files]]
1114
[clojure.pprint :as pprint]
12-
[clojure.java.io :refer [file]])
15+
[clojure.java.io :refer [file]]
16+
[clj-time.core :as t])
1317
(:gen-class))
1418

1519
(defn exit [status msg]
@@ -24,62 +28,57 @@
2428
(println (str ~module " elapsed time: " (/ (double (- (. System (nanoTime)) start#)) 1000000.0) " msecs")))
2529
ret#))
2630

27-
(defn clean-tmp-folder [directory]
28-
(doseq [path directory]
29-
(delete-recursively! path)))
30-
3131
(defn -main [& args]
3232
(let [{:keys [action options exit-message ok?]} (parse-args args)]
3333
(if exit-message
3434
(exit (if ok? 0 1) exit-message)
35-
(do
36-
(doseq [report-path (:reports-path options)]
37-
(remove-bom report-path (:temp-folder options)))
38-
(let [client (make-client (select-keys options [:email :api-token :api-uri :max-api-rate]))
39-
directory (map #(.getAbsolutePath (file (:temp-folder options) %)) (:reports-path options))
40-
reports (parse-reports-dir directory)
41-
additional-reports (send-directory directory reports)]
35+
(let [client (make-client (select-keys options [:email :api-token :api-uri :max-api-rate]))
36+
directory (:reports-path options)
37+
dirs (for [dir directory] (clojure.java.io/file dir))
38+
parsed-dirs (for [dir (file-seq (first dirs))] (parse-files dir))
39+
additional-reports (send-directory parsed-dirs (:test-case-as-pt-test-step options) (:multitestset options) (:testset-name options) false)
40+
start-time (t/now)]
4241
(case action
4342
"display-config"
4443
(do
4544
(pprint/pprint {"=============== additional-reports: ===============" additional-reports})
46-
(pprint/pprint {"=============== FC original reports val: ===============" reports})
47-
(clean-tmp-folder directory))
45+
(pprint/pprint {"=============== directory: ===============" directory}))
4846

4947
"display-options"
5048
(do
5149
(pprint/pprint {"=============== options: ===============" options})
52-
(pprint/pprint {"=============== args: ===============" args})
53-
(clean-tmp-folder directory))
50+
(pprint/pprint {"=============== args: ===============" args}))
5451

55-
"create-testset"
56-
(let [testset (create-or-update-sf-testset client options additional-reports)]
57-
(clean-tmp-folder directory)
58-
(exit 0 (format "TestSet ID: %s" (:id testset))))
52+
;; "create-testset"
53+
;; (do
54+
;; (doall
55+
;; (pmap
56+
;; (fn [report]
57+
;; (let [testset (create-or-update-sf-testset client options report)]
58+
;; (pprint/pprint (format "Populated TestSet ID: %s" (:id testset)))))
59+
;; additional-reports))
60+
;; (exit 0 "Done"))
5961

6062
"populate-testset"
6163
(do
62-
(populate-sf-results client
63-
options
64-
additional-reports)
65-
(clean-tmp-folder directory)
64+
(doall
65+
(pmap
66+
(fn [report]
67+
(populate-sf-results client
68+
options
69+
report))
70+
additional-reports))
6671
(exit 0 "Done"))
6772

6873
"create-and-populate-testset"
69-
(let [testset (timef
70-
"create-or-update-testset"
71-
(create-or-update-sf-testset client options additional-reports))]
74+
(do
7275
(timef
73-
"populate-results"
74-
(populate-sf-results client
75-
(assoc options
76-
:skip-validation? true
77-
:testset-id (:id testset))
78-
additional-reports))
79-
(clean-tmp-folder directory)
80-
(exit 0 (format "Populated TestSet ID: %s" (:id testset))))
81-
"test"
82-
(let [testset (create-or-update-sf-testset client options additional-reports additional-reports)]
83-
(clean-tmp-folder directory)
84-
(exit 0 (format "TestSet ID: %s" (:id testset)))))
85-
)))))
76+
"create-and-populate-testset"
77+
(-> (create-testsets client options additional-reports)
78+
(group-tests client options)
79+
(create-or-update-tests client options start-time)
80+
(create-instances client options start-time)
81+
(make-runs client options start-time)
82+
(create-runs client options start-time)
83+
))
84+
(exit 0 (format "Done"))))))))

0 commit comments

Comments
 (0)