test: add the loadtime report tool (#9351) (#9364)

This pull request adds the report tool and modifies the loadtime libraries to better support its use.

(cherry picked from commit 8655080a0f)

Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2022-09-02 15:29:56 -04:00
committed by GitHub
co-authored by William Banfield
parent 6ed1bb96d7
commit d9fd26ce93
13 changed files with 551 additions and 88 deletions
+50
View File
@@ -0,0 +1,50 @@
package payload_test
import (
"testing"
"github.com/tendermint/tendermint/test/loadtime/payload"
)
const payloadSizeTarget = 1024 // 1kb
func TestSize(t *testing.T) {
s, err := payload.MaxUnpaddedSize()
if err != nil {
t.Fatalf("calculating max unpadded size %s", err)
}
if s > payloadSizeTarget {
t.Fatalf("unpadded payload size %d exceeds target %d", s, payloadSizeTarget)
}
}
func TestRoundTrip(t *testing.T) {
const (
testConns = 512
testRate = 4
)
b, err := payload.NewBytes(&payload.Payload{
Size: payloadSizeTarget,
Connections: testConns,
Rate: testRate,
})
if err != nil {
t.Fatalf("generating payload %s", err)
}
if len(b) < payloadSizeTarget {
t.Fatalf("payload size in bytes %d less than expected %d", len(b), payloadSizeTarget)
}
p, err := payload.FromBytes(b)
if err != nil {
t.Fatalf("reading payload %s", err)
}
if p.Size != payloadSizeTarget {
t.Fatalf("payload size value %d does not match expected %d", p.Size, payloadSizeTarget)
}
if p.Connections != testConns {
t.Fatalf("payload connections value %d does not match expected %d", p.Connections, testConns)
}
if p.Rate != testRate {
t.Fatalf("payload rate value %d does not match expected %d", p.Rate, testRate)
}
}