mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-05 14:07:01 +00:00
02bd942b04
continue #75 close #16 - fix regression (from #34) _thanks to @crystal_ - create own gitea client package - more logging - add mock impl of CertDB Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: crystal <crystal@noreply.codeberg.org> Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/78 Reviewed-by: crapStone <crapstone@noreply.codeberg.org>
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/valyala/fasthttp"
|
|
|
|
"codeberg.org/codeberg/pages/server/cache"
|
|
"codeberg.org/codeberg/pages/server/gitea"
|
|
)
|
|
|
|
func TestHandlerPerformance(t *testing.T) {
|
|
giteaRoot := "https://codeberg.org"
|
|
giteaClient := gitea.NewClient(giteaRoot, "")
|
|
testHandler := Handler(
|
|
[]byte("codeberg.page"), []byte("raw.codeberg.org"),
|
|
giteaClient,
|
|
giteaRoot, "https://docs.codeberg.org/pages/raw-content/",
|
|
[][]byte{[]byte("/.well-known/acme-challenge/")},
|
|
[][]byte{[]byte("raw.codeberg.org"), []byte("fonts.codeberg.org"), []byte("design.codeberg.org")},
|
|
cache.NewKeyValueCache(),
|
|
cache.NewKeyValueCache(),
|
|
cache.NewKeyValueCache(),
|
|
cache.NewKeyValueCache(),
|
|
)
|
|
|
|
testCase := func(uri string, status int) {
|
|
ctx := &fasthttp.RequestCtx{
|
|
Request: *fasthttp.AcquireRequest(),
|
|
Response: *fasthttp.AcquireResponse(),
|
|
}
|
|
ctx.Request.SetRequestURI(uri)
|
|
fmt.Printf("Start: %v\n", time.Now())
|
|
start := time.Now()
|
|
testHandler(ctx)
|
|
end := time.Now()
|
|
fmt.Printf("Done: %v\n", time.Now())
|
|
if ctx.Response.StatusCode() != status {
|
|
t.Errorf("request failed with status code %d", ctx.Response.StatusCode())
|
|
} else {
|
|
t.Logf("request took %d milliseconds", end.Sub(start).Milliseconds())
|
|
}
|
|
}
|
|
|
|
testCase("https://mondstern.codeberg.page/", 424) // TODO: expect 200
|
|
testCase("https://mondstern.codeberg.page/", 424) // TODO: expect 200
|
|
testCase("https://example.momar.xyz/", 424) // TODO: expect 200
|
|
testCase("https://codeberg.page/", 424) // TODO: expect 200
|
|
}
|