From 0f878ddef715191ba27dad67aa0e4440694bc0f1 Mon Sep 17 00:00:00 2001 From: odubajDT <93584209+odubajDT@users.noreply.github.com> Date: Wed, 25 Sep 2024 09:29:11 +0200 Subject: [PATCH] Update internal/testbed/integration/combinedload/e2e_test.go Co-authored-by: Florian Bacher --- .../integration/combinedload/e2e_test.go | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/internal/testbed/integration/combinedload/e2e_test.go b/internal/testbed/integration/combinedload/e2e_test.go index 0415d3b6..3fe18552 100644 --- a/internal/testbed/integration/combinedload/e2e_test.go +++ b/internal/testbed/integration/combinedload/e2e_test.go @@ -85,16 +85,24 @@ func TestLoad_Combined(t *testing.T) { require.NoError(t, err) t.Log("collecting data...") - for seconds := 15; seconds < 151; seconds += 15 { - time.Sleep(15 * time.Second) - - //fetch metrics data - cpu, mem, err := k8stest.FetchPodMetrics(metricsClientSet, testNs, otelColPodName) - require.NoError(t, err) - - t.Log("------------------------------------------------------") - t.Logf("data after %d seconds:", seconds) - t.Logf("memory: %s, cpu: %s", mem, cpu) - t.Log("------------------------------------------------------") + ctx, cancel := context.WithTimeout(context.Background(), 150*time.Second) + defer cancel() + interval := 15 * time.Second + i := 0 + for { + select { + case <-time.After(interval): + i += 1 + //fetch metrics data + cpu, mem, err := k8stest.FetchPodMetrics(metricsClientSet, testNs, otelColPodName) + require.NoError(t, err) + + t.Log("------------------------------------------------------") + t.Logf("data after %d seconds:", i * int(interval.Seconds())) + t.Logf("memory: %s, cpu: %s", mem, cpu) + t.Log("------------------------------------------------------") + case <-ctx.Done(): + break + } } }