mirror of
https://github.com/pgsty/minio.git
synced 2026-09-16 23:44:06 +03:00
7b4cacc392
Signed-off-by: Feng Ruohang <rh@vonng.com>
61 lines
2.2 KiB
Go
61 lines
2.2 KiB
Go
// Copyright (c) 2026 PGSTY
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/minio/madmin-go/v3"
|
|
)
|
|
|
|
// Measures steady-state index traversal, sorting and the capability request.
|
|
// The network peer acknowledges real batches but performs no disk I/O; this
|
|
// benchmark deliberately does not claim durable catch-up throughput.
|
|
func BenchmarkIAMRevisionConvergedHealing(b *testing.B) {
|
|
for _, n := range []int{1000, 10000} {
|
|
b.Run(fmt.Sprint(n), func(b *testing.B) {
|
|
ctx, sys, _ := prepareIAMRevisionFixture(b)
|
|
_, err := sys.CreateUser(ctx, "benchmark-sync", madmin.AddOrUpdateUserReq{SecretKey: "valid-sync-password", Status: madmin.AccountEnabled})
|
|
mustIAM(b, err)
|
|
for i := range n {
|
|
at := UTCNow().Add(time.Duration(i) * time.Nanosecond)
|
|
data, err := json.Marshal(iamRevision{Deleted: true, UpdatedAt: at, RevokedBefore: at})
|
|
mustIAM(b, err)
|
|
sys.store.revisionIndex().observe(getUserIdentityPath(fmt.Sprintf("deleted-%06d", i), regUser), data)
|
|
}
|
|
var puts atomic.Int64
|
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if r.URL.Path == "/minio/health/live" {
|
|
w.WriteHeader(http.StatusOK)
|
|
return
|
|
}
|
|
if r.Method == http.MethodPut {
|
|
puts.Add(1)
|
|
}
|
|
_ = json.NewEncoder(w).Encode(iamRevisionResponse{iamRevisionStatus: iamRevisionStatus{Version: iamRevisionProtocol, Node: "node-1", Instance: "benchmark-peer", Digest: "constant"}})
|
|
}))
|
|
defer server.Close()
|
|
c := &SiteReplicationSys{enabled: true, state: srState{ServiceAccountAccessKey: "benchmark-sync", Peers: map[string]madmin.PeerInfo{globalDeploymentID(): {DeploymentID: globalDeploymentID(), Name: "local"}, "remote": {DeploymentID: "remote", Name: "remote", Endpoint: server.URL}}}}
|
|
mustIAM(b, c.healIAMDeletions(ctx))
|
|
before := puts.Load()
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for b.Loop() {
|
|
mustIAM(b, c.healIAMDeletions(ctx))
|
|
}
|
|
b.StopTimer()
|
|
b.ReportMetric(float64(puts.Load()-before)/float64(b.N), "PUT/op")
|
|
if puts.Load() != before {
|
|
b.Fatal("steady-state healing replayed acknowledged records")
|
|
}
|
|
})
|
|
}
|
|
}
|