Skip to content

Commit 8d976d7

Browse files
committed
feat: created tcp_long_conn e2e test
Signed-off-by: Yash Patel <yp969803@gmail.com>
1 parent e579883 commit 8d976d7

File tree

9 files changed

+62
-17
lines changed

9 files changed

+62
-17
lines changed

bpf/kmesh/bpf2go/dualengine/kmeshcgroupskb_bpfeb.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bpf/kmesh/bpf2go/dualengine/kmeshcgroupskb_bpfel.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bpf/kmesh/bpf2go/dualengine/kmeshcgroupskbcompat_bpfeb.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bpf/kmesh/bpf2go/dualengine/kmeshcgroupskbcompat_bpfel.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bpf/kmesh/probes/probe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#define LONG_CONN_THRESHOLD_TIME (5 * 1000000000ULL) // 5s
1111

12-
volatile __u32 enable_monitoring = 0;
12+
volatile __u32 enable_monitoring = 1;
1313

1414
static inline bool is_monitoring_enable()
1515
{

bpf/kmesh/probes/tcp_probe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define __KMESH_BPF_ACCESS_LOG_H__
66

77
#include "bpf_common.h"
8+
#include "config.h"
89

910
// direction
1011
enum {

bpf/kmesh/workload/cgroup_skb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "bpf_log.h"
99
#include "bpf_common.h"
1010
#include "probe.h"
11+
#include "config.h"
1112

1213
SEC("cgroup_skb/ingress")
1314
int cgroup_skb_ingress_prog(struct __sk_buff *skb)

test/e2e/baseline_test.go

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ func TestL4Telemetry(t *testing.T) {
793793
To: localDst,
794794
}
795795

796-
query := buildL4Query(localSrc, localDst)
796+
query := buildL4Query(localSrc, localDst, "kmesh_tcp_connections_opened_total")
797797
stc.Logf("prometheus query: %#v", query)
798798
err := retry.Until(func() bool {
799799
stc.Logf("sending call from %q to %q", deployName(localSrc), localDst.Config().Service)
@@ -819,7 +819,50 @@ func TestL4Telemetry(t *testing.T) {
819819
})
820820
}
821821

822-
func buildL4Query(src, dst echo.Instance) prometheus.Query {
822+
func TestLongConnL4Telemetry(t *testing.T) {
823+
framework.NewTest(t).Run(func(tc framework.TestContext) {
824+
for _, src := range apps.EnrolledToKmesh {
825+
for _, dst := range apps.EnrolledToKmesh {
826+
tc.NewSubTestf("from %q to %q", src.Config().Service, dst.Config().Service).Run(func(stc framework.TestContext) {
827+
localDst := dst
828+
localSrc := src
829+
opt := echo.CallOptions{
830+
Port: echo.Port{Name: "tcp"},
831+
Scheme: scheme.TCP,
832+
Count: 10,
833+
Timeout: time.Second,
834+
Check: check.OK(),
835+
To: localDst,
836+
NewConnectionPerRequest: false,
837+
}
838+
839+
query := buildL4Query(localSrc, localDst, "kmesh_tcp_sent_bytes_total")
840+
stc.Logf("prometheus query: %#v", query)
841+
err := retry.Until(func() bool {
842+
stc.Logf("sending call from %q to %q", deployName(localSrc), localDst.Config().Service)
843+
localSrc.CallOrFail(stc, opt)
844+
reqs, err := prom.QuerySum(localSrc.Config().Cluster, query)
845+
if err != nil {
846+
stc.Logf("could not query for traffic from %q to %q: %v", deployName(localSrc), localDst.Config().Service, err)
847+
return false
848+
}
849+
if reqs == 0.0 {
850+
stc.Logf("found zero-valued sum for traffic from %q to %q: %v", deployName(localSrc), localDst.Config().Service, err)
851+
return false
852+
}
853+
return true
854+
}, retry.Timeout(15*time.Second), retry.BackoffDelay(1*time.Second))
855+
if err != nil {
856+
PromDiff(t, prom, localSrc.Config().Cluster, query)
857+
stc.Errorf("could not validate L4 telemetry for %q to %q: %v", deployName(localSrc), localDst.Config().Service, err)
858+
}
859+
})
860+
}
861+
}
862+
})
863+
}
864+
865+
func buildL4Query(src, dst echo.Instance, metricName string) prometheus.Query {
823866
query := prometheus.Query{}
824867

825868
srcns := src.NamespaceName()
@@ -849,7 +892,7 @@ func buildL4Query(src, dst echo.Instance) prometheus.Query {
849892
"source_cluster": "Kubernetes",
850893
}
851894

852-
query.Metric = "kmesh_tcp_connections_opened_total"
895+
query.Metric = metricName
853896
query.Labels = labels
854897

855898
return query
@@ -1150,7 +1193,6 @@ spec:
11501193
}
11511194
})
11521195
})
1153-
11541196
}
11551197
})
11561198
}

test/e2e/run_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,4 @@ if [[ -n "${CLEANUP_REGISTRY}" ]]; then
299299
fi
300300

301301
rm -rf "${TMP}"
302+

0 commit comments

Comments
 (0)