From 319b0fee43a2e955a0f3ca8f7a8e6536a645edc2 Mon Sep 17 00:00:00 2001 From: Haley Wang Date: Fri, 27 Sep 2024 13:32:30 +0800 Subject: [PATCH] 1 --- lib/streamaggr/max.go | 4 ++-- lib/streamaggr/max_test.go | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/streamaggr/max.go b/lib/streamaggr/max.go index eb185dfe9..cab553ea2 100644 --- a/lib/streamaggr/max.go +++ b/lib/streamaggr/max.go @@ -30,7 +30,7 @@ func (as *maxAggrState) pushSamples(samples []pushSample) { again: v, ok := as.m.Load(outputKey) if !ok { - fmt.Printf("wang The entry is missing in the map: %d\n", time.Now().UnixMicro()) + // fmt.Printf("wang The entry is missing in the map: %d\n", time.Now().UnixMicro()) // The entry is missing in the map. Try creating it. v = &maxStateValue{ max: s.value, @@ -45,7 +45,7 @@ func (as *maxAggrState) pushSamples(samples []pushSample) { // Use the entry created by a concurrent goroutine. v = vNew } - fmt.Printf("wang the right way %d\n", time.Now().Unix()) + fmt.Printf("wang This is the right way %d\n", time.Now().Unix()) sv := v.(*maxStateValue) sv.mu.Lock() deleted := sv.deleted diff --git a/lib/streamaggr/max_test.go b/lib/streamaggr/max_test.go index f3f3dc61e..8fa4c76e8 100644 --- a/lib/streamaggr/max_test.go +++ b/lib/streamaggr/max_test.go @@ -1,7 +1,7 @@ package streamaggr import ( - // "fmt" + "fmt" "testing" "time" @@ -87,3 +87,11 @@ func TestPushSampleRace(t *testing.T) { } time.Sleep(1 * time.Second) } + +func TestPushSamples(t *testing.T) { + for i := 0; i < 5; i++ { + t.Run(fmt.Sprintf("Run%d", i+1), func(t *testing.T) { + TestPushSampleRace(t) + }) + } +}