Skip to content

[Tech Debt]: Extract orchestration logic from runE/cleanupE for testability #123

Description

@mrhillsman

Category

Missing tests

Description

runE is ~450 lines handling config loading, audit init, workload planning, service creation, secret creation, VM creation, readiness waiting, and summary printing. cleanupE is ~140 lines with similar breadth. These are the riskiest functions in the codebase and the hardest to test.

All internal packages have 84-96% coverage, but cmd/virtwork sits at 1.3%. The E2E tests provide some coverage but require a live cluster. There are no unit-level tests for the orchestration logic.

Severity

High — actively causes silent failures or blocks development

Affected Files

  • cmd/virtwork/main.gorunE function (~450 lines, 0% unit test coverage)
  • cmd/virtwork/main.gocleanupE function (~140 lines, 0% unit test coverage)

Proposed Fix

Extract the orchestration logic into a testable internal package (e.g., internal/orchestrator) that takes interfaces for client, auditor, and logger. Break runE into smaller functions: planVMs(), createServices(), createSecrets(), createVMs(), waitForReadiness(). The cmd layer becomes a thin shell that parses flags and calls the orchestrator.

This also addresses the function length concern — the current monolithic runE violates Go best practices for function complexity.

Area: CLI / Configuration, Testing
Architecture Layer: Layer 4 - Orchestration (cmd, cleanup)

Metadata

Metadata

Assignees

No one assigned

    Labels

    size/XXLDenotes a PR that changes 1000+ lines, ignoring generated files.tech-debtTechnical debt, code quality, or maintenance concern

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions