This commit is contained in:
William Banfield
2022-09-01 17:48:13 -04:00
parent e768dee0cb
commit 9ad3132dc6
3 changed files with 15 additions and 10 deletions

View File

@@ -9,7 +9,10 @@ import (
const payloadSizeTarget = 1024 // 1kb
func TestSize(t *testing.T) {
s := payload.UnpaddedSizeBytes()
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)
}
@@ -20,10 +23,10 @@ func TestRoundTrip(t *testing.T) {
testConns = 512
testRate = 4
)
b, err := payload.NewBytes(payload.Options{
Size: payloadSizeTarget,
Conns: testConns,
Rate: testRate,
b, err := payload.NewBytes(&payload.Payload{
Size: payloadSizeTarget,
Connections: testConns,
Rate: testRate,
})
if err != nil {
t.Fatalf("generating payload %s", err)

View File

@@ -94,7 +94,8 @@ func GenerateFromBlockStore(s BlockStore) (Report, error) {
r.All = append(r.All, pd.l)
if pd.l > r.Max {
r.Max = pd.l
} else if pd.l < r.Min {
}
if pd.l < r.Min {
r.Min = pd.l
}
// Using an int64 here makes an assumption about the scale and quantity of the data we are processing.

View File

@@ -74,14 +74,15 @@ func TestGenerateReport(t *testing.T) {
t.Fatalf("Avg did not match expected. Expected %s but contained %s", 5*time.Second, r.Avg)
}
if r.Min != 4*time.Second {
t.Fatalf("Avg did not match expected. Expected %s but contained %s", 4*time.Second, r.Min)
t.Fatalf("Min did not match expected. Expected %s but contained %s", 4*time.Second, r.Min)
}
if r.Max != 6*time.Second {
t.Fatalf("Avg did not match expected. Expected %s but contained %s", 6*time.Second, r.Max)
t.Fatalf("Max did not match expected. Expected %s but contained %s", 6*time.Second, r.Max)
}
// Verified using online standard deviation calculator:
// https://www.calculator.net/standard-deviation-calculator.html?numberinputs=6%2C+4&ctype=p&x=84&y=27
if r.StdDev != time.Second {
t.Fatalf("StdDev did not match expected. Expected %s but contained %s", time.Second, r.StdDev)
expectedStdDev := 1414213562 * time.Nanosecond
if r.StdDev != expectedStdDev {
t.Fatalf("StdDev did not match expected. Expected %s but contained %s", expectedStdDev, r.StdDev)
}
}