fix:修改压测的bug
This commit is contained in:
parent
d7dd809327
commit
0aa02cc3a4
@ -8,7 +8,11 @@ cloud.google.com/go/datastore v1.1.0 h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0m
|
||||
cloud.google.com/go/firestore v1.1.0 h1:9x7Bx0A9R5/M9jibeJeZWqjeVEIxYW9fZYqB9a70/bY=
|
||||
cloud.google.com/go/pubsub v1.3.1 h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU=
|
||||
cloud.google.com/go/storage v1.10.0 h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA=
|
||||
codeberg.org/go-fonts/dejavu v0.4.0/go.mod h1:abni088lmhQJvso2Lsb7azCKzwkfcnttl6tL1UTWKzg=
|
||||
codeberg.org/go-fonts/latin-modern v0.4.0/go.mod h1:BF68mZznJ9QHn+hic9ks2DaFl4sR5YhfM6xTYaP9vNw=
|
||||
codeberg.org/go-fonts/stix v0.3.0/go.mod h1:1OSJSnA/PoHqbW2tjkkqTmNPp5xTtJQN2GRXJjO/+WA=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9 h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=
|
||||
git.sr.ht/~sbinet/cmpimg v0.1.0/go.mod h1:FU12psLbF4TfNXkKH2ZZQ29crIqoiqTZmeQ7dkp/pxE=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0 h1:sBEjpZlNHzK1voKq9695PJSX2o5NEXl7/OL3coiIY0c=
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0/go.mod h1:P4WPRUkOhJC13W//jWpyfJNDAIpvRbAUIYLX/4jtlE0=
|
||||
@ -53,6 +57,8 @@ github.com/aws/smithy-go v1.8.0 h1:AEwwwXQZtUwP5Mz506FeXXrKBe0jA8gVM+1gEcSRooc=
|
||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
|
||||
github.com/bketelsen/crypt v0.0.4 h1:w/jqZtC9YD4DS/Vp9GhWfWcCpuAL58oTnLoI8vE9YHU=
|
||||
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8=
|
||||
github.com/casbin/casbin/v2 v2.1.2 h1:bTwon/ECRx9dwBy2ewRVr5OiqjeXSGiTUY74sDPQi/g=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
|
||||
@ -134,7 +140,6 @@ github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3a
|
||||
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
|
||||
github.com/gogo/googleapis v1.1.0 h1:kFkMAZBNAn4j7K0GiZr8cRYzejq68VbheufiV3YuyFI=
|
||||
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d h1:lBXNCxVENCipq4D1Is42JVOP4eQjlB8TQ6H69Yx5J9Q=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
|
||||
github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac h1:Q0Jsdxl5jbxouNs1TQYt0gxesYMU4VXRbsTlgDloZ50=
|
||||
github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82 h1:EvokxLQsaaQjcWVWSV38221VAK7qc2zhaO17bKys/18=
|
||||
@ -245,7 +250,6 @@ github.com/nats-io/nats-server/v2 v2.1.2 h1:i2Ly0B+1+rzNZHHWtD4ZwKi+OU5l+uQo1iDH
|
||||
github.com/nats-io/nats.go v1.9.1 h1:ik3HbLhZ0YABLto7iX80pZLPw/6dx3T+++MZJwLnMrQ=
|
||||
github.com/nats-io/nkeys v0.1.3 h1:6JrEfig+HzTH85yxzhSVbjHRJv9cn0p6n3IngIcM5/k=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/npillmayer/nestext v0.1.3 h1:2dkbzJ5xMcyJW5b8wwrX+nnRNvf/Nn1KwGhIauGyE2E=
|
||||
github.com/oklog/oklog v0.3.2 h1:wVfs8F+in6nTBMkA7CbRw+zZMIB7nNM825cM1wuzoTk=
|
||||
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
|
||||
@ -260,6 +264,7 @@ github.com/pact-foundation/pact-go v1.0.4 h1:OYkFijGHoZAYbOIb1LWXrwKQbMMRUv1oQ89
|
||||
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
|
||||
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
|
||||
github.com/performancecopilot/speed v3.0.0+incompatible h1:2WnRzIquHa5QxaJKShDkLM+sc0JPuwhXzK8OYOyt3Vg=
|
||||
github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
|
||||
github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc=
|
||||
github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
@ -278,6 +283,7 @@ github.com/rhnvrm/simples3 v0.6.1 h1:H0DJwybR6ryQE+Odi9eqkHuzjYAeJgtGcGtuBwOhsH8
|
||||
github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk=
|
||||
github.com/ryanuber/columnize v2.1.0+incompatible h1:j1Wcmh8OrK4Q7GXY+V7SVSY8nUWQxHW5TkBe7YUl+2s=
|
||||
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da h1:p3Vo3i64TCLY7gIfzeQaUJ+kppEO5WQG3cL8iE8tGHU=
|
||||
@ -331,6 +337,7 @@ golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0 h1:OE9mWmgKkjJyEmDAAtGMPjXu+YNeGvK9VTSHY6+Qihc=
|
||||
gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b h1:Qh4dB5D/WpoUUp3lSod7qgoyEHbDGPUWjIbnqdqqe1k=
|
||||
gonum.org/v1/tools v0.0.0-20200318103217-c168b003ce8c/go.mod h1:fy6Otjqbk477ELp8IXTpw1cObQtLbRCBVonY+bTTfcM=
|
||||
google.golang.org/api v0.44.0 h1:URs6qR1lAxDsqWITsQXI4ZkGiYJ5dHtRNiCpfs2OeKA=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
|
||||
|
||||
1
backend/report.json
Normal file
1
backend/report.json
Normal file
@ -0,0 +1 @@
|
||||
{"scenario":"S1","total_requests":30,"errors":0,"five_xx":0,"p50_us":88383,"p95_us":150911,"p99_us":187903,"max_us":187903}
|
||||
@ -63,6 +63,9 @@ func main() {
|
||||
}
|
||||
|
||||
func runLoadgen(target, scenarioIDs, stage, stepSchedule string, rps, vus int, duration, interPause time.Duration, monitorMode, prodSSH string) error {
|
||||
// 让 scenarios 用 --target 而不是写死的 prod IP
|
||||
scenarios.DefaultBaseURL = target
|
||||
|
||||
users, err := lib.LoadUsers("users.csv")
|
||||
if err != nil {
|
||||
return fmt.Errorf("load users.csv: %w (先跑 `seed` 生成 users.csv)", err)
|
||||
|
||||
@ -8,7 +8,9 @@ import (
|
||||
"github.com/topfans/backend/scripts/loadgen/loadgen/lib"
|
||||
)
|
||||
|
||||
const DefaultBaseURL = "http://101.132.250.62:8080"
|
||||
// DefaultBaseURL is overridden by main.go from --target flag before scenarios are constructed.
|
||||
// Kept as a const-style default for tests; treat as a package-level mutable in production.
|
||||
var DefaultBaseURL = "http://101.132.250.62:8080"
|
||||
|
||||
func doRequest(client *http.Client, req *http.Request, rec *lib.LatencyRecorder, errCount, totalCount, fiveXXCount *atomic.Int64, breaker *lib.CircuitBreaker) {
|
||||
start := time.Now()
|
||||
|
||||
@ -23,12 +23,19 @@ func Cleanup(db *sql.DB, starID int64, full bool) error {
|
||||
}
|
||||
if full {
|
||||
queries = append(queries,
|
||||
"DELETE FROM users WHERE id BETWEEN $2 AND $3",
|
||||
"DELETE FROM users WHERE id BETWEEN $1 AND $2",
|
||||
"DELETE FROM stars WHERE star_id = $1",
|
||||
)
|
||||
}
|
||||
for _, q := range queries {
|
||||
if _, err := db.Exec(q, starID, LoadtestUserMin, LoadtestUserMax); err != nil {
|
||||
var err error
|
||||
switch q {
|
||||
case "DELETE FROM users WHERE id BETWEEN $1 AND $2":
|
||||
_, err = db.Exec(q, LoadtestUserMin, LoadtestUserMax)
|
||||
default:
|
||||
_, err = db.Exec(q, starID)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("cleanup %q: %w", q[:30], err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
$2a$10$38rspoc377zFTH3h3AeLy.qD7JxaJbw7VGSJ/Wp.hyZ0isFGJO/0m
|
||||
$2b$10$CCAN3dyE7BxAwmmNPSSrmet0qRytgb297NJZigX4Vfsln.8W0Wznu
|
||||
@ -31,7 +31,6 @@ func main() {
|
||||
cleanup := flag.Bool("cleanup", false, "run cleanup (default: keep baseline)")
|
||||
cleanupFull := flag.Bool("full", false, "with -cleanup: also delete users/stars")
|
||||
cleanupStarID := flag.Int64("cleanup-star-id", LoadtestStarID, "star_id to clean (safety)")
|
||||
flag.Parse()
|
||||
|
||||
cfg := parseFlags()
|
||||
|
||||
@ -68,7 +67,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if err := runSeed(db, cfg); err != nil {
|
||||
if err := runSeed(db); err != nil {
|
||||
log.Fatalf("seed failed: %v", err)
|
||||
}
|
||||
if err := GenerateTokensForLoadtest(cfg); err != nil {
|
||||
@ -97,7 +96,7 @@ func openDB(cfg *Config) (*sql.DB, error) {
|
||||
return sql.Open("postgres", dsn)
|
||||
}
|
||||
|
||||
func runSeed(db *sql.DB, cfg *Config) error {
|
||||
func runSeed(db *sql.DB) error {
|
||||
if err := SeedStars(db); err != nil {
|
||||
return fmt.Errorf("seed stars: %w", err)
|
||||
}
|
||||
|
||||
1
backend/scripts/loadgen/seed/report.json
Normal file
1
backend/scripts/loadgen/seed/report.json
Normal file
@ -0,0 +1 @@
|
||||
{"scenario":"S1","total_requests":30,"errors":30,"five_xx":0,"p50_us":22063,"p95_us":28143,"p99_us":30991,"max_us":30991}
|
||||
@ -8,14 +8,15 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/topfans/backend/pkg/jwt"
|
||||
)
|
||||
|
||||
type TestUser struct {
|
||||
UserID int64
|
||||
Mobile string
|
||||
AssetIDs []int64
|
||||
ExhibitionIDs []int64
|
||||
AssetIDs pq.Int64Array
|
||||
ExhibitionIDs pq.Int64Array
|
||||
}
|
||||
|
||||
func GenerateTokensForLoadtest(cfg *Config) error {
|
||||
@ -29,8 +30,8 @@ func GenerateTokensForLoadtest(cfg *Config) error {
|
||||
|
||||
rows, err := db.Query(`
|
||||
SELECT u.id, u.mobile,
|
||||
COALESCE(array_agg(DISTINCT a.id) FILTER (WHERE a.id IS NOT NULL), '{}'),
|
||||
COALESCE(array_agg(DISTINCT e.id) FILTER (WHERE e.id IS NOT NULL), '{}')
|
||||
COALESCE(array_agg(DISTINCT a.id) FILTER (WHERE a.id IS NOT NULL), '{}'::int8[]),
|
||||
COALESCE(array_agg(DISTINCT e.id) FILTER (WHERE e.id IS NOT NULL), '{}'::int8[])
|
||||
FROM users u
|
||||
LEFT JOIN assets a ON a.owner_uid = u.id AND a.star_id = $1
|
||||
LEFT JOIN fan_profiles fp ON fp.user_id = u.id AND fp.star_id = $1
|
||||
@ -79,8 +80,8 @@ func GenerateTokensForLoadtest(cfg *Config) error {
|
||||
u.Mobile, "Test@123",
|
||||
strconv.FormatInt(u.UserID, 10),
|
||||
"999900", token,
|
||||
joinInt64(u.AssetIDs),
|
||||
joinInt64(u.ExhibitionIDs),
|
||||
joinInt64([]int64(u.AssetIDs)),
|
||||
joinInt64([]int64(u.ExhibitionIDs)),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
1001
backend/scripts/loadgen/seed/users.csv
Normal file
1001
backend/scripts/loadgen/seed/users.csv
Normal file
File diff suppressed because it is too large
Load Diff
1001
backend/users.csv
Normal file
1001
backend/users.csv
Normal file
File diff suppressed because it is too large
Load Diff
@ -1198,7 +1198,7 @@ const goBack = () => {
|
||||
} else {
|
||||
// 没有上一页,跳转到square页面
|
||||
uni.reLaunch({
|
||||
url: "/pages/profile/myWorks",
|
||||
url: "/pages/square/square",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user