Skip to content

test: local-creds helper for acceptance runs#545

Merged
natalie-o-perret merged 2 commits into
masterfrom
feat/local-creds-helper
Jun 5, 2026
Merged

test: local-creds helper for acceptance runs#545
natalie-o-perret merged 2 commits into
masterfrom
feat/local-creds-helper

Conversation

@natalie-o-perret

@natalie-o-perret natalie-o-perret commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

Local helper for running acceptance tests against real infra. Mirrors exoscale/cli#837. Reads ~/.config/exoscale/exoscale.toml, sets the creds via t.Setenv, defaults TF_ACC=1 (pre-set is respected).

go test -tags=local_integration -run TestDatabaseLocal \
  -account=owner-production -timeout 60m ./pkg/resources/database/
  • pkg/testutils/localcreds.go: LoadLocalCreds(t, account).
  • 9 pkg/resources/<pkg>/local_test.go (build local_integration): TestXxxLocal per package, wraps the existing TestXxx. Legacy exoscale/ left out, no single entry.
  • README.md: short note in Contributing pointing at the helper, so new contributors know they don't need to export creds by hand.

Build, vet, gofmt, unit tests clean. Smoke tested with a fake exoscale.toml, env vars land correctly, TF_ACC default and override both work.

Checklist

(For exoscale contributors)

  • Changelog updated (under Unreleased block)
  • Acceptance tests OK
  • For a new resource, datasource or new attributes: acceptance test added/updated

Testing

make test passes. No real-infra run, no creds in this env.

@natalie-o-perret natalie-o-perret force-pushed the feat/local-creds-helper branch from 5107388 to 40ce7e3 Compare June 4, 2026 14:58
@natalie-o-perret

Copy link
Copy Markdown
Contributor Author

[SC-183040]

@natalie-o-perret natalie-o-perret marked this pull request as ready for review June 4, 2026 15:12
@natalie-o-perret natalie-o-perret self-assigned this Jun 4, 2026
Add a build-tagged entry point to every acceptance test package so
contributors can run real-infrastructure tests without exporting
EXOSCALE_API_KEY / EXOSCALE_API_SECRET into the shell, and without
remembering to set TF_ACC=1.

Mirrors exoscale/cli#837. Credentials are read from
$HOME/.config/exoscale/exoscale.toml (same file the CLI uses) and
injected via t.Setenv, scoped to the test. LoadLocalCreds also defaults
TF_ACC to "1" when unset; a pre-set value is respected.

- pkg/testutils/localcreds.go: LoadLocalCreds(t, account) helper. No
  build tag, but only invoked from build-tagged _test.go files, so CI
  never sees it.
- pkg/resources/<pkg>/local_test.go (build local_integration): one
  TestXxxLocal per package that loads creds and forwards to the
  existing TestXxx entry point. 9 packages covered; the legacy
  exoscale/ package has no single entry point and is left out
  (callers can still use LoadLocalCreds directly there).

Usage:
  go test -tags=local_integration -run TestDatabaseLocal \
    -account=owner-production -timeout 60m ./pkg/resources/database/
@natalie-o-perret natalie-o-perret force-pushed the feat/local-creds-helper branch from 40ce7e3 to 8dfe099 Compare June 4, 2026 15:15

@kobajagi kobajagi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legit 👍

Comment thread pkg/testutils/localcreds.go Outdated
LoadLocalCreds hardcoded $HOME/.config/exoscale/exoscale.toml, which is
the Linux XDG path. The CLI uses os.UserConfigDir(), so on macOS the
config actually lives at ~/Library/Application Support/exoscale/ and
the helper would not find it. Mirrors the CLI lookup instead.

Also honour $EXOSCALE_CONFIG, same as the CLI's -C/--config flag.
@natalie-o-perret natalie-o-perret merged commit 79657c6 into master Jun 5, 2026
2 of 3 checks passed
@natalie-o-perret natalie-o-perret deleted the feat/local-creds-helper branch June 5, 2026 15:10
natalie-o-perret added a commit that referenced this pull request Jun 8, 2026
## Summary

Backfill the `Unreleased` block in `CHANGELOG.md` with natalie's PRs
merged since v0.69.2 (2026-05-05) that were missing.

## Related issue

None.

## Changes

Add the following to the existing `## Unreleased` block in
`CHANGELOG.md`:

### IMPROVEMENTS
- test: local-creds helper for acceptance runs #545

### BUG FIXES
- fix(compute_instance): suppress user_data diffs for pre-encoded input
#518
- fix(security-group-rule): allow portless protocols (ESP, AH, GRE,
IPIP) #531
- fix(template): fall back to private visibility when name lookup
returns not found #532

### FEATURES
- feat(dbaas): add exoscale_dbaas_valkey_user resource #528

## Checklist

* [x] Changelog updated (under *Unreleased* block)
* [ ] Acceptance tests OK (not applicable, docs only)

## Notes for reviewers

Entries for other merged PRs since 0.69.2 (#533 by @imiric) are missing.
Not added here per scope; left for the relevant author or release
manager.

---------

Co-authored-by: Ivan Mirić <1009277+imiric@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants