feat(loadtest): sync add real 500-session capacity harness
This commit is contained in:
parent
ac0566f779
commit
141f2f20c4
39 changed files with 4157 additions and 42 deletions
33
internal/loadharness/server_metrics_test.go
Normal file
33
internal/loadharness/server_metrics_test.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package loadharness
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestServerMetricsScrapeSelectsBoundedCapacitySignals(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
fmt.Fprintln(w, `telesrv_mtproto_raw_connections 500`)
|
||||
fmt.Fprintln(w, `telesrv_mtproto_sessions{state="active"} 499`)
|
||||
fmt.Fprintln(w, `telesrv_mtproto_sessions{state="provisional"} 1`)
|
||||
for i := 0; i < 256; i++ {
|
||||
fmt.Fprintf(w, "telesrv_mtproto_rpc_result_wire_bytes_total{method=%q} 1\n", fmt.Sprintf("method-%d", i))
|
||||
}
|
||||
fmt.Fprintln(w, `unrelated_high_cardinality{user_id="secret"} 1`)
|
||||
}))
|
||||
defer server.Close()
|
||||
client := newServerMetricsClient(server.URL)
|
||||
values, err := client.scrape(context.Background())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if values["telesrv_mtproto_raw_connections"] != 500 || values["telesrv_mtproto_sessions"] != 500 || values["telesrv_mtproto_rpc_result_wire_bytes_total"] != 256 {
|
||||
t.Fatalf("values = %#v", values)
|
||||
}
|
||||
if len(values) != 3 || client.successes() != 1 || client.failures() != 0 {
|
||||
t.Fatalf("bounded values/scrapes = %#v, %d/%d", values, client.successes(), client.failures())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue