Skip to content

Conversation

@SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Nov 11, 2025

Following #37569, this PR demonstrates that these commands work when pluggable state storage is in use:

  • state identities
  • state list
  • state mv
  • state replace-provider
  • state rm
  • state pull
  • state push
  • state show

This PR mostly implements integration tests, but adds E2E tests for state list and state show.

Target Release

N/A

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Nov 11, 2025
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: the test will still need to build the appropriate binary and put it in a folder here that's named appropriately for the platform that is running the test.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: I thought that go build creates the parent directories in the path, so this should not be necessary? I suppose it just means we need to cleanup the directory afterwards rather than just the binary.

Base automatically changed from pss/make-worspace-new-work-with-pss to main November 19, 2025 12:50
@SarahFrench SarahFrench marked this pull request as ready for review November 20, 2025 14:46
@SarahFrench SarahFrench requested a review from a team as a code owner November 20, 2025 14:46
@SarahFrench
Copy link
Member Author

Ooh, actually I'm going to add a non-E2E version of the tests to help with code coverage reporting, moving to draft.

@SarahFrench SarahFrench marked this pull request as draft November 20, 2025 14:47
@SarahFrench SarahFrench changed the title PSS: Add E2E tests showing state subcommands being used with PSS PSS: Add E2E tests showing state show and state list subcommands being used with PSS Nov 21, 2025
@SarahFrench SarahFrench changed the title PSS: Add E2E tests showing state show and state list subcommands being used with PSS PSS: Add E2E and integration tests showing state show and state list subcommands being used with PSS Nov 21, 2025
@SarahFrench SarahFrench changed the title PSS: Add E2E and integration tests showing state show and state list subcommands being used with PSS PSS: Add tests showing state subcommands being used with PSS Nov 21, 2025
@SarahFrench SarahFrench force-pushed the pss/pss-with-state-commands branch 2 times, most recently from 28e61ce to cebf4a5 Compare November 24, 2025 13:11
@SarahFrench SarahFrench marked this pull request as ready for review November 24, 2025 14:49
Copy link
Member Author

Choose a reason for hiding this comment

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

The push command has its own test fixture, versus the shared internal/command/testdata/state-commands-state-store, because it needs a local state file to be the data that's pushed up to the state store.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

My only major question is about the gating of the E2E test, the rest is really minor/nitpicky stuff.

t.Skip("can't run without building a new provider executable")
}

t.Setenv(e2e.TestExperimentFlag, "true")
Copy link
Member

Choose a reason for hiding this comment

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

Why are we setting this to true? I feel like that defeats the original purpose of the flag/variable, which is to avoid running E2E tests by default during go test ./...

Copy link
Member Author

Choose a reason for hiding this comment

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

When the e2e.GoBuild method on L140 builds the Terraform binary it uses this ENV to decide if the binary should be built with experiments enabled or not:

if exp := os.Getenv(TestExperimentFlag); exp != "" && exp != "false" {
args = append(args, "-ldflags", "-X 'main.experimentsAllowed=yes'")
}

It looks like this was added in the context of the Search project ~5 months ago.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: I thought that go build creates the parent directories in the path, so this should not be necessary? I suppose it just means we need to cleanup the directory afterwards rather than just the binary.

@SarahFrench SarahFrench force-pushed the pss/pss-with-state-commands branch from bd6f62e to 3af7596 Compare December 4, 2025 21:25
Comment on lines 450 to 451
mockProviderAddress := addrs.NewDefaultProvider("test")
providerSource, close := newMockProviderSource(t, map[string][]string{
"hashicorp/test": {"1.0.0"},
})
defer close()

Copy link
Member Author

Choose a reason for hiding this comment

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

Context: I realised that in lots of tests for PSS I've been adding this provider source value into the Meta in tests. Provider sources are only needed in the context of an init command, so providing them in these tests is unnecessary.

Similarly there are times where supplying both a View and Ui is unnecessary, and some commands need a Stream. I guess this reflects how different commands' terminal output is implemented slightly differently (shout out to #37439), and so only some outputs are required in their tests.

@SarahFrench SarahFrench force-pushed the pss/pss-with-state-commands branch from 3af7596 to bb7d519 Compare December 4, 2025 21:51
…mand under test.

This test fixure is reused across tests that need the config to define a state store but otherwise rely on the mock provider to set up the test scenario.
The internal/command/testdata/state-commands-state-store and internal/command/testdata/state-store-unchanged test fixtures are the same.
…using grpcwrap package

This was removed, incorrectly, in #37899
…turned from `mockPluggableStateStorageProvider` and the `MockStates` that's been set in the mock
@SarahFrench SarahFrench force-pushed the pss/pss-with-state-commands branch from bb7d519 to c2d9c42 Compare December 4, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Add this to your PR if the change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants