]> Untitled Git - lemmy.git/commitdiff
Add script to test http api, fix two api calls
authorFelix <me@nutomic.com>
Tue, 28 Jan 2020 15:50:40 +0000 (16:50 +0100)
committerFelix <me@nutomic.com>
Fri, 31 Jan 2020 13:17:37 +0000 (14:17 +0100)
server/query_testing/apache_bench_report.sh
server/query_testing/api_benchmark.sh [new file with mode: 0755]
server/query_testing/generate_explain_reports.sh
server/src/api/site.rs
ui/src/services/WebSocketService.ts

index c22af73084c58b8dc8ef1951702668986a93d6c8..62b3e86368f584aa187357f84e14c5f15b0dd096 100755 (executable)
@@ -1,4 +1,5 @@
-#!/bin/sh
+#!/bin/bash
+set -e
 
 declare -a arr=(
 "https://mastodon.social/"
diff --git a/server/query_testing/api_benchmark.sh b/server/query_testing/api_benchmark.sh
new file mode 100755 (executable)
index 0000000..8f8c65f
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+set -e
+
+# By default, this script runs against `http://127.0.0.1:8536`, but you can pass a different Lemmy instance,
+# eg `./api_benchmark.sh "https://example.com"`.
+DOMAIN=${1:-"http://127.0.0.1:8536"}
+
+declare -a arr=(
+"/api/v1/site"
+"/api/v1/categories"
+"/api/v1/modlog"
+"/api/v1/search?q=test&type_=Posts&sort=Hot"
+"/api/v1/community"
+"/api/v1/community/list?sort=Hot"
+"/api/v1/post/list?sort=Hot&type_=All"
+)
+
+## now loop through the above array
+for path in "${arr[@]}"
+do
+  URL="$DOMAIN$path"
+  printf "\n\n\n"
+  echo "testing $URL"
+  curl --show-error --fail --silent "$URL" >/dev/null
+  ab -c 64 -t 10 "$URL" > out.abtest
+  grep "Server Hostname:" out.abtest
+  grep "Document Path:" out.abtest
+  grep "Requests per second" out.abtest
+  grep "(mean, across all concurrent requests)" out.abtest
+  grep "Transfer rate:" out.abtest
+  echo "---"
+done
+
+rm *.abtest
index 9ba910362667ef0a1c5e4c4f0ad4c0c4da5aec23..0dc06f6526a6ac6052ee76fffa696cb1260924c8 100755 (executable)
@@ -1,4 +1,5 @@
-#!/bin/sh
+#!/bin/bash
+set -e
 
 # Do the views first
 
index a5faf34dd820a02524777418228da69d9c6e1a89..dfbd5ff041ea66a83bf2fd8c3c1cd138b4cdf1bd 100644 (file)
@@ -3,7 +3,7 @@ use diesel::PgConnection;
 use std::str::FromStr;
 
 #[derive(Serialize, Deserialize)]
-pub struct ListCategories;
+pub struct ListCategories {}
 
 #[derive(Serialize, Deserialize)]
 pub struct ListCategoriesResponse {
@@ -72,7 +72,7 @@ pub struct EditSite {
 }
 
 #[derive(Serialize, Deserialize)]
-pub struct GetSite;
+pub struct GetSite {}
 
 #[derive(Serialize, Deserialize)]
 pub struct SiteResponse {
index e72a28716ffdc8d1d17876aa7f40dc1829e2acf0..b4042194966157e2ae4f509191ba671edf16c7f6 100644 (file)
@@ -116,7 +116,7 @@ export class WebSocketService {
 
   public listCategories() {
     this.subject.next(
-      this.wsSendWrapper(UserOperation.ListCategories, undefined)
+      this.wsSendWrapper(UserOperation.ListCategories, {})
     );
   }
 
@@ -255,7 +255,7 @@ export class WebSocketService {
   }
 
   public getSite() {
-    this.subject.next(this.wsSendWrapper(UserOperation.GetSite, undefined));
+    this.subject.next(this.wsSendWrapper(UserOperation.GetSite, {}));
   }
 
   public search(form: SearchForm) {