Lemmy: Write test script for HTTP API

Created on 22 Jan 2020  路  11Comments  路  Source: LemmyNet/lemmy

For performance testing, we can use ab to write a basic load test for each API call, and see which ones are slow.

For correctness testing, we could write a script that calls each method and verifies the returned data.

enhancement good first issue

Most helpful comment

I need to step away from this, sorry. Lots of complication here in holding on to the jwt. I may have more time to investigate next week

All 11 comments

Is this covered by apache_bench_report.sh?

@MitchLillie Mostly by api_benchmark.sh, but its far from complete (doesnt include any POST/PUT/DEL requests).

Gotcha, thanks. I will take a stab at this today

Is there anything I'm missing? Simply trying to curl as below, and getting 400 responses:

curl -i -H "Content-Type: application/json" -d '{
  "op": "Login",
  "data": {
    "username_or_email": "mitch",
    "password": "mitch"
  }
}' http://localhost:8536/api/v1/user/login

I think you need to add -X POST.

Same result, 400. I think -X POST is redundant when you pass -d

I just tested this and its working fine on my machine:

curl -i -H \
"Content-Type: application/json" \
-X POST \
-d '{
  "username_or_email": "why",
  "password": "test"
}' \
http://localhost:8536/api/v1/user/login

edit: I see the issue. You don't include the "op" or "data" field when using the http calls. These are just required for the websocket since there's only one websocket endpoint. The post example shows that.

Awesome, thanks. I knew it was something silly

I need to step away from this, sorry. Lots of complication here in holding on to the jwt. I may have more time to investigate next week

@MitchLillie no need to rush :)

The federation tests have this now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chopin2712 picture chopin2712  路  3Comments

chovy picture chovy  路  5Comments

dessalines picture dessalines  路  6Comments

NicolasCARPi picture NicolasCARPi  路  5Comments

shirshak55 picture shirshak55  路  5Comments