|
31 | 31 | {"Content-Type" "application/json" |
32 | 32 | "X-Experience-API-Version" "1.0.3"}) |
33 | 33 |
|
34 | | -(def basic-auth |
| 34 | +(def api-keys |
35 | 35 | ["username" "password"]) |
36 | 36 |
|
37 | 37 | (deftest bench-test |
38 | 38 | (let [sys (support/test-system) |
39 | 39 | sys' (component/start sys) |
40 | 40 | url-prefix (-> sys' :webserver :config :url-prefix) |
41 | 41 | 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"]])) |
44 | 42 | statements (support/bench-statements* num-statements)] |
45 | 43 | (testing "Inserting large amounts of data" |
46 | 44 | (let [start (jt/instant)] |
|
50 | 48 | (let [{:keys [status]} |
51 | 49 | (try (curl/post stmt-endpoint |
52 | 50 | {:headers headers |
53 | | - :basic-auth basic-auth |
| 51 | + :basic-auth api-keys |
54 | 52 | :body (u/write-json-str (vec batch))}) |
55 | 53 | (catch Exception e e))] |
56 | 54 | (recur (rest batches) |
|
69 | 67 | (let [{:keys [status body]} |
70 | 68 | (try (curl/get query-url |
71 | 69 | {:headers headers |
72 | | - :basic-auth basic-auth}) |
| 70 | + :basic-auth api-keys}) |
73 | 71 | (catch Exception e e)) |
74 | 72 | {:keys [statements more]} |
75 | 73 | (some-> body (u/parse-json :keyword-keys? true)) |
|
90 | 88 | (is (not fail?)) |
91 | 89 | (is (= num-statements stmt-count*)))))))) |
92 | 90 | (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 |
94 | 115 | (jt/instant) |
95 | 116 | {:keys [status] input-stream :body} |
96 | 117 | (curl/get csv-endpoint {:as :stream})] |
|
102 | 123 | num-statements |
103 | 124 | t-diff) |
104 | 125 | (is (= 200 status)) |
105 | | - (is (= (inc num-statements) res-count)))))) |
106 | | - (component/stop sys'))) |
| 126 | + (is (= (inc num-statements) res-count)))))))) |
0 commit comments