Skip to content

[Bug]: E2E tests fail — CGO_ENABLED override and stale assertions after slog migration #82

Description

@mrhillsman

Bug Description

E2E tests have 6 defects across 3 files that cause 5 test failures (one defect is already fixed locally but not yet merged). The root causes are:

  1. internal/testutil/binary.go hardcoded CGO_ENABLED=0 — The test harness binary builder set CGO_ENABLED=0 for "portability," but go-sqlite3 (a CGO dependency) requires CGO_ENABLED=1. This caused every E2E test to fail because the compiled binary couldn't initialize the audit subsystem. Already fixed locally (line 75 changed from CGO_ENABLED=0 to CGO_ENABLED=1), needs to be committed.

  2. dryrun_test.go:79 — wrong error substring — The test asserts Expect(stderr).To(ContainSubstring("unknown workload")), but the registry error (internal/workloads/registry.go:101) actually says workload "nonexistent" not found. The substring "unknown workload" never appears in the output.

  3. cleanup_test.go:44,82 and fullcycle_test.go:55,93 — output format mismatch after slog migration — Four assertions expect human-readable strings like "1 VMs deleted" or "0 VMs deleted" in stdout. After the migration from fmt.Fprintf to structured slog logging, the actual output is JSON: {"level":"INFO","msg":"cleanup complete","vms_deleted":1,...}. The substring "N VMs deleted" no longer appears.

Steps to Reproduce

# From repo root, with a connected cluster:
CGO_ENABLED=1 go test -count=1 -tags e2e -timeout 600s ./tests/e2e/...

Expected Behavior

All E2E tests pass (18/18).

Actual Behavior

5 tests fail:

Test File:Line Assertion Actual Output
should fail for unknown workload name dryrun_test.go:79 ContainSubstring("unknown workload") workload "nonexistent" not found; available: ...
should delete all managed resources cleanup_test.go:44 ContainSubstring("1 VMs deleted") {"msg":"cleanup complete","vms_deleted":1,...}
should be idempotent cleanup_test.go:82 ContainSubstring("0 VMs deleted") {"msg":"cleanup complete","vms_deleted":0,...}
should deploy CPU workload... fullcycle_test.go:55 ContainSubstring("1 VMs deleted") {"msg":"cleanup complete","vms_deleted":1,...}
should deploy network workload... fullcycle_test.go:93 ContainSubstring("2 VMs deleted") {"msg":"cleanup complete","vms_deleted":2,...}

Proposed Fix

  1. internal/testutil/binary.go:75 — Change CGO_ENABLED=0CGO_ENABLED=1.

  2. dryrun_test.go:79 — Change assertion to match actual registry error:

    Expect(stderr).To(ContainSubstring("workload not found"))
  3. cleanup_test.go and fullcycle_test.go — Update 4 assertions to match structured slog JSON output. Either:

    • Assert on the JSON key: ContainSubstring("vms_deleted") plus a count check, or
    • Assert on the slog message: ContainSubstring("cleanup complete")

Additional Context

  • The slog migration (from fmt.Fprintf to internal/logging.NewLogger()) was applied to cmd/virtwork/main.go but the E2E test expectations were not updated to match.
  • The stale comment on binary.go:30 still says "built with CGO_ENABLED=0 for portability" — should be updated to reflect CGO_ENABLED=1 and the go-sqlite3 requirement.
  • 13 of 18 E2E tests pass after the CGO fix alone; only these 5 string-mismatch failures remain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.size/MDenotes a PR that changes 30-99 lines, ignoring generated files.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    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