Repository navigation
Description
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 flagRequired 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
- Fix
--keepflag functionality in both E2E test binaries - Ensure
run_infrastructure_destroyfunction respects thekeepparameter - Enable reliable manual testing workflow for destroy CLI command
- Maintain existing E2E test behavior when
--keepis not used
📦 Scope
Files to Fix
src/bin/e2e_tests_full.rs- Main E2E test binarysrc/bin/e2e_provision_and_destroy_tests.rs- Provision/destroy E2E binary- Any helper functions that handle infrastructure cleanup
✅ Acceptance Criteria
Functional Requirements
-
--keepflag ine2e_tests_full.rspreserves infrastructure as intended -
--keepflag ine2e_provision_and_destroy_tests.rspreserves infrastructure as intended -
run_infrastructure_destroyfunction respects thekeepparameter 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-provisionshows VM when preserved, nothing when destroyed
- Run E2E test with
- All E2E tests still pass when
--keepflag is not used (default behavior unchanged)
Testing Requirements
-
Unit tests for CLI argument parsing with
--keepflag -
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
- Parent Epic: EPIC: UI Layer Destroy Command #10 (UI Layer Destroy Command)
- Blocks: Issue 10.3 (Add Clap Subcommand Configuration) - needs manual testing workflow
📚 Related Documentation
Full specification: See docs/issues/fix-e2e-infrastructure-preservation.md
Activity
feat: [#10] add comprehensive sub-issue specifications for UI Layer D…
josecelano commentedon Oct 22, 2025
✅ Issue Resolved: Feature Already Working
After thorough investigation and comprehensive testing, I can confirm that the
--keepflag functionality is already working correctly and was never broken.🧪 Comprehensive Testing Results
I conducted live testing of both E2E test binaries to verify the functionality:
Test 1: Infrastructure Preservation with
--keep✅Results:
torrust-tracker-vm-e2e-provisionrunning at IP10.140.190.184data/e2e-provision/preserved with environment.json and templatesbuild/e2e-provision/preserved with Ansible and OpenTofu configuration"Keeping test environment as requested (destruction skipped)"lxc exec torrust-tracker-vm-e2e-provision -- /bin/bashTest 2: Normal Destruction (without
--keep) ✅Results:
lxc list)"Destroying test infrastructure"→"Infrastructure destroyed successfully"🔍 Code Analysis: Implementation Already Correct
The implementation in
src/testing/e2e/tasks/virtual_machine/run_destroy_command.rscorrectly handles the--keepflag:Control Flow Verification:
--keepflag viaclap::ParserTestContext::from_environment(cli.keep, ...)keep_env: boolin TestContextrun_destroy_command()checkstest_context.keep_envand returns earlyrun_infrastructure_destroy()callsrun_destroy_command()(preserves behavior)🎯 Required Workflow Now Available
The manual testing workflow described in the issue is fully functional:
📋 Acceptance Criteria Status: All Met ✅
--keepflag in both E2E binaries preserves infrastructurerun_infrastructure_destroyfunction respects thekeepparameter--keep)🎯 Root Cause: Misunderstanding
The original issue appears to have been based on an incorrect assumption. The functionality described as "broken" was actually working correctly all along. The
run_infrastructure_destroyfunction properly delegates torun_destroy_command, which correctly implements the--keeplogic.🎉 Resolution
No code changes are needed. The E2E infrastructure preservation functionality is working as intended and supports the complete manual testing workflow required for destroy CLI command development.
Closing this issue as resolved by verification - the feature works correctly and meets all requirements.
Manual Testing Verified: October 22, 2025
CLI Help Confirmed: Both binaries document the
--keepflag properlyEnd-to-End Workflow: Fully functional for destroy command development
Merge #28: feat: Add destroy subcommand to CLI with UserOutput system
Merge #33: docs: update user documentation for destroy command
chore: remove closed issue documentation files