#4902·chaos-mesh

[LFX Mentorship] Refactor PodChaos and NetworkChaos E2E Tests into Gherkin-based BDD Scenarios

Author: STRRLCreated Apr 27, 2026Updated Aug 4, 2026

Refactor PodChaos and NetworkChaos E2E Tests into Gherkin-based BDD Scenarios

Background

Chaos Mesh has an existing Go-based E2E test suite for validating chaos behavior on Kubernetes. The current tests are effective, but many scenarios mix test intent, fixture setup, Chaos Mesh custom resource creation, probing logic, assertions, and cleanup in Go code.

This makes the E2E suite harder to read and extend, especially for new contributors who need to understand both the user-facing chaos behavior and the underlying Kubernetes test implementation at the same time.

We want to introduce a Gherkin + Godog based BDD layer for selected Chaos Mesh E2E tests. The first migration target should be PodChaos and NetworkChaos, because they cover both pod-level and network-level chaos behaviors and already have meaningful E2E coverage.

Goals

  • Introduce a Godog-based BDD testing layer for Chaos Mesh E2E tests.
  • Migrate all existing PodChaos E2E scenarios into Gherkin feature files backed by Go step definitions.
  • Migrate all existing NetworkChaos E2E scenarios into Gherkin feature files backed by Go step definitions.
  • Reuse existing E2E fixtures and helper logic where possible.
  • Preserve Chaos Mesh-specific behavior details in feature files, such as PodChaos actions, NetworkChaos direction, peer indexes, blocked pairs, slow pairs, and recovery expectations.
  • Document the recommended style for future Gherkin scenarios and Godog step definitions.

Non-goals

  • This project does not migrate every Chaos Mesh E2E test in one step.
  • This project does not remove the existing E2E framework in one step.
  • This project does not change Chaos Mesh runtime behavior.
  • This project does not hide important Chaos Mesh-specific details behind overly generic Gherkin wording.
  • This project does not require every fixture helper to become a public reusable step.

Expected Deliverables

  • A Godog-based BDD test layer that can run Chaos Mesh E2E scenarios from Gherkin feature files.
  • Gherkin feature files for all existing PodChaos E2E scenarios.
  • Gherkin feature files for all existing NetworkChaos E2E scenarios.
  • Go step definitions for common E2E operations, including workload preparation, applying Chaos Mesh custom resources, probing pod/network behavior, checking expected failures or delays, and verifying recovery.
  • Integration with the existing E2E development workflow. The exact command and CI integration can be decided during implementation.
  • Documentation for writing and migrating Chaos Mesh E2E tests with Gherkin and Godog.

Acceptance Criteria

  • PodChaos E2E scenarios can be executed through the new Gherkin + Godog path.
  • NetworkChaos E2E scenarios can be executed through the new Gherkin + Godog path.
  • The migrated scenarios preserve the behavior checked by the existing tests.
  • The new step definitions reuse existing E2E helpers where practical instead of duplicating test infrastructure.
  • The project includes documentation that explains the feature file style, step definition conventions, and migration guidance.

Suggested Implementation Direction

  • Start from one small PodChaos scenario to establish the Godog runner and step registration pattern.
  • Add NetworkChaos scenarios after the basic runner and shared context are stable.
  • Keep feature files close to the current E2E semantics instead of turning them into very high-level user stories.
  • Refactor shared setup and probing logic only when it reduces duplication or makes scenarios easier to maintain.
  • Keep the existing E2E tests available during migration until the new path is proven stable.

References