eBPF Testing

Keploy uses to capture every API call, database query and service interaction at the kernel level, and turns them into tests and mocks: eBPF API testing with zero code changes, zero proxies, zero SDKs.

On Apple Silicon Macs and Windows, Keploy also records natively without eBPF for Go, Node.js, Python and Java apps. You choose where recording runs, such as a local machine, CI or a staging namespace.

  • Every API call, query and message captured
  • No SDKs, no proxies, no code changes
  • Works with any language on Linux

eBPF capture: Keploy attaches eBPF probes to the kernel socket system calls, copies every request and dependency call that crosses the kernel, and decodes them into test cases and mocks.

Step 1 of 3: Attach probes

Why eBPF for Testing

The testing industry spent two decades building tools that require application changes. eBPF removes all of these requirements.

Kernel-level capture

eBPF sees every byte entering and leaving your app through network sockets. No proxies, no middleware, no blind spots.

Near-zero overhead

JIT-compiled probes run in the kernel with no extra network hop, unlike sidecar proxies that route every request through another process.

Language agnostic

Go (Golang), Java, Python, Node.js, Rust, C++, Ruby, PHP and Elixir all work the same way, with no code changes.

Full protocol support

HTTP, gRPC, PostgreSQL, MySQL, MongoDB, Redis, Kafka and GraphQL are decoded into readable tests and mocks.

Key takeaway: eBPF shifts the instrumentation burden from the application developer to the kernel. This is the same paradigm shift that eBPF brought to networking and security, and Keploy is bringing it to testing.

How Keploy Uses eBPF for API Testing

Most eBPF tools are built for tracing and security. Keploy is an open-source eBPF testing tool, built for record and replay testing, with flaky test detection built in.

Step 1

Recording phase

eBPF probes capture every inbound request and outbound call, stored as YAML test cases with mocks.

Step 2

Noise detection

AI compares fields across recordings and flags timestamps, UUIDs and tokens so tests are not flaky.

Step 3

Replay phase

Recorded requests replay while eBPF intercepts outbound calls and answers them with recorded mocks.

Step 4

CI/CD integration

A single CLI step runs the suite in seconds in GitHub Actions, GitLab CI, Jenkins or any CI system.

Keploy's eBPF code is open source on GitHub. To run it in CI, see executing eBPF in GitHub Actions.

eBPF vs Sidecar Proxy vs SDK

Three approaches to capturing traffic for testing, each at a different layer of the stack.

vs

eBPF (Keploy)

Sidecar proxy

Capture layer

Strong:Linux kernel
Partial:Network, in user space

Code changes

Strong:None
Partial:Deployment config changes

Protocol visibility

Strong:All network protocols
Partial:HTTP and gRPC only

Performance overhead

Strong:Low, no extra network hop
Weak:Higher, extra hop per request

Language support

Strong:Any language
Strong:Any language
Key takeaway: eBPF provides the widest protocol visibility with the lowest overhead and zero code changes. For comprehensive testing of services with database and queue dependencies, eBPF is the strongest approach. OpenTelemetry eBPF instrumentation uses the same kernel hooks to produce traces and metrics; Keploy keeps the full payloads so traffic can be replayed as tests.

eBPF Testing in Kubernetes

Every pod on a node shares that node's Linux kernel, so eBPF can observe any container's traffic without changing its image. That makes eBPF on k8s a natural fit for recording real service traffic.

One kernel per node

Pods on a node share its Linux kernel, so Kubernetes eBPF capture works for every language and base image, with no image rebuilds or injected libraries.

Scoped to the pods you record

A node agent loads the eBPF programs and filters capture by the target pods' PIDs and cgroups. You choose the namespace, such as staging or a sandbox.

Node agent or sidecar

Keploy runs as a DaemonSet node agent by default, or injects a sidecar agent into your pod when the DaemonSet is turned off.

Protocol Support and Wire-Level Capture

eBPF captures raw bytes. Keploy's protocol decoders parse them into structured, human-readable test cases and mocks.

HTTP APIs

HTTP/1.1 and HTTP/2: method, path, headers, body and status code.

RPC

gRPC: service, method, and request and response protobufs.

SQL databases

PostgreSQL and MySQL: query text, parameters and result sets.

NoSQL databases

MongoDB and Redis: commands, keys, documents and responses.

Message queues

Kafka: topic, partition, key and message payload.

GraphQL

GraphQL over HTTP: query, variables and response data.

This protocol breadth enables full dependency mocking. When Keploy records a test for an HTTP endpoint that queries PostgreSQL and calls a downstream gRPC service, the resulting test includes mocks for both. No live database or downstream service is needed during replay.

Performance Overhead Analysis

eBPF's low overhead comes from its execution model: programs are JIT-compiled to native machine code and run in a sandboxed context within the kernel. Data is buffered in kernel ring buffers and drained to user space asynchronously.

For most teams, we recommend recording in staging, where the small recording overhead does not affect users. During replay in CI/CD there is no production overhead, since tests run against recorded data. Overhead depends on your workload, so measure it on your own services.

Recording overhead

Where each approach adds work. Relative, not a benchmark.

eBPF (Keploy)In the kernel, no extra hop
TCP mirroringCopies packets off the wire
SDK instrumentationRuns inside your process
Sidecar proxyExtra network hop per request

Limitations and Considerations

eBPF-based testing is powerful but not without constraints. Transparency helps teams make informed decisions.

Linux Only

eBPF is a Linux kernel technology: macOS has no eBPF, and eBPF for Windows is a separate, still-maturing Microsoft project. On Apple Silicon Macs and Windows, Keploy records natively for Go, Node.js, Python and Java apps (HTTP/HTTPS, MySQL and MongoDB decoded). Other setups run Keploy inside Docker or WSL. CI/CD on Linux runs natively.

Kernel Version Requirements

Keploy needs Linux kernel 5.10 or higher. Ubuntu 22.04+, Debian 11+ and Amazon Linux 2023 meet this. To check if eBPF is enabled, run uname -r and grep CONFIG_BPF /boot/config-$(uname -r): CONFIG_BPF=y and CONFIG_BPF_SYSCALL=y mean it is on.

TLS-Encrypted Traffic

For eBPF TLS capture, Keploy attaches uprobes to TLS library functions (SSL_write, SSL_read) to read data before encryption and after decryption, which works transparently for most applications.

Privileged Access

Loading eBPF programs requires elevated privileges (root or CAP_BPF). CI/CD containers run as root by default. eBPF programs are kernel-verified and sandboxed.

FAQs

Give every change a verified
Digital Twin

Verify human- or AI-written code against real production behavior — deterministic tests, mocks, and production-like sandboxes, before it ships.

Need Resources?

Read Documentation

Integration Testing Simplified

Start With Keploy Open Source

Need Further Assistance?

Talk To Our Team On Slack

Join our GlobalCommunity

Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.

1.2M+Installs
20K+GitHub
100K+Devs
300M+Mocks
1K+Contributors
#1OSS Trending
4.9★★★★★from 500+ reviews onG2GartnerVS CodeChrome
★★★★★

“Best report of integration and API tests I've seen — which we don't get from RestAssured.”

G2
★★★★★

“Future of microservices testing. I don't write tests now!”

Mahfooz A. · G2 · 5/5
★★★★★

“An amazing product that simplifies the automation.”

Gartner · 4.0
XGitHubSlackYouTubeLinkedIn
Built by developers, for developers.Let's build the future, together.