Skip to content

Fail if using SKIP_ env vars while running multiple parallel tests #1280

Open
@Octogonapus

Description

I recognize this is user error, but I ran into a problem where I accidentally ran multiple parallel tests locally using a SKIP_ environment variable, so all these tests ran against the same Terraform directory and broke each other. You get very weird and concerning error messages like:

TestFoo 2023-05-02T11:08:37-04:00 logger.go:66: │ Error: Failed to download module
TestFoo 2023-05-02T11:08:37-04:00 logger.go:66: │ 
TestFoo 2023-05-02T11:08:37-04:00 logger.go:66: │ Could not download module "redacted" (redacted.tf:1) source code from
TestFoo 2023-05-02T11:08:37-04:00 logger.go:66: │ "git::https://github.com/redacted/redacted.git?ref=v6.2.1":
TestFoo 2023-05-02T11:08:37-04:00 logger.go:66: │ error downloading
TestFoo 2023-05-02T11:08:37-04:00 logger.go:66: │ 'https://github.com/redacted/redacted.git?ref=v6.2.1':
TestFoo 2023-05-02T11:08:37-04:00 logger.go:66: │ /usr/bin/git exited with -1: Cloning into '.terraform/modules/redacted'...
TestFoo 2023-05-02T11:08:37-04:00 logger.go:66: │ BUG: refs/files-backend.c:3040: initial ref transaction called with
TestFoo 2023-05-02T11:08:37-04:00 logger.go:66: │ existing refs

This was an easy mistake for me to make because I have tests like TestFoo and TestFooBadDeployment, etc. I wanted to run only TestFoo, so I ran SKIP_teardown=1 go test -v -timeout 60m -run TestFoo, but of course this ran (effectively) TestFoo*.

Perhaps a lock file could be written inside the .test-data directory? Then other parallel tests could try to make the same lock file and fail.

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestp:needs triageNeeds to be processed by maintainer and issue type / priority added

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions