Add script to test http api, fix two api calls

This commit is contained in:
Felix 2020-01-28 16:50:40 +01:00
parent 8cfd5f9266
commit 7b4bf68486
5 changed files with 42 additions and 6 deletions

View file

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/bash
set -e
declare -a arr=( declare -a arr=(
"https://mastodon.social/" "https://mastodon.social/"

34
server/query_testing/api_benchmark.sh vendored Executable file
View file

@ -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

View file

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/bash
set -e
# Do the views first # Do the views first

View file

@ -3,7 +3,7 @@ use diesel::PgConnection;
use std::str::FromStr; use std::str::FromStr;
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct ListCategories; pub struct ListCategories {}
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct ListCategoriesResponse { pub struct ListCategoriesResponse {
@ -72,7 +72,7 @@ pub struct EditSite {
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct GetSite; pub struct GetSite {}
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct SiteResponse { pub struct SiteResponse {

View file

@ -116,7 +116,7 @@ export class WebSocketService {
public listCategories() { public listCategories() {
this.subject.next( this.subject.next(
this.wsSendWrapper(UserOperation.ListCategories, undefined) this.wsSendWrapper(UserOperation.ListCategories, {})
); );
} }
@ -255,7 +255,7 @@ export class WebSocketService {
} }
public getSite() { public getSite() {
this.subject.next(this.wsSendWrapper(UserOperation.GetSite, undefined)); this.subject.next(this.wsSendWrapper(UserOperation.GetSite, {}));
} }
public search(form: SearchForm) { public search(form: SearchForm) {