Skip to content

Commit e748f59

Browse files
stelcodesaustb
authored andcommitted
(PDB-5230) Add collected-queries-still-working regression test
Ensure we don't break important queries we've collected from services that depend on pdb. For now we just ensure the http status of the response is 200.
1 parent 35d53ef commit e748f59

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(ns puppetlabs.puppetdb.query.regression-test
2+
(:require
3+
[clj-yaml.core :as yaml]
4+
[clojure.java.io :as io]
5+
[clojure.string :as str]
6+
[clojure.test :refer [deftest is testing]]
7+
[puppetlabs.puppetdb.cheshire :as json]
8+
[puppetlabs.puppetdb.testutils.db :refer [with-test-db]]
9+
[puppetlabs.puppetdb.testutils.http
10+
:refer [query-response with-http-app]]))
11+
12+
(deftest collected-queries-still-working
13+
(with-test-db
14+
(with-http-app
15+
(doseq [file (->> "locust/load-test"
16+
io/as-file
17+
file-seq
18+
(filter #(str/ends-with? % ".yaml")))
19+
request-data (yaml/parse-string (slurp file))
20+
:let [{:keys [alias method path query]} request-data
21+
keyword-method (case method
22+
"GET" :get
23+
"POST" :post)
24+
relative-path (str/replace-first path #"^/pdb/query" "")]]
25+
(testing (str "testing " alias " in " file)
26+
(let [{:keys [status body]}
27+
(query-response keyword-method relative-path query)]
28+
;; If body of response is not valid JSON, the test should fail
29+
(is (-> body slurp json/parse-string))
30+
;; If status of response is not 200, the test should fail
31+
(is (= 200 status))))))))
32+

0 commit comments

Comments
 (0)