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
|
|
@ -29,6 +29,21 @@ type failAfterTransport struct {
|
|||
last []byte
|
||||
}
|
||||
|
||||
type acknowledgementCaptureMetrics struct {
|
||||
NopMetrics
|
||||
count atomic.Int64
|
||||
bytes atomic.Int64
|
||||
retainedNS atomic.Int64
|
||||
rpcResult atomic.Bool
|
||||
}
|
||||
|
||||
func (m *acknowledgementCaptureMetrics) LogicalOutboxAcknowledged(bytes int, retainedFor time.Duration, rpcResult bool) {
|
||||
m.count.Add(1)
|
||||
m.bytes.Add(int64(bytes))
|
||||
m.retainedNS.Store(int64(retainedFor))
|
||||
m.rpcResult.Store(rpcResult)
|
||||
}
|
||||
|
||||
func TestRPCResultReplayAttemptHooksArePhysicalConnectionLocal(t *testing.T) {
|
||||
const reqMsgID = int64(771)
|
||||
base := &encodedOutboundMessage{
|
||||
|
|
@ -814,6 +829,8 @@ func TestOutboundTrackedBudgetAckAndCloseReturnExactly(t *testing.T) {
|
|||
budget := newOutboundTrackedBudget(64)
|
||||
tr := &failAfterTransport{}
|
||||
c := newOutboundTestConn(t, tr, budget)
|
||||
metrics := &acknowledgementCaptureMetrics{}
|
||||
c.metrics = metrics
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
body := exactTestUpdatesEncoded(t, c, make([]byte, 12))
|
||||
|
|
@ -827,6 +844,9 @@ func TestOutboundTrackedBudgetAckAndCloseReturnExactly(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("decrypt frame: %v", err)
|
||||
}
|
||||
// Windows wall-clock resolution can otherwise make an immediate ACK look
|
||||
// like zero retention even though sentAt was populated after the write.
|
||||
time.Sleep(time.Millisecond)
|
||||
c.AckServerMessages([]int64{data.MessageID})
|
||||
deadline := time.Now().Add(time.Second)
|
||||
for budget.snapshot() != 0 && time.Now().Before(deadline) {
|
||||
|
|
@ -835,6 +855,18 @@ func TestOutboundTrackedBudgetAckAndCloseReturnExactly(t *testing.T) {
|
|||
if got := budget.snapshot(); got != 0 {
|
||||
t.Fatalf("tracked bytes after ack = %d, want 0", got)
|
||||
}
|
||||
if got := metrics.count.Load(); got != 1 {
|
||||
t.Fatalf("logical ACK metric count = %d, want 1", got)
|
||||
}
|
||||
if got := metrics.bytes.Load(); got != 12 {
|
||||
t.Fatalf("logical ACK metric bytes = %d, want 12", got)
|
||||
}
|
||||
if metrics.retainedNS.Load() <= 0 {
|
||||
t.Fatal("logical ACK metric did not record positive retention")
|
||||
}
|
||||
if metrics.rpcResult.Load() {
|
||||
t.Fatal("ordinary update ACK was classified as rpc_result")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("close", func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue