Skip to content

Conversation

@josecelano
Copy link
Member

Summary

Refactors e2e_tests_full.rs to use black-box CLI execution via ProcessRunner, following the same pattern established in issue #199.

Changes

  • Remove internal imports: Eliminated TestContext and direct command_handlers imports
  • Use ProcessRunner: All CLI commands (create, provision, configure, test, destroy) now execute through ProcessRunner
  • Extend ProcessRunner: Added run_configure_command and run_test_command methods
  • Dynamic config generation: Generate environment config at runtime with absolute SSH key paths (required because Ansible runs from build directory)
  • Consistent pattern: Applied same black-box testing approach from issue Refactor e2e_provision_and_destroy_tests to use black-box CLI execution #199

Testing

  • ✅ Pre-commit checks pass
  • ✅ E2E full tests pass (ran twice to verify cleanup works)

Related

- Remove TestContext and direct command_handlers imports
- Use ProcessRunner for all CLI commands (create, provision, configure, test, destroy)
- Add run_configure_command and run_test_command to ProcessRunner
- Generate dynamic environment config with absolute SSH key paths
- Apply same pattern from issue #199 to full E2E lifecycle tests
- Move src/testing/black_box/ to src/testing/e2e/black_box/
- Update module declarations and re-exports
- Update import paths in binaries and tests
- black_box contains E2E testing utilities (ProcessRunner)
- Create src/testing/e2e/black_box/tasks/ module
- Add verify_dependencies.rs with shared function
- Function accepts dependencies slice as parameter
- Remove duplicate implementations from both E2E binaries
- Move process_runner.rs to src/testing/e2e/ (remove black_box wrapper)
- Move tasks/verify_dependencies.rs to src/testing/e2e/tasks/black_box/
- Remove empty black_box directory
- Update all imports and re-exports
- Create preflight_cleanup.rs in src/testing/e2e/tasks/black_box/
- Function removes artifacts from previous test runs
- Remove duplicate implementations from both E2E binaries
- Create generate_config.rs in src/testing/e2e/tasks/black_box/
- Function generates environment config with absolute SSH key paths
- Remove duplicate implementations from both E2E binaries
Extract the duplicate create_environment function from both E2E binaries
into a shared task module at src/testing/e2e/tasks/black_box/create_environment.rs.

This reduces code duplication and keeps the shared E2E task functions
centralized for easier maintenance.
Extract the duplicate provision_infrastructure function from both E2E binaries
into a shared task module at src/testing/e2e/tasks/black_box/provision_infrastructure.rs.

This reduces code duplication and keeps the shared E2E task functions
centralized for easier maintenance.
Extract the duplicate destroy_infrastructure function from both E2E binaries
into a shared task module at src/testing/e2e/tasks/black_box/destroy_infrastructure.rs.

This reduces code duplication and keeps the shared E2E task functions
centralized for easier maintenance.
Extract the validate_deployment function from e2e_tests_full.rs into a
shared task module at src/testing/e2e/tasks/black_box/validate_deployment.rs.

This follows the same pattern as the other extracted functions and keeps
the shared E2E task functions centralized for easier maintenance and
potential reuse.
Extract the configure_services function from e2e_tests_full.rs into a
shared task module at src/testing/e2e/tasks/black_box/configure_services.rs.

This follows the same pattern as the other extracted functions and keeps
the shared E2E task functions centralized for easier maintenance and
potential reuse.
Extract the repeated (runner, environment_name) pattern into a cohesive
E2eTestRunner type that encapsulates:

- The ProcessRunner for CLI command execution
- The environment name for the test session
- A cleanup_on_failure flag to control automatic cleanup

This eliminates the data clump code smell where runner and environment_name
were passed together to 5 different task functions.

Changes:
- Add E2eTestRunner struct with methods for all test tasks
- Add with_cleanup_on_failure() builder method for configuration
- Convert task functions to methods: create_environment, provision_infrastructure,
  configure_services, validate_deployment, destroy_infrastructure
- Remove individual task modules that are now methods
- Update both E2E test binaries to use the new abstraction

The workflow now reads more naturally:
  let test_runner = E2eTestRunner::new("e2e-full")
      .with_cleanup_on_failure(true);
  test_runner.create_environment(&config_path)?;
  test_runner.provision_infrastructure()?;
  test_runner.configure_services()?;
  test_runner.validate_deployment()?;
  test_runner.destroy_infrastructure()?;
@josecelano josecelano self-assigned this Nov 26, 2025
@josecelano
Copy link
Member Author

ACK 0e3ab51

@josecelano josecelano merged commit a692539 into main Nov 26, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor e2e_tests_full to use black-box CLI execution

2 participants