Skip to content

Commit e435ef2

Browse files
committed
fix:修复测试错误
1 parent c39f915 commit e435ef2

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

window/performance_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ func TestTumblingWindowPerformance(t *testing.T) {
4444

4545
t.Logf("缓冲区大小: %d", bufferSize)
4646
t.Logf("处理时间: %v", elapsed)
47-
t.Logf("发送成功: %d", stats["sent_count"])
48-
t.Logf("丢弃数量: %d", stats["dropped_count"])
49-
t.Logf("缓冲区利用率: %d/%d", stats["buffer_used"], stats["buffer_size"])
47+
t.Logf("发送成功: %d", stats["sentCount"])
48+
t.Logf("丢弃数量: %d", stats["droppedCount"])
49+
t.Logf("缓冲区利用率: %d/%d", stats["bufferUsed"], stats["bufferSize"])
5050

5151
// 验证没有严重的数据丢失
5252
if bufferSize >= 1000 {
53-
if stats["dropped_count"] > int64(dataCount/10) { // 允许最多10%的丢失
54-
t.Errorf("丢失数据过多: %d (总数: %d)", stats["dropped_count"], dataCount)
53+
if stats["droppedCount"] > int64(dataCount/10) { // 允许最多10%的丢失
54+
t.Errorf("丢失数据过多: %d (总数: %d)", stats["droppedCount"], dataCount)
5555
}
5656
}
5757

@@ -101,7 +101,7 @@ func BenchmarkTumblingWindowThroughput(b *testing.B) {
101101

102102
// 获取最终统计
103103
stats := tw.GetStats()
104-
b.Logf("发送成功: %d, 丢弃: %d", stats["sent_count"], stats["dropped_count"])
104+
b.Logf("发送成功: %d, 丢弃: %d", stats["sentCount"], stats["droppedCount"])
105105

106106
tw.Stop()
107107
}
@@ -132,15 +132,15 @@ func TestWindowBufferOverflow(t *testing.T) {
132132
time.Sleep(200 * time.Millisecond)
133133

134134
stats := tw.GetStats()
135-
t.Logf("缓冲区溢出测试 - 发送: %d, 丢弃: %d", stats["sent_count"], stats["dropped_count"])
135+
t.Logf("缓冲区溢出测试 - 发送: %d, 丢弃: %d", stats["sentCount"], stats["droppedCount"])
136136

137137
// 应该有数据被丢弃
138-
if stats["dropped_count"] == 0 {
138+
if stats["droppedCount"] == 0 {
139139
t.Log("预期会有数据丢弃,但实际没有丢弃")
140140
}
141141

142142
// 验证系统仍然运行正常(没有阻塞)
143-
if stats["sent_count"] == 0 {
143+
if stats["sentCount"] == 0 {
144144
t.Error("应该至少发送了一些数据")
145145
}
146146

window/window_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,8 @@ func TestWindowUnifiedConfigIntegration(t *testing.T) {
10291029

10301030
// 检查统计信息
10311031
stats := tw.GetStats()
1032-
assert.Contains(t, stats, "dropped_count")
1033-
assert.Contains(t, stats, "sent_count")
1032+
assert.Contains(t, stats, "droppedCount")
1033+
assert.Contains(t, stats, "sentCount")
10341034
})
10351035
}
10361036

@@ -1369,8 +1369,8 @@ func TestTumblingWindowAdvanced(t *testing.T) {
13691369

13701370
// 检查统计信息
13711371
stats := tw.GetStats()
1372-
assert.Contains(t, stats, "sent_count")
1373-
assert.Contains(t, stats, "dropped_count")
1372+
assert.Contains(t, stats, "sentCount")
1373+
assert.Contains(t, stats, "droppedCount")
13741374

13751375
// 测试重置统计信息
13761376
tw.ResetStats()

0 commit comments

Comments
 (0)