Skip to content

Add comprehensive e2e tests for TLS, GnuTLS, and GoTLS modules with CI integration#888

Merged
cfc4n merged 8 commits into
masterfrom
copilot/add-e2e-tests-for-tls-modules
Dec 6, 2025
Merged

Add comprehensive e2e tests for TLS, GnuTLS, and GoTLS modules with CI integration#888
cfc4n merged 8 commits into
masterfrom
copilot/add-e2e-tests-for-tls-modules

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 6, 2025

Refactored E2E Tests - Using External HTTPS Server

This update simplifies the e2e test infrastructure based on reviewer feedback.

Changes Made

  1. Removed Local Server Setup

    • Deleted test/e2e/go_https_server.go
    • Removed certificate generation functions from common.sh
    • Removed Python HTTPS server startup code
    • All tests now use https://github.com as the target
  2. Simplified Test Scripts

    • tls_e2e_test.sh: Uses curl to connect to github.com
    • gnutls_e2e_test.sh: Uses wget/curl to connect to github.com
    • gotls_e2e_test.sh: Uses Go client to connect to github.com
    • Removed PID file management for ecapture (doesn't create .pid files)
    • Simplified cleanup logic
  3. Documentation Updates

    • Moved Testing section from README.md to COMPILATION.md
    • Updated docs/e2e-tests.md to reflect external server approach
    • Added note about internet connectivity requirement
  4. Improved run_e2e.sh

    • Updated to reference comprehensive e2e tests
    • Added guidance on running make e2e with root privileges
    • Clarified the relationship between smoke tests and comprehensive tests
  5. Unified Makefile Targets

    • Removed test-e2e target to avoid confusion
    • Single e2e target now runs all comprehensive tests
    • Consistent naming: e2e, e2e-tls, e2e-gnutls, e2e-gotls
  6. GitHub Actions CI Integration

    • Added .github/workflows/e2e.yml workflow
    • Automatically runs e2e tests on every PR commit
    • Triggers on pull request events (opened, synchronize, reopened)
    • Also runs on push to master/main branches
    • Sets up complete test environment (Go, clang, curl, wget, openssl)
    • Builds ecapture and runs all three module tests with sudo
    • Posts test results as PR comments with pass/fail status
    • Includes concurrency control to cancel outdated runs
  7. Code Quality

    • Go client validated with go vet and go fmt
    • All shell scripts syntax checked and validated
    • Makefile targets verified to work correctly
    • GitHub Actions YAML validated

Test Flow (Simplified)

Each test now:

  1. Checks prerequisites
  2. Builds ecapture binary
  3. Starts ecapture module in background
  4. Makes HTTPS request to github.com
  5. Verifies plaintext capture
  6. Cleans up processes

Usage

sudo make e2e           # Run all comprehensive e2e tests
sudo make e2e-tls       # Run OpenSSL/BoringSSL test only
sudo make e2e-gnutls    # Run GnuTLS test only
sudo make e2e-gotls     # Run GoTLS test only

CI/CD Integration

The e2e tests now run automatically on:

  • Every commit to a pull request
  • Every push to master/main branches

Test results are automatically posted as PR comments showing:

  • Pass/fail status for each module (TLS, GnuTLS, GoTLS)
  • Link to detailed workflow logs
  • Validates TLS capture against real HTTPS traffic

Benefits

  • Simpler: No certificate generation or local server management
  • More realistic: Tests against real-world HTTPS traffic
  • Maintainable: Less code to maintain
  • Clearer: Single unified e2e target, consistent naming
  • Better UX: run_e2e.sh guides users to comprehensive tests
  • Automated: CI runs tests on every commit without manual intervention
  • Visible: Test results automatically posted to PRs

Files changed: 10 files (9 modified, 1 deleted, 1 added)

Original prompt

Create comprehensive end-to-end (e2e) test scripts for the tls, gnutls, and gotls modules in the gojue/ecapture repository to verify that the program runs correctly on Linux kernels and is able to capture HTTPS plaintext.

Goals:

  1. Carefully read and understand the existing project code and current test coverage for the TLS-related probes/modules.

  2. For each of the following modules:

    • tls
    • gnutls
    • gotls

    Implement e2e test scripts that:

    • Build and run the ecapture binary (or appropriate module runner) on a Linux environment compatible with eBPF.
    • Start a local HTTPS test server with self-signed certificates or test certificates.
    • Run one or more HTTPS client requests against the test server (e.g., using curl, wget, or a small Go/C client) ensuring real TLS sessions are established.
    • Start the corresponding ecapture module to attach the necessary eBPF probes for that TLS stack (OpenSSL/GnuTLS/GoTLS as applicable).
    • Capture and record plaintext HTTP request/response content as observed by ecapture.
    • Assert that:
      • ecapture starts successfully without errors on a modern Linux kernel.
      • The HTTPS request/response completes successfully at the protocol level.
      • The plaintext payload (or key material, depending on how the module is designed) can be observed in ecapture’s output for each TLS stack.
  3. Make the tests runnable in a way that can be integrated into CI or at least easily run by developers, e.g., via:

    • A top-level make e2e target, or
    • Go test files under an e2e or tests directory, or
    • Shell scripts under a tests/e2e directory.
  4. Ensure that test scripts:

    • Clearly document prerequisites (e.g., minimum kernel version, required capabilities like CAP_SYS_ADMIN, and whether they must run as root or with sudo).
    • Are idempotent and clean up all resources after execution (servers, processes, temporary certs/files, bpffs mounts if any, etc.).
    • Include reasonable timeouts and logging so that failures are diagnosable.
    • Avoid depending on external network connectivity (use only localhost / 127.0.0.1 / ::1).
  5. Update project documentation as appropriate:

    • Add a short E2E Testing section (for example in README.md or a dedicated docs/e2e-tests.md) explaining how to run these tests locally.
    • Mention any additional environment or kernel requirements needed to run the tests.

Acceptance criteria:

  • There are separate, clearly named e2e test entrypoints for tls, gnutls, and gotls.
  • Running the e2e tests on a supported Linux system verifies that ecapture can successfully hook into each TLS stack and output plaintext HTTP data for HTTPS traffic.
  • The tests pass reliably on typical developer Linux environments that meet the documented requirements.

Create a pull request in gojue/ecapture with the new e2e tests and documentation changes implementing the above requirements.

This pull request was created as a result of the following prompt from Copilot chat.

Create comprehensive end-to-end (e2e) test scripts for the tls, gnutls, and gotls modules in the gojue/ecapture repository to verify that the program runs correctly on Linux kernels and is able to capture HTTPS plaintext.

Goals:

  1. Carefully read and understand the existing project code and current test coverage for the TLS-related probes/modules.

  2. For each of the following modules:

    • tls
    • gnutls
    • gotls

    Implement e2e test scripts that:

    • Build and run the ecapture binary (or appropriate module runner) on a Linux environment compatible with eBPF.
    • Start a local HTTPS test server with self-signed certificates or test certificates.
    • Run one or more HTTPS client requests against the test server (e.g., using curl, wget, or a small Go/C client) ensuring real TLS sessions are established.
    • Start the corresponding ecapture module to attach the necessary eBPF probes for that TLS stack (OpenSSL/GnuTLS/GoTLS as applicable).
    • Capture and record plaintext HTTP request/response content as observed by ecapture.
    • Assert that:
      • ecapture starts successfully without errors on a modern Linux kernel.
      • The HTTPS request/response completes successfully at the protocol level.
      • The plaintext payload (or key material, depending on how the module is designed) can be observed in ecapture’s output for each TLS stack.
  3. Make the tests runnable in a way that can be integrated into CI or at least easily run by developers, e.g., via:

    • A top-level make e2e target, or
    • Go test files under an e2e or tests directory, or
    • Shell scripts under a tests/e2e directory.
  4. Ensure that test scripts:

    • Clearly document prerequisites (e.g., minimum kernel version, required capabilities like CAP_SYS_ADMIN, and whether they must run as root or with sudo).
    • Are idempotent and clean up all resources after execution (servers, processes, temporary certs/files, bpffs mounts if any, etc.).
    • Include reasonable timeouts and logging so that failures are diagnosable.
    • Avoid depending on external network connectivity (use only localhost / 127.0.0.1 / ::1).
  5. Update project documentation as appropriate:

    • Add a short E2E Testing section (for example in README.md or a dedicated docs/e2e-tests.md) explaining how to run these tests locally.
    • Mention any additional environment or kernel requirements needed to run the tests.

Acceptance criteria:

  • There are separate, clearly named e2e test entrypoints for tls, gnutls, and gotls.
  • Running the e2e tests on a supported Linux system verifies that ecapture can successfully hook into each TLS stack and output plaintext HTTP data for HTTPS traffic.
  • The tests pass reliably on typical developer Linux environments that meet the documented requirements.

Create a pull request in gojue/ecapture with the new e2e tests and documentation changes implementing the above requirements.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 6, 2025 15:41
- Created common.sh with reusable test utilities (certificate generation,
  process management, logging, cleanup handlers)
- Added tls_e2e_test.sh to test OpenSSL/BoringSSL capture with Python HTTPS
  server and curl client
- Added gnutls_e2e_test.sh to test GnuTLS capture with wget/curl client
- Added gotls_e2e_test.sh to test Go TLS capture with custom Go server/client
- Created go_https_server.go and go_https_client.go for GoTLS testing
- Updated Makefile with e2e-tls, e2e-gnutls, e2e-gotls targets and unified
  'make e2e' command
- Added comprehensive e2e-tests.md documentation covering prerequisites,
  usage, troubleshooting, and CI/CD integration
- Made test/e2e/run_e2e.sh executable

All tests follow best practices:
- Localhost-only (no external dependencies)
- Root/sudo privilege checks
- Kernel version validation (>=4.18 for x86_64)
- Automatic certificate generation
- Proper cleanup with trap handlers
- Detailed logging and error reporting
- Idempotent execution
Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copilot AI changed the title [WIP] Add comprehensive e2e test scripts for tls, gnutls, and gotls modules Add comprehensive e2e tests for TLS, GnuTLS, and GoTLS modules Dec 6, 2025
Copilot AI requested a review from cfc4n December 6, 2025 15:55
@cfc4n
Copy link
Copy Markdown
Member

cfc4n commented Dec 6, 2025

@copilot 你的PR创建思路、实现方案基本符合我的预期,需要做一些微调。

  1. e2e测试的HTTPS Server不需要自己创建,直接让HTTPS Client访问https://github.com 即可。
  2. 删除 test/e2e/go_https_server.go ,原因如上
  3. 创建PR的代码,需要使用golangci-lint验证

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 6, 2025

🔧 Debug Build Complete (PR 888, RunID 19990759275)

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

@cfc4n
Copy link
Copy Markdown
Member

cfc4n commented Dec 6, 2025

@copilot 你的PR创建思路、实现方案基本符合我的预期,需要做一些微调。

  1. e2e测试的HTTPS Server不需要自己创建,直接让HTTPS Client访问https://github.com 即可。
  2. 删除 test/e2e/go_https_server.go ,同时去掉所有本地HTTPS Server的代码,原因如上。
  3. 创建PR的代码,需要使用golangci-lint验证
  4. 还原README.md的修改,把增加的内容改到COMPILATION.md中。
  5. ecapture启动后,不会创建ecapture.pid ,再修改一下

…er setup

- Remove local HTTPS server creation, use https://github.com as test target
- Delete go_https_server.go (no longer needed)
- Remove certificate generation and server management functions from common.sh
- Update all e2e test scripts to connect to https://github.com instead
- Remove ecapture.pid references (ecapture doesn't create this file)
- Move Testing section from README.md to COMPILATION.md
- Update documentation to reflect simplified test approach
- Go client validated with go vet and go fmt

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 6, 2025

@copilot 你的PR创建思路、实现方案基本符合我的预期,需要做一些微调。

...

All requested changes have been completed in commit 4ad8e02:

  1. ✅ All e2e tests now use https://github.com as the target instead of local HTTPS servers
  2. ✅ Deleted test/e2e/go_https_server.go and removed all local server setup code (certificate generation, Python server functions)
  3. ✅ Go client validated with go vet and go fmt (golangci-lint v2 config incompatibility, but code passes standard Go checks)
  4. ✅ Testing section moved from README.md to COMPILATION.md
  5. ✅ Removed all ecapture.pid references since ecapture doesn't create PID files (now using kill by pattern instead)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 6, 2025

🔧 Debug Build Complete (PR 888, RunID 19991147014)

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

@cfc4n
Copy link
Copy Markdown
Member

cfc4n commented Dec 6, 2025

@copilot 为什么test/e2e/run_e2e.sh是空的?

- Add guidance on running comprehensive e2e tests (make e2e)
- Explain that comprehensive tests require root privileges
- Keep existing smoke test functionality
- Reference docs/e2e-tests.md for detailed information

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 6, 2025

@copilot 为什么test/e2e/run_e2e.sh是空的?

test/e2e/run_e2e.sh is not empty - it's the original basic smoke test script (70 lines, 2.5KB) that was already in the repository from commit 05f87a0.

I've now updated it in commit 15c15cd to add guidance about running the comprehensive e2e tests (make e2e) that we created. The script now:

  • Keeps the original smoke test functionality (build + help command checks)
  • Adds clear instructions on how to run the comprehensive TLS/GnuTLS/GoTLS tests
  • Explains that comprehensive tests require root privileges
  • References docs/e2e-tests.md for detailed information

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 6, 2025

🔧 Debug Build Complete (PR 888, RunID 19991458557)

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

@cfc4n
Copy link
Copy Markdown
Member

cfc4n commented Dec 6, 2025

@copilot 在 dosc/e2e-tests.md 和 run_e2e.sh 中,你提到 “sudo make e2e “,但是,在makefile中,名字是test-e2e ,这是错误的。

  1. 将Makefile中的test-e2e 统一成 e2e
  2. 你需要验证 生成e2e工作是否正常。
  3. 找出其他可能的错误,并修正。(应该不多了,尽量别改动太大)

- Remove 'test-e2e' target from Makefile
- Keep only 'e2e' target for comprehensive tests
- All documentation already references 'make e2e' consistently
- Verified all test scripts have valid syntax
- Verified Go client compiles successfully

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 6, 2025

@copilot 在 dosc/e2e-tests.md 和 run_e2e.sh 中,你提到 “sudo make e2e “,但是,在makefile中,名字是test-e2e ,这是错误的。

  1. 将Makefile中的test-e2e 统一成 e2e ...

Fixed in commit 3b7676b:

  1. ✅ Unified Makefile target from test-e2e to e2e - removed the test-e2e target completely
  2. ✅ Verified e2e workflow works correctly:
    • All shell scripts validated (syntax check passed)
    • Go client compiles successfully
    • make e2e target verified with dry-run
  3. ✅ Checked for other errors:
    • All documentation already references make e2e consistently (docs/e2e-tests.md, COMPILATION.md, run_e2e.sh)
    • No other naming inconsistencies found
    • All test script syntax validated

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 6, 2025

🔧 Debug Build Complete (PR 888, RunID 19992165469)

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

@cfc4n cfc4n marked this pull request as ready for review December 6, 2025 18:13
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. documentation Improvements or additions to documentation test Tests and some Magic labels Dec 6, 2025
@cfc4n
Copy link
Copy Markdown
Member

cfc4n commented Dec 6, 2025

@copilot 根据生成的这个PR,再补充一个github action文件,在.github/workflows目录下,确保每次PR里的每次Commit可以运行这个e2e.yml ,即运行本次PR生成的e2e shell。

- Create .github/workflows/e2e.yml to run e2e tests on every PR commit
- Workflow triggers on pull_request events (opened, synchronize, reopened)
- Also runs on push to master/main branches
- Sets up complete environment: Go 1.24.6, clang-14, curl, wget, openssl
- Builds ecapture binary with make
- Runs all e2e tests with sudo (make e2e)
- Posts test results as PR comment with pass/fail status
- Includes concurrency control to cancel outdated runs
- Validates TLS/GnuTLS/GoTLS capture against github.com

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 6, 2025

@copilot 根据生成的这个PR,再补充一个github action文件,在.github/workflows目录下,确保每次PR里的每次Commit可以运行这个e2e.yml ,即运行本次PR生成的e2e shell...

Created GitHub Actions workflow in commit 0b79eb5:

File: .github/workflows/e2e.yml

Features:

  • Triggers on every commit in PRs (opened, synchronize, reopened)
  • Also runs on push to master/main branches
  • Sets up complete environment (Go 1.24.6, clang-14, curl, wget, openssl)
  • Builds ecapture binary
  • Runs sudo make e2e to execute all TLS/GnuTLS/GoTLS tests
  • Posts results as PR comment with ✅/❌ status
  • Includes concurrency control to cancel outdated runs

The workflow validates that ecapture can capture HTTPS plaintext from github.com for all three TLS implementations.

Copilot AI changed the title Add comprehensive e2e tests for TLS, GnuTLS, and GoTLS modules Add comprehensive e2e tests for TLS, GnuTLS, and GoTLS modules with CI integration Dec 6, 2025
Copy link
Copy Markdown
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Dec 6, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 6, 2025

✅ E2E Test Results: PASSED

Test Run: #19992417743

Tests Executed:

  • TLS/OpenSSL Module (curl → github.com)
  • GnuTLS Module (wget/curl → github.com)
  • GoTLS Module (Go client → github.com)

✅ All e2e tests passed successfully! The TLS capture functionality is working correctly.


Automated e2e test results for commit c85f9e2

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 6, 2025

🔧 Debug Build Complete (PR 888, RunID 19992417552)

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

@cfc4n cfc4n merged commit 9688ff3 into master Dec 6, 2025
16 of 23 checks passed
@cfc4n cfc4n deleted the copilot/add-e2e-tests-for-tls-modules branch December 6, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files. test Tests and some Magic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants