Skip to content

test(e2e): embed short commit SHA in cli-e2e- prefix#842

Draft
natalie-o-perret wants to merge 1 commit into
masterfrom
test/e2e-prefix-sha
Draft

test(e2e): embed short commit SHA in cli-e2e- prefix#842
natalie-o-perret wants to merge 1 commit into
masterfrom
test/e2e-prefix-sha

Conversation

@natalie-o-perret

Copy link
Copy Markdown
Contributor

Description

PR #841 made the cli-e2e- prefix the single source of truth for naming API e2e test resources. This PR embeds the short commit SHA of the CLI repo into the prefix so any leaked resource in the portal can be traced straight back to the commit that created it.

Concrete change: TEST_RUN_ID is now cli-e2e-<short-sha>-<unix>-<rand6> instead of cli-e2e-<unix>-<rand6>. So an NLB is now named cli-e2e-abc1234-1717000000-xyz789-nlb-a. On git log for abc1234 you get the commit; on that commit's page, you get the PR.

The SHA is resolved at test startup with git rev-parse --short HEAD. If git is not on PATH or the working copy is not inside a git repository, the helper returns unknown and the prefix stays well-formed rather than failing the suite.

Related issue

Follow-up to #841.

Changes

  • tests/e2e/testscript_api_test.go: runID now includes the short SHA. Added a shortSHA helper that walks up to find the repo root and shells out to git. Falls back to unknown on failure.
  • tests/e2e/README.md: documents the new cli-e2e-<short-sha>-<unix>-<rand6> shape.
  • CHANGELOG.md: entry under Unreleased.

Checklist

  • Changelog updated (Unreleased block)
  • Testing

Testing

  • go vet ./... and go vet -tags=api ./... from tests/e2e/ pass.
  • go build ./... and go build -tags=api ./... from tests/e2e/ pass.
  • Smoke-tested the shortSHA helper standalone in a one-off Go program; returned the expected 8-char SHA (git returns longer than 7 chars when the 7-char prefix is ambiguous).

I have not run the actual -tags=api scenarios because they need EXOSCALE_API_KEY and EXOSCALE_API_SECRET. CI is the source of truth for the full run.

Notes for reviewers

  • Name length: with the SHA the prefix is up to ~31 chars including the descriptor suffix. Exoscale's NLB name limit is 255 chars, instance name limit is 255, PG service name limit is 63. All safe.
  • git rev-parse --short is intentionally left unconstrained on length. Git will return 7 chars by default and grow the short form automatically if 7 chars are ambiguous, which is the right behaviour.
  • The unknown fallback is for environments where git is not installed (e.g. some minimal CI images). The cli-e2e- prefix is preserved in that case, so collision protection from test(e2e): prefix all API test resource names with cli-e2e- #841 still works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant