Skip to content

Fix E2E Infrastructure Preservation #21

@josecelano

Description

@josecelano

Fix E2E Infrastructure Preservation

Type: Task
Priority: High
Parent Epic: #10 - UI Layer Destroy Command
Estimated Effort: 1-2 hours


📋 Issue Overview

Restore the --keep flag functionality in E2E test binaries to preserve infrastructure for manual testing workflows. This is a prerequisite for testing the destroy CLI command implementation.

🎯 Problem Statement

During E2E binary refactoring, the new run_infrastructure_destroy function doesn't respect the --keep CLI argument. This breaks the ability to preserve test infrastructure for manual verification, which is essential for testing the destroy CLI command.

Current Broken Workflow

# This should preserve infrastructure but doesn't
cargo run --bin e2e-tests-full -- --keep
cargo run --bin e2e-provision-and-destroy-tests -- --keep

# Infrastructure gets destroyed despite --keep flag

Required Manual Testing Workflow

# 1. Provision infrastructure and keep it
cargo run --bin e2e-provision-and-destroy-tests -- --keep

# Verify infrastructure is preserved
ls data/e2e-provision/          # Should exist
ls build/e2e-provision/         # Should exist
lxc list | grep e2e-provision   # Should show VM running

# 2. Manually test destroy CLI command (when implemented)
torrust-tracker-deployer destroy e2e-provision

# 3. Verify complete cleanup using LXD commands (see docs/tech-stack/lxd.md)
ls data/e2e-provision/          # Should not exist
ls build/e2e-provision/         # Should not exist  
lxc list | grep e2e-provision   # Should return nothing (VM destroyed)

🎯 Goals

  1. Fix --keep flag functionality in both E2E test binaries
  2. Ensure run_infrastructure_destroy function respects the keep parameter
  3. Enable reliable manual testing workflow for destroy CLI command
  4. Maintain existing E2E test behavior when --keep is not used

📦 Scope

Files to Fix

  • src/bin/e2e_tests_full.rs - Main E2E test binary
  • src/bin/e2e_provision_and_destroy_tests.rs - Provision/destroy E2E binary
  • Any helper functions that handle infrastructure cleanup

✅ Acceptance Criteria

Functional Requirements

  • --keep flag in e2e_tests_full.rs preserves infrastructure as intended
  • --keep flag in e2e_provision_and_destroy_tests.rs preserves infrastructure as intended
  • run_infrastructure_destroy function respects the keep parameter correctly
  • Manual testing workflow works:
    • Run E2E test with --keep → infrastructure preserved (data/, build/, LXD VM)
    • Can manually test destroy CLI command on preserved infrastructure
    • Can verify complete cleanup after manual destroy command using LXD commands
    • LXD VM verification works: lxc list | grep e2e-provision shows VM when preserved, nothing when destroyed
  • All E2E tests still pass when --keep flag is not used (default behavior unchanged)

Testing Requirements

  • Unit tests for CLI argument parsing with --keep flag

  • Integration test verifying infrastructure preservation

  • E2E test verifying default destruction behavior (no --keep)

  • Manual testing verification:

    # Test with --keep
    cargo run --bin e2e-provision-and-destroy-tests -- --keep
    # Verify infrastructure exists in data/ and build/
    lxc list | grep e2e-provision  # Should show VM running
    
    # Test without --keep (default)
    cargo run --bin e2e-provision-and-destroy-tests
    # Verify infrastructure is cleaned up
    lxc list | grep e2e-provision  # Should return nothing

🔗 Related Issues

📚 Related Documentation


Full specification: See docs/issues/fix-e2e-infrastructure-preservation.md

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions