del: 将go版本的内容删除,只保留处理日志功能
This commit is contained in:
79
go/cmd/internal/latencylog/summary_chart_test.go
Normal file
79
go/cmd/internal/latencylog/summary_chart_test.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package latencylog
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"omnisocketgo/cmd/internal/protocol"
|
||||
)
|
||||
|
||||
func TestWriteSummariesHTMLChart(t *testing.T) {
|
||||
aProcessing := int64(20_000_000)
|
||||
aQueue := int64(10_000_000)
|
||||
transport := int64(40_000_000)
|
||||
bProcessing := int64(30_000_000)
|
||||
endToEnd := int64(100_000_000)
|
||||
aProcessingBitrate := float64(5) * 8 * 1_000_000_000 / float64(aProcessing)
|
||||
transportBitrate := float64(5) * 8 * 1_000_000_000 / float64(transport)
|
||||
endToEndBitrate := float64(5) * 8 * 1_000_000_000 / float64(endToEnd)
|
||||
|
||||
summaries := []Summary{
|
||||
{
|
||||
MessageType: protocol.MessageTypeText,
|
||||
MessageID: 7,
|
||||
From: "peer-a",
|
||||
To: "peer-b",
|
||||
BodySize: 5,
|
||||
AProcessingLatencyNS: &aProcessing,
|
||||
AQueueLatencyNS: &aQueue,
|
||||
ABTransportPropagationNS: &transport,
|
||||
BProcessingLatencyNS: &bProcessing,
|
||||
EndToEndLatencyNS: &endToEnd,
|
||||
AProcessingBitrateBPS: &aProcessingBitrate,
|
||||
ABTransportPropagationBitrateBPS: &transportBitrate,
|
||||
EndToEndBitrateBPS: &endToEndBitrate,
|
||||
ApproxRTTNS: &endToEnd,
|
||||
},
|
||||
{
|
||||
MessageType: protocol.MessageTypeFile,
|
||||
MessageID: 8,
|
||||
From: "peer-b",
|
||||
To: "peer-a",
|
||||
FileName: "payload.bin",
|
||||
BodySize: 128,
|
||||
MissingTimestamps: []string{EventBRXSoftware},
|
||||
},
|
||||
}
|
||||
|
||||
path := filepath.Join(t.TempDir(), "charts", "latency-summary.html")
|
||||
if err := WriteSummariesHTMLChart(path, summaries); err != nil {
|
||||
t.Fatalf("WriteSummariesHTMLChart() error = %v", err)
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("os.ReadFile() error = %v", err)
|
||||
}
|
||||
|
||||
content := string(data)
|
||||
for _, want := range []string{
|
||||
"Latency Summary",
|
||||
"text #7",
|
||||
"peer-a -> peer-b | 5 bytes",
|
||||
"End-to-end: 100.000 ms",
|
||||
"Approx RTT: 100.000 ms",
|
||||
"A processing bitrate 0.002 Mb/s",
|
||||
"A-B transport + propagation bitrate 0.001 Mb/s",
|
||||
"End-to-end bitrate 0.000 Mb/s",
|
||||
"A processing 20.000 ms",
|
||||
"A-B transport + propagation 40.000 ms",
|
||||
"file #8 (payload.bin)",
|
||||
"Missing timestamps: B_RX_SOFTWARE",
|
||||
} {
|
||||
if !strings.Contains(content, want) {
|
||||
t.Fatalf("chart content missing %q\n%s", want, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user