Repository navigation
Enhancement | Hermetic bats tests for the tofu/terraform layer lifecycle - #347
Conversation
Run init, plan, apply, output and destroy against the real binaries, on a single layer and with --layers, with no cloud access: the layers use the local backend and the built-in terraform_data resource. Covers exit code passthrough (-detailed-exitcode), tfvars and backend config injection, --layers order and fail-fast, the usage errors, and that no AWS credentials are touched when SSO and MFA are off. Relates to #346 (H5). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 22 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Coverage Report for CI Build 43610001772Coverage remained the same at 67.689%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
Sabotage check in CI: #348 (closed, not merged) dropped the tfvars and Result in
The 4 that kept passing (15–18) cover error paths that do not depend on the injection. The ref-arch E2E triggered by that PR was cancelled before it reached AWS. |
What?
tests/bats/leverage_tofu_lifecycle.bats: 10 tests that runinit → plan → apply → output → destroyagainst the real tofu and terraform binaries, with no cloud access. The layers use thelocalbackend and the built-interraform_dataresource._create_local_backend_projecthelper totests/bats/utils.bash.make test-intalready picks up every file undertests/bats, and the job already installs tofu and terraform.The tests cover:
plan -detailed-exitcodeexits2 → 0 → 2around apply/destroy, and the CLI passes it through. Runs with tofu and with terraformcommon.tfvars+account.tfvarsreach the layer (outputts-account-first);-backend-configis applied (the state lands at thepathfrombackend.tfvars)--layers--layersinside a layer, a missing layer, and the layout validation oninitall exit1HOMEis isolated in a temp dirThe new file adds ~12 s to the bats job.
Why?
H5 in #346. The unit tests mock
TFRunner.run, and the ref-arch E2E needs AWS secrets, so it skips forks. Until now, nothing ran the realinit/plan/applycycle or--layerson every PR.To check the tests catch real breakage, I dropped the tfvars and
-backend-configinjection fromtf.py: 6 of the 10 tests fail. The other 4 cover error paths that do not depend on injection.Notes
leverage terraform initfails when the project path crosses a symlink ($TMPDIRis under/var→/private/var). Terraform turns the-backend-configpath into a relative one from the real cwd, and ends up one../short. Tofu is not affected. The helper resolves the path withpwd -P. Linux CI is not affected either.Relates to #346
🤖 Generated with Claude Code