Skip to content

actions: Add functionality to allow assertions on progress messages returned from invoke #632

@austinvalle

Description

@austinvalle

terraform-plugin-testing version

github.com/hashicorp/terraform-plugin-testing v1.15.0

Use cases

When a Terraform action is being invoked it can send progress messages, which the Terraform UI displays upon receiving: https://github.com/hashicorp/terraform/blob/a47b89170f40e7deaf72e543a86660060f83d4e8/internal/terraform/node_action_trigger_instance_apply.go#L168-L174 .

Since these progress messages are produced by provider action code, it might be desirable to write test assertions against said progress messages with terraform-plugin-testing.

Proposal

Since Terraform doesn't store the action progress messages in any artifact (like the state or plan file), terraform-plugin-testing has limited options for retrieving the progress message.

One potential idea is to grab the action's progress message from the console output (likely via JSON), which we would need to do some decent-size refactoring to achieve with our current setup of testing errors with Config mode, which is what paused the warning assertion work (#69, #17 (comment)).

Another idea is to wrap the provider itself with a test spy to record the actual protocol messages that go between the provider and Terraform as they run, an implementation of this idea was proposed in #570


If you have use-cases for testing progress messages, please share them here!

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions