mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 11:45:18 +00:00
* add separated runs by UUID (#9367)
This _should_ be the last piece needed for this tool.
This allows the tool to generate reports on multiple experimental runs that may have been performed against the same chain.
The `load` tool has been updated to generate a `UUID` on startup to uniquely identify each experimental run. The `report` tool separates all of the results it reads by `UUID` and performs separate calculations for each discovered experiment.
Sample output is as follows
```
Experiment ID: 6bd7d1e8-d82c-4dbe-a1b3-40ab99e4fa30
Connections: 1
Rate: 1000
Size: 1024
Total Valid Tx: 9000
Total Negative Latencies: 0
Minimum Latency: 86.632837ms
Maximum Latency: 1.151089602s
Average Latency: 813.759361ms
Standard Deviation: 225.189977ms
Experiment ID: 453960af-6295-4282-aed6-367fc17c0de0
Connections: 1
Rate: 1000
Size: 1024
Total Valid Tx: 9000
Total Negative Latencies: 0
Minimum Latency: 79.312992ms
Maximum Latency: 1.162446243s
Average Latency: 422.755139ms
Standard Deviation: 241.832475ms
Total Invalid Tx: 0
```
closes: #9352
#### PR checklist
- [ ] Tests written/updated, or no tests needed
- [ ] `CHANGELOG_PENDING.md` updated, or no changelog entry needed
- [ ] Updated relevant documentation (`docs/`) and code comments, or no
documentation updates needed
(cherry picked from commit 1067ba1571)
# Conflicts:
# go.mod
* fix merge conflict
* fix lint
Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
Co-authored-by: William Banfield <wbanfield@gmail.com>
125 lines
3.1 KiB
Go
125 lines
3.1 KiB
Go
package report_test
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/tendermint/tendermint/test/loadtime/payload"
|
|
"github.com/tendermint/tendermint/test/loadtime/report"
|
|
"github.com/tendermint/tendermint/types"
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
type mockBlockStore struct {
|
|
base int64
|
|
blocks []*types.Block
|
|
}
|
|
|
|
func (m *mockBlockStore) Height() int64 {
|
|
return m.base + int64(len(m.blocks))
|
|
}
|
|
|
|
func (m *mockBlockStore) Base() int64 {
|
|
return m.base
|
|
}
|
|
|
|
func (m *mockBlockStore) LoadBlock(i int64) *types.Block {
|
|
return m.blocks[i-m.base]
|
|
}
|
|
|
|
func TestGenerateReport(t *testing.T) {
|
|
t1 := time.Now()
|
|
u := [16]byte(uuid.New())
|
|
b1, err := payload.NewBytes(&payload.Payload{
|
|
Id: u[:],
|
|
Time: timestamppb.New(t1.Add(-10 * time.Second)),
|
|
Size: 1024,
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("generating payload %s", err)
|
|
}
|
|
b2, err := payload.NewBytes(&payload.Payload{
|
|
Id: u[:],
|
|
Time: timestamppb.New(t1.Add(-4 * time.Second)),
|
|
Size: 1024,
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("generating payload %s", err)
|
|
}
|
|
b3, err := payload.NewBytes(&payload.Payload{
|
|
Id: u[:],
|
|
Time: timestamppb.New(t1.Add(2 * time.Second)),
|
|
Size: 1024,
|
|
})
|
|
t2 := t1.Add(time.Second)
|
|
if err != nil {
|
|
t.Fatalf("generating payload %s", err)
|
|
}
|
|
s := &mockBlockStore{
|
|
blocks: []*types.Block{
|
|
{
|
|
Data: types.Data{
|
|
Txs: []types.Tx{b1, b2},
|
|
},
|
|
},
|
|
{
|
|
// The timestamp from block H+1 is used to calculate the
|
|
// latency for the transactions in block H.
|
|
Header: types.Header{
|
|
Time: t1,
|
|
},
|
|
Data: types.Data{
|
|
Txs: []types.Tx{[]byte("error")},
|
|
},
|
|
},
|
|
{
|
|
Data: types.Data{
|
|
Txs: []types.Tx{b3, b3},
|
|
},
|
|
},
|
|
{
|
|
Header: types.Header{
|
|
Time: t2,
|
|
},
|
|
Data: types.Data{
|
|
Txs: []types.Tx{},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
rs, err := report.GenerateFromBlockStore(s)
|
|
if err != nil {
|
|
t.Fatalf("generating report %s", err)
|
|
}
|
|
if rs.ErrorCount() != 1 {
|
|
t.Fatalf("ErrorCount did not match expected. Expected %d but contained %d", 1, rs.ErrorCount())
|
|
}
|
|
rl := rs.List()
|
|
if len(rl) != 1 {
|
|
t.Fatalf("number of reports did not match expected. Expected %d but contained %d", 1, len(rl))
|
|
}
|
|
r := rl[0]
|
|
if len(r.All) != 4 {
|
|
t.Fatalf("report contained different number of data points from expected. Expected %d but contained %d", 4, len(r.All)) //nolint:lll
|
|
}
|
|
if r.NegativeCount != 2 {
|
|
t.Fatalf("NegativeCount did not match expected. Expected %d but contained %d", 2, r.NegativeCount)
|
|
}
|
|
if r.Avg != 3*time.Second {
|
|
t.Fatalf("Avg did not match expected. Expected %s but contained %s", 3*time.Second, r.Avg)
|
|
}
|
|
if r.Min != -time.Second {
|
|
t.Fatalf("Min did not match expected. Expected %s but contained %s", time.Second, r.Min)
|
|
}
|
|
if r.Max != 10*time.Second {
|
|
t.Fatalf("Max did not match expected. Expected %s but contained %s", 10*time.Second, r.Max)
|
|
}
|
|
// Verified using online standard deviation calculator:
|
|
// https://www.calculator.net/standard-deviation-calculator.html?numberinputs=10%2C+4%2C+-1%2C+-1&ctype=s&x=45&y=12
|
|
expectedStdDev := 5228129047 * time.Nanosecond
|
|
if r.StdDev != expectedStdDev {
|
|
t.Fatalf("StdDev did not match expected. Expected %s but contained %s", expectedStdDev, r.StdDev)
|
|
}
|
|
}
|