Skip to content

Commit faceeb9

Browse files
committed
Apply necessary updates to bench tests
1 parent 35b445e commit faceeb9

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

src/test/lrsql/bench_test.clj

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@
3131
{"Content-Type" "application/json"
3232
"X-Experience-API-Version" "1.0.3"})
3333

34-
(def basic-auth
34+
(def api-keys
3535
["username" "password"])
3636

3737
(deftest bench-test
3838
(let [sys (support/test-system)
3939
sys' (component/start sys)
4040
url-prefix (-> sys' :webserver :config :url-prefix)
4141
stmt-endpoint (format "http://localhost:8080%s/statements" url-prefix)
42-
csv-endpoint (format "http://localhost:8080/admin/csv?property-paths=%s"
43-
(u/url-encode [["id"] ["verb" "id"]]))
4442
statements (support/bench-statements* num-statements)]
4543
(testing "Inserting large amounts of data"
4644
(let [start (jt/instant)]
@@ -50,7 +48,7 @@
5048
(let [{:keys [status]}
5149
(try (curl/post stmt-endpoint
5250
{:headers headers
53-
:basic-auth basic-auth
51+
:basic-auth api-keys
5452
:body (u/write-json-str (vec batch))})
5553
(catch Exception e e))]
5654
(recur (rest batches)
@@ -69,7 +67,7 @@
6967
(let [{:keys [status body]}
7068
(try (curl/get query-url
7169
{:headers headers
72-
:basic-auth basic-auth})
70+
:basic-auth api-keys})
7371
(catch Exception e e))
7472
{:keys [statements more]}
7573
(some-> body (u/parse-json :keyword-keys? true))
@@ -90,7 +88,30 @@
9088
(is (not fail?))
9189
(is (= num-statements stmt-count*))))))))
9290
(testing "Downloading large amounts of data"
93-
(let [start
91+
(let [;; Log in and get the one-time JWT
92+
json-web-token
93+
(-> (curl/post "http://localhost:8080/admin/account/login"
94+
{:headers headers
95+
:body (u/write-json-str
96+
{"username" "username"
97+
"password" "password"})})
98+
:body
99+
(u/parse-json :keyword-keys? true)
100+
:json-web-token)
101+
headers*
102+
{"Authorization" (str "Bearer " json-web-token)}
103+
json-web-token*
104+
(-> (curl/get "http://localhost:8080/admin/csv/auth"
105+
{:headers headers*})
106+
:body
107+
(u/parse-json :keyword-keys? true)
108+
:json-web-token)
109+
csv-endpoint
110+
(format "http://localhost:8080/admin/csv?token=%s&property-paths=%s"
111+
json-web-token*
112+
(u/url-encode [["id"] ["verb" "id"]]))
113+
;; Download CSV
114+
start
94115
(jt/instant)
95116
{:keys [status] input-stream :body}
96117
(curl/get csv-endpoint {:as :stream})]
@@ -102,5 +123,4 @@
102123
num-statements
103124
t-diff)
104125
(is (= 200 status))
105-
(is (= (inc num-statements) res-count))))))
106-
(component/stop sys')))
126+
(is (= (inc num-statements) res-count))))))))

0 commit comments

Comments
 (0)