Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add acceptance tests for how provider handles impersonate_service_account argument #11641

Conversation

SarahFrench
Copy link
Contributor

@SarahFrench SarahFrench commented Sep 5, 2024

This PR adds acceptance tests for usage of impersonate_service_account that demonstrate:

  • how the provider behaves when provider configuration arguments come from different sources ( config vs ENVs)
    • There is only a single ENV used for this argument, versus other arguments
  • schema-level validation that's in place, e.g. handling of empty strings
  • use cases: how does this argument impact the providers behaviour in plan/apply

Note: this PR does not include testing usage of impersonate_service_account when using PF-implemented resource/data source as doing this in the context of Firebase (the only service with PF-implemented stuff) is very complex.

Release Note Template for Downstream PRs (will be copied)


@SarahFrench SarahFrench force-pushed the mux-refactor-9-replace-impersonate-service-account-tests branch from 9cf6bd1 to 50c0e6c Compare September 5, 2024 11:41
@modular-magician

This comment was marked as outdated.

2 similar comments
@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@SarahFrench SarahFrench force-pushed the mux-refactor-9-replace-impersonate-service-account-tests branch from 2a23bca to 0c8a3cb Compare September 23, 2024 09:18
@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@SarahFrench SarahFrench force-pushed the mux-refactor-9-replace-impersonate-service-account-tests branch from e1cd694 to 3eb5766 Compare September 23, 2024 15:02
@SarahFrench SarahFrench force-pushed the mux-refactor-9-replace-impersonate-service-account-tests branch from 3eb5766 to a4a04bc Compare September 23, 2024 15:04
@SarahFrench SarahFrench changed the title Add acceptance tests for how provider handles impersonate_service_account argument, remove old unit tests Add acceptance tests for how provider handles impersonate_service_account argument Sep 23, 2024
@modular-magician

This comment was marked as outdated.

2 similar comments
@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

Copy link
Contributor Author

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

Some comments to assist in review

Comment on lines +23 to +25
// Usage
// We need to wait for a non-Firebase resource to be migrated to the plugin-framework to enable writing this test
// "impersonate_service_account controls which service account is used for actions"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think waiting for an 'easier' resource to use would be best - given that Firebase is the only PF-impemented resources/data source available to us and it's Beta-only.

Comment on lines +132 to +133
Config: testAccSdkProvider_impersonate_service_account_testViaFailure(context),
ExpectError: regexp.MustCompile("Error creating Topic: googleapi: Error 403: User not authorized"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error can only arise if Terraform is using the impersonated service account that has no permissions

@modular-magician

This comment was marked as outdated.

1 similar comment
@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@SarahFrench
Copy link
Contributor Author

Some TeamCity builds running these tests:

@SarahFrench SarahFrench marked this pull request as ready for review September 23, 2024 18:07
@SarahFrench
Copy link
Contributor Author

Marking this as ready for review - happy to save merging for after the rewrite is released (will reduce the diffs in this PR) but would be nice to get feedback on the tests in the meantime

I've self-reviewed a little here and have triggered the tests in TeamCity here.

@SarahFrench SarahFrench requested a review from c2thorn September 23, 2024 18:08
Copy link
Member

@c2thorn c2thorn left a comment

Choose a reason for hiding this comment

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

LGTM overall. Can't think of more cases to cover with impersonate_service_account

Copy link
Contributor Author

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

Thanks for the review!

Before merging I'm going to remove these outputs that are unused.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 348 insertions(+), 6 deletions(-))
google-beta provider: Diff ( 6 files changed, 348 insertions(+), 6 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 4098
Passed tests: 3686
Skipped tests: 412
Affected tests: 0

Click here to see the affected service packages

All service packages are affected

$\textcolor{green}{\textsf{All tests passed!}}$

View the build log

@ScottSuarez
Copy link
Contributor

Hi Sarah, this test is failing in teamcity at 50% frequency

https://hashicorp.teamcity.com/test/-2975064263368697375?currentProjectId=TerraformProviders_GoogleCloud_GOOGLE_BETA_NIGHTLYTESTS&expandTestHistoryChartSection=true

I suspect because the actual SA's we are attempting to impersonate do not exist
hashicorp/terraform-provider-google#19741

@SarahFrench
Copy link
Contributor Author

SarahFrench commented Oct 3, 2024

Thanks for letting me know! I'll split the test into two steps and that should ensure the service account is present. Ah the test is already split that way.

That failure is actually related to #11785

niharika-98 pushed a commit to niharika-98/magic-modules that referenced this pull request Oct 7, 2024
Philip-Jonany pushed a commit to Philip-Jonany/magic-modules that referenced this pull request Nov 4, 2024
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.

4 participants