From 06a6bc8864a26d5411bdd18f8d2132da344a3782 Mon Sep 17 00:00:00 2001 From: kalo <24719519+KaloyanTanev@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:01:25 +0300 Subject: [PATCH 1/2] Fix race condition making the log test fail --- app/log/loki/client_test.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/log/loki/client_test.go b/app/log/loki/client_test.go index 8f74763361..9ba1d0e1eb 100644 --- a/app/log/loki/client_test.go +++ b/app/log/loki/client_test.go @@ -98,7 +98,7 @@ func TestLongLines(t *testing.T) { var ( ctx = context.Background() - entriesChan = make(chan string) + entriesChan = make(chan string, 10) // buffered so handler never blocks on send ) srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -110,11 +110,7 @@ func TestLongLines(t *testing.T) { require.Contains(t, req.GetStreams()[0].GetLabels(), fmt.Sprintf(`service="%s"`, serviceLabel)) for _, entry := range req.GetStreams()[0].GetEntries() { - go func(entry string) { - entriesChan <- entry - - close(entriesChan) - }(entry.GetLine()) + entriesChan <- entry.GetLine() } })) @@ -133,15 +129,23 @@ func TestLongLines(t *testing.T) { cl.Add(huge) } + // Wait for normal to arrive via the periodic ticker flush before stopping. + // Stop() only flushes whatever is already in the batch, so we must confirm + // delivery here rather than relying on the shutdown path. + select { + case entry := <-entriesChan: + require.Equal(t, normal, entry) + case <-time.After(5 * time.Second): + t.Fatal("timed out waiting for log entry") + } + cl.Stop(ctx) - var entries []string + // Stop() guarantees all in-flight HTTP calls have completed, so closing + // here is safe. Drain any remaining entries and verify no huge lines leaked. + close(entriesChan) for entry := range entriesChan { require.NotEqual(t, huge, entry) - entries = append(entries, entry) } - - require.Len(t, entries, 1) - require.Equal(t, normal, entries[0]) } From 5f0211eff73ca646fc4cc45708f32f46dec4c8cb Mon Sep 17 00:00:00 2001 From: kalo <24719519+KaloyanTanev@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:36:35 +0300 Subject: [PATCH 2/2] Fix test data race --- core/scheduler/scheduler_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/scheduler/scheduler_test.go b/core/scheduler/scheduler_test.go index c8e875eea2..6bb4d92d91 100644 --- a/core/scheduler/scheduler_test.go +++ b/core/scheduler/scheduler_test.go @@ -568,13 +568,15 @@ func TestSubmitValidatorRegistrations(t *testing.T) { eth2Cl.SubmitValidatorRegistrationsFunc = func(ctx context.Context, regs []*eth2api.VersionedSignedValidatorRegistration) error { callCount.Add(1) - if registrations == nil { - callMutex.Lock() + callMutex.Lock() + first := registrations == nil + if first { registrations = regs + } + callMutex.Unlock() - callMutex.Unlock() - + if first { select { case callDone <- struct{}{}: default: