From 1374efd063a19afba2dc8b1057221a5b1f574610 Mon Sep 17 00:00:00 2001 From: Yash Patel Date: Thu, 22 May 2025 11:48:15 +0530 Subject: [PATCH 1/8] e2e test for long_conn metrics Signed-off-by: Yash Patel --- test/e2e/baseline_test.go | 54 +++++++++++++++++++++++++++++++++++++-- test/e2e/gateway_test.go | 2 -- test/e2e/main_test.go | 2 -- test/e2e/manage_test.go | 2 -- test/e2e/restart_test.go | 2 -- 5 files changed, 52 insertions(+), 10 deletions(-) diff --git a/test/e2e/baseline_test.go b/test/e2e/baseline_test.go index 3c1625246..a45ceed26 100644 --- a/test/e2e/baseline_test.go +++ b/test/e2e/baseline_test.go @@ -1,5 +1,3 @@ -//go:build integ -// +build integ /* * Copyright The Kmesh Authors. @@ -955,6 +953,58 @@ func TestL4Telemetry(t *testing.T) { }) } +func TestLongConnL4Telemetry(t *testing.T) { + framework.NewTest(t).Run(func(tc framework.TestContext) { + for _, src := range apps.EnrolledToKmesh { + for _, dst := range apps.EnrolledToKmesh { + tc.NewSubTestf("from %q to %q", src.Config().Service, dst.Config().Service).Run(func(stc framework.TestContext) { + localDst := dst + localSrc := src + opt := echo.CallOptions{ + Port: echo.Port{Name: "http"}, + Scheme: scheme.HTTP, + Count: 20, + Timeout: 1.5*60* time.Second, + Check: check.OK(), + HTTP: echo.HTTP{Path: "/?delay=3s", HTTP2: true}, + To: localDst, + NewConnectionPerRequest: false, + } + + stc.Logf("sending continuous calls from %q to %q", deployName(localSrc), localDst.Config().Service) + go localSrc.CallOrFail(stc, opt) + + query := buildL4Query(localSrc, localDst) + stc.Logf("prometheus query: %#v", query) + prevReqs := float64(0) + for i := 0; i < 2; i++ { + err := retry.Until(func() bool { + reqs, err := prom.QuerySum(localSrc.Config().Cluster, query) + if err != nil { + stc.Logf("could not query for traffic from %q to %q: %v", deployName(localSrc), localDst.Config().Service, err) + return false + } + + if reqs-prevReqs == 0.0 { + stc.Logf("found zero-valued sum for traffic from %q to %q: %v", deployName(localSrc), localDst.Config().Service, err) + return false + } + prevReqs = reqs + return true + }, retry.Timeout(15*time.Second), retry.BackoffDelay(1*time.Second)) + if err != nil { + PromDiff(t, prom, localSrc.Config().Cluster, query) + stc.Errorf("could not validate L4 telemetry for %q to %q: %v", deployName(localSrc), localDst.Config().Service, err) + } + time.Sleep(15 * time.Second) + } + time.Sleep(2 * 60 * time.Second) + }) + } + } + }) +} + func buildL4Query(src, dst echo.Instance) prometheus.Query { query := prometheus.Query{} diff --git a/test/e2e/gateway_test.go b/test/e2e/gateway_test.go index 8ea613b49..cc9026360 100644 --- a/test/e2e/gateway_test.go +++ b/test/e2e/gateway_test.go @@ -1,5 +1,3 @@ -//go:build integ -// +build integ // CODE Copied and modified from https://github.com/istio/istio // more specifically: https://github.com/istio/istio/blob/master/pkg/test/framework/components/istio/ingress.go diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index 98522c73c..f1b019e51 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -1,5 +1,3 @@ -//go:build integ -// +build integ /* * Copyright The Kmesh Authors. diff --git a/test/e2e/manage_test.go b/test/e2e/manage_test.go index f80b9243a..2a0c61367 100644 --- a/test/e2e/manage_test.go +++ b/test/e2e/manage_test.go @@ -1,5 +1,3 @@ -//go:build integ -// +build integ /* * Copyright The Kmesh Authors. diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index 987c3d095..4eef41518 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -1,5 +1,3 @@ -//go:build integ -// +build integ /* * Copyright The Kmesh Authors. From ea6e006613c92f120bca8f5374f0c2acb0b00980 Mon Sep 17 00:00:00 2001 From: Yash Patel Date: Mon, 26 May 2025 08:06:20 +0530 Subject: [PATCH 2/8] demo testing Signed-off-by: Yash Patel --- bpf/kmesh/workload/cgroup_skb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bpf/kmesh/workload/cgroup_skb.c b/bpf/kmesh/workload/cgroup_skb.c index 9cb9662be..8b2cda898 100644 --- a/bpf/kmesh/workload/cgroup_skb.c +++ b/bpf/kmesh/workload/cgroup_skb.c @@ -11,7 +11,7 @@ #include "probe.h" #include "config.h" -volatile __u32 enable_periodic_report = 0; +volatile __u32 enable_periodic_report = 1; static inline bool is__periodic_report_enable() { From 556ba404673fd4972bfd710cf065f99ad957935b Mon Sep 17 00:00:00 2001 From: Yash Patel Date: Mon, 26 May 2025 08:27:14 +0530 Subject: [PATCH 3/8] demo testing Signed-off-by: Yash Patel --- test/e2e/baseline_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/baseline_test.go b/test/e2e/baseline_test.go index a45ceed26..6e4c8ca98 100644 --- a/test/e2e/baseline_test.go +++ b/test/e2e/baseline_test.go @@ -977,6 +977,7 @@ func TestLongConnL4Telemetry(t *testing.T) { query := buildL4Query(localSrc, localDst) stc.Logf("prometheus query: %#v", query) prevReqs := float64(0) + time.Sleep(5 * time.Second) for i := 0; i < 2; i++ { err := retry.Until(func() bool { reqs, err := prom.QuerySum(localSrc.Config().Cluster, query) @@ -998,7 +999,7 @@ func TestLongConnL4Telemetry(t *testing.T) { } time.Sleep(15 * time.Second) } - time.Sleep(2 * 60 * time.Second) + time.Sleep(60 * time.Second) }) } } From b7afeff26304feac85b9c22602e38397f7162fb8 Mon Sep 17 00:00:00 2001 From: Yash Patel Date: Mon, 26 May 2025 09:05:08 +0530 Subject: [PATCH 4/8] demo testing Signed-off-by: Yash Patel --- test/e2e/baseline_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/baseline_test.go b/test/e2e/baseline_test.go index 6e4c8ca98..9e203511f 100644 --- a/test/e2e/baseline_test.go +++ b/test/e2e/baseline_test.go @@ -977,8 +977,8 @@ func TestLongConnL4Telemetry(t *testing.T) { query := buildL4Query(localSrc, localDst) stc.Logf("prometheus query: %#v", query) prevReqs := float64(0) - time.Sleep(5 * time.Second) - for i := 0; i < 2; i++ { + time.Sleep(10 * time.Second) + for range(3) { err := retry.Until(func() bool { reqs, err := prom.QuerySum(localSrc.Config().Cluster, query) if err != nil { @@ -999,7 +999,7 @@ func TestLongConnL4Telemetry(t *testing.T) { } time.Sleep(15 * time.Second) } - time.Sleep(60 * time.Second) + time.Sleep(30 * time.Second) }) } } From 055075853a8406c47003e84c77b401c636ba6761 Mon Sep 17 00:00:00 2001 From: Yash Patel Date: Mon, 26 May 2025 10:30:27 +0530 Subject: [PATCH 5/8] demo testing Signed-off-by: Yash Patel --- test/e2e/baseline_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/baseline_test.go b/test/e2e/baseline_test.go index 9e203511f..b8b734591 100644 --- a/test/e2e/baseline_test.go +++ b/test/e2e/baseline_test.go @@ -978,7 +978,7 @@ func TestLongConnL4Telemetry(t *testing.T) { stc.Logf("prometheus query: %#v", query) prevReqs := float64(0) time.Sleep(10 * time.Second) - for range(3) { + for range(2) { err := retry.Until(func() bool { reqs, err := prom.QuerySum(localSrc.Config().Cluster, query) if err != nil { @@ -999,7 +999,7 @@ func TestLongConnL4Telemetry(t *testing.T) { } time.Sleep(15 * time.Second) } - time.Sleep(30 * time.Second) + time.Sleep(1.5 * 60 * time.Second) }) } } From b8126769d1523c19d47c4e533ac7a59d2ee88bce Mon Sep 17 00:00:00 2001 From: Yash Patel Date: Mon, 26 May 2025 11:07:28 +0530 Subject: [PATCH 6/8] demo testing Signed-off-by: Yash Patel --- test/e2e/baseline_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/e2e/baseline_test.go b/test/e2e/baseline_test.go index b8b734591..ea757ab3f 100644 --- a/test/e2e/baseline_test.go +++ b/test/e2e/baseline_test.go @@ -971,9 +971,13 @@ func TestLongConnL4Telemetry(t *testing.T) { NewConnectionPerRequest: false, } - stc.Logf("sending continuous calls from %q to %q", deployName(localSrc), localDst.Config().Service) - go localSrc.CallOrFail(stc, opt) - + go func() { + stc.Logf("sending continuous calls from %q to %q", deployName(localSrc), localDst.Config().Service) + start := time.Now() + localSrc.CallOrFail(stc, opt) + elapsed := time.Since(start) + stc.Logf("finished continuous calls from %q to %q in %v", deployName(localSrc), localDst.Config().Service, elapsed) + }() query := buildL4Query(localSrc, localDst) stc.Logf("prometheus query: %#v", query) prevReqs := float64(0) From 654311b695f419725492201e4d80370146514727 Mon Sep 17 00:00:00 2001 From: Yash Patel Date: Mon, 26 May 2025 11:36:10 +0530 Subject: [PATCH 7/8] demo testing Signed-off-by: Yash Patel --- test/e2e/baseline_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/baseline_test.go b/test/e2e/baseline_test.go index ea757ab3f..049624fed 100644 --- a/test/e2e/baseline_test.go +++ b/test/e2e/baseline_test.go @@ -963,7 +963,7 @@ func TestLongConnL4Telemetry(t *testing.T) { opt := echo.CallOptions{ Port: echo.Port{Name: "http"}, Scheme: scheme.HTTP, - Count: 20, + Count: 200, Timeout: 1.5*60* time.Second, Check: check.OK(), HTTP: echo.HTTP{Path: "/?delay=3s", HTTP2: true}, From 90612e3ab1b536780a8c5c5f393c7e160459c05d Mon Sep 17 00:00:00 2001 From: Yash Patel Date: Mon, 26 May 2025 12:08:57 +0530 Subject: [PATCH 8/8] demo testing Signed-off-by: Yash Patel --- test/e2e/baseline_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/baseline_test.go b/test/e2e/baseline_test.go index 049624fed..11f8b0f6f 100644 --- a/test/e2e/baseline_test.go +++ b/test/e2e/baseline_test.go @@ -981,7 +981,7 @@ func TestLongConnL4Telemetry(t *testing.T) { query := buildL4Query(localSrc, localDst) stc.Logf("prometheus query: %#v", query) prevReqs := float64(0) - time.Sleep(10 * time.Second) + time.Sleep(5 * time.Second) for range(2) { err := retry.Until(func() bool { reqs, err := prom.QuerySum(localSrc.Config().Cluster, query)