Testing and Debugging
Overview
The Cilium project utilizes a comprehensive testing and debugging approach to ensure code quality and stability. This involves various strategies, including:
- Unit Testing: Focused on verifying individual components and functions in isolation.
- Integration Testing: Testing how different components interact with each other, ensuring they work as expected in a combined environment.
- End-to-End Testing: Validating the entire system, including the interactions between different components, from user input to output.
- BPF Tracing and Debugging Tools: Tools such as
bpf_trace
andbcc
are used to analyze kernel behavior and identify issues within the BPF programs.
Unit Testing
Unit tests are implemented to test individual functions and components in isolation. These tests are typically written using the Go
language and are located within the test
directory of each package.
Examples:
- The
test_verifier
test in thebpf
package validates the BPF verifier’s correctness. - The
test_xdp
test verifies the functionality of the XDP program.
References:
- [PATCH 0/2] Fix some bpf program testing framework: https://patchwork.ozlabs.org/patch/757650/
- [PATCH 1/2] bpf: Do not dereference user pointer in: https://patchwork.ozlabs.org/patch/757650/
- [PATCH 2/2] bpf: Align packet data properly in program testing: https://patchwork.ozlabs.org/patch/757650/
- [iovisor-dev] [PATCH v3 net-next 06/12] selftests/bpf: change test_verifier expectations
- [iovisor-dev] [PATCH v3 net-next 07/12] selftests/bpf: rewrite test_align
- [iovisor-dev] [PATCH v3 net-next 08/12] selftests/bpf: add a test to test_align
- [iovisor-dev] [PATCH v3 net-next 09/12] selftests/bpf: add test for bogus operations on pointers
Integration Testing
Integration tests are used to verify the interaction between different components. They often run within a controlled environment like a Kubernetes cluster or a virtual machine, allowing for realistic testing scenarios.
Examples:
- Testing the integration of Cilium with different Kubernetes networking backends.
- Verifying the communication between the Cilium agent and the Cilium controller.
References:
- [PATCH net-next] selftests/bpf: get rid of: https://patchwork.ozlabs.org/patch/757650/
- [iovisor-dev] [PATCH v3 net-next 05/12] bpf/verifier: more concise register state logs for constant var_off
End-to-End Testing
End-to-end tests cover the complete workflow, simulating real-world scenarios to validate the system’s functionality. These tests often involve deploying a complex environment with multiple services and interactions.
Examples:
- Testing the deployment of a microservice application with Cilium-enabled networking.
- Validating the behavior of security policies and network access control rules.
References:
Tracing and Debugging Tools
Various tools and techniques are used for tracing and debugging, particularly for the BPF programs:
- BPFtrace: A DTrace-style tracing tool for Linux based on the extended BPF capabilities.
- BCC: A framework for interacting with the Linux BPF system.
vltrace
: A syscall tracing tool leveraging eBPF for tracing kernel behavior.
Examples:
- Using
bpf_trace
to track the execution of BPF programs and identify performance bottlenecks. - Utilizing
bcc
to monitor and analyze the performance of network traffic.
References:
- https://github.com/cilium/cilium.io/
- https://github.com/cilium/cilium.io/
- https://github.com/cilium/cilium.io/
- https://github.com/cilium/cilium.io/
Reporting and Diagnosis
The project provides tools to assist in automatic detection of common problems and collection of information for bug reports. These tools can help streamline the debugging process and provide valuable insights.
References:
Contributing
The Cilium project welcomes contributions from the community. To contribute, refer to the project’s contribution guidelines.
References:
Top-Level Directory Explanations
src/ - This directory contains the source code for the Cilium project.
src/components/ - This directory contains components used in the project.
src/hooks/ - This directory contains hooks used in the project.
src/layouts/ - This directory contains the layouts used for the project’s website.
src/pages/ - This directory contains the pages for the project’s website.