mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-31 15:29:48 +02:00
Initial test environment implementation
This commit is contained in:
parent
dc427a4078
commit
f1d2799a9f
24 changed files with 2917 additions and 20 deletions
54
internal/benchmarks/config_bench_test.go
Normal file
54
internal/benchmarks/config_bench_test.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package benchmarks_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/testenv"
|
||||
"github.com/pomerium/pomerium/internal/testenv/snippets"
|
||||
"github.com/pomerium/pomerium/internal/testenv/upstreams"
|
||||
)
|
||||
|
||||
func BenchmarkStartupLatency(b *testing.B) {
|
||||
for _, n := range []int{1, 10, 100, 1000, 10000} {
|
||||
b.Run(fmt.Sprintf("routes=%d", n), func(b *testing.B) {
|
||||
for range b.N {
|
||||
env := testenv.New(b)
|
||||
up := upstreams.HTTP(nil)
|
||||
for i := range n {
|
||||
up.Route().
|
||||
From(env.SubdomainURL(fmt.Sprintf("from-%d", i))).
|
||||
PPL(`{"allow":{"and":[{"accept":"true"}]}}`)
|
||||
}
|
||||
env.AddUpstream(up)
|
||||
|
||||
env.Start()
|
||||
snippets.WaitStartupComplete(b, env, 60*time.Minute)
|
||||
|
||||
env.Stop()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAppendRoutes(b *testing.B) {
|
||||
for _, n := range []int{1, 10, 100, 1000, 10000} {
|
||||
b.Run(fmt.Sprintf("routes=%d", n), func(b *testing.B) {
|
||||
for range b.N {
|
||||
env := testenv.New(b)
|
||||
up := upstreams.HTTP(nil)
|
||||
env.AddUpstream(up)
|
||||
|
||||
env.Start()
|
||||
snippets.WaitStartupComplete(b, env)
|
||||
for i := range n {
|
||||
env.Add(up.Route().
|
||||
From(env.SubdomainURL(fmt.Sprintf("from-%d", i))).
|
||||
PPL(fmt.Sprintf(`{"allow":{"and":["email":{"is":"user-%d@example.com"}]}}`, i)))
|
||||
}
|
||||
env.Stop()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue