Skip to content

Instantly share code, notes, and snippets.

@pbaille
Created October 7, 2021 14:35
Show Gist options
  • Select an option

  • Save pbaille/86dbb23f41bc598fb6a61b36acbcea79 to your computer and use it in GitHub Desktop.

Select an option

Save pbaille/86dbb23f41bc598fb6a61b36acbcea79 to your computer and use it in GitHub Desktop.
stress test terminus
(require 'clj-http.client)
(def DURATION 10)
(def tics (atom []))
(def start (System/currentTimeMillis))
(defn rand-query []
{"@type" "woql:AddTriple",
"woql:subject" {"@type" "woql:Node", "woql:node" (str "doc:" (gensym))},
"woql:predicate" {"@type" "woql:Node", "woql:node" (str "scm:" (gensym))},
"woql:object" {"@type" "woql:Node", "woql:node" (str "doc:" (gensym))}})
(defn tic []
(swap! tics conj
(clj-http.client/post "https://localhost:6363/api/woql/admin/pouet"
{:basic-auth "admin:root"
:async false
:insecure? true,
:validate-hostnames false,
:content-type :json
:form-params
{:commit_info {:author "pierrebaille@gmail.com", :message "si je veux"},
:query (rand-query)}}))
(when (< (- (System/currentTimeMillis) start)
(* DURATION 1000))
(tic)))
(tic)
(println "requests per second: "
(float (/ (count @tics) DURATION))
"\nsample response:\n"
(first @tics))
;; requests per second: 2.8
;; sample response:
#_{:cached nil, :request-time 488, :repeatable? false, :protocol-version {:name HTTP, :major 1, :minor 1}, :streaming? true, :http-client #object[org.apache.http.impl.client.InternalHttpClient 0x73009bfb org.apache.http.impl.client.InternalHttpClient@73009bfb], :chunked? false, :reason-phrase OK, :headers {Date Thu, 07 Oct 2021 14:28:17 GMT, Connection close, Content-Type application/json; charset=UTF-8, Content-Length 173}, :orig-content-encoding nil, :status 200, :length 173,
:body {
"@type":"api:WoqlResponse",
"api:status":"api:success",
"api:variable_names": [],
"bindings": [ {} ],
"deletes":0,
"inserts":1,
"transaction_retry_count":0},
:trace-redirects []}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment