repair stale loadtest friendship setup

This commit is contained in:
richjohnrambo
2026-09-27 13:40:58 +08:00
parent ecfe13ff0e
commit d0e1e98f5f
2 changed files with 18 additions and 5 deletions
+14 -3
View File
@@ -127,12 +127,23 @@ func prepareFriendships(ctx context.Context, cfg *Config, manifest *Manifest, ap
err := parallelAccounts(ctx, pairs, cfg.PrepareWorkers, func(a AccountRecord) error {
return retryPrepareOperation(ctx, fmt.Sprintf("friend-pair-%04d", a.Index), func() error {
b := *accounts[accountKey("b", a.Index)]
if a.P2PTopic != "" && b.P2PTopic == a.P2PTopic {
return nil
}
if a.UserID == "" || b.UserID == "" {
return fmt.Errorf("pair %d has missing user ID", a.Index)
}
conversation, conversationErr := api.ensureP2P(ctx, a, b)
if conversationErr == nil && conversation.Relationship == "friend" && conversation.Topic != "" {
mu.Lock()
accounts[accountKey("a", a.Index)].P2PTopic = conversation.Topic
accounts[accountKey("b", a.Index)].P2PTopic = conversation.Topic
mu.Unlock()
return nil
}
if conversationErr != nil {
var apiErr *apiError
if !errors.As(conversationErr, &apiErr) || apiErr.Status != http.StatusForbidden {
return fmt.Errorf("check friend pair %d: %w", a.Index, conversationErr)
}
}
request, requestErr := api.createFriendRequest(ctx, a, b)
if requestErr == nil && request.Status == "pending" {
if _, requestErr = api.acceptFriendRequest(ctx, b, request.RequestID); requestErr != nil {