Skip to content

fix(bigqueryanalyticshub): pass token source to BigQuery client in multi region listing#16236

Merged
NickElliot merged 2 commits into
GoogleCloudPlatform:mainfrom
okvidhi:fix-multiregion-auth-bug
Feb 3, 2026
Merged

fix(bigqueryanalyticshub): pass token source to BigQuery client in multi region listing#16236
NickElliot merged 2 commits into
GoogleCloudPlatform:mainfrom
okvidhi:fix-multiregion-auth-bug

Conversation

@okvidhi
Copy link
Copy Markdown
Contributor

@okvidhi okvidhi commented Jan 27, 2026

Description
This PR fixes an authentication bug in the BigQuery Analytics Hub multi-region acceptance tests that caused failures.

The multi-region support for Listings and Subscriptions requires custom bootstrapping to create BigQuery dataset replicas via the Go client library before the Terraform tests can run. In environments where Application Default Credentials (ADC) are not locally present on the disk, the standalone BigQuery client was unable to authenticate

Bug Details
The tests TestAccBigqueryAnalyticsHubListingSubscription_multiregion and TestAccBigqueryAnalyticsHubListing_multiregion failed with the following error during the bootstrapping phase:
resource_bigquery_analytics_hub_listing_subscription_test.go:72: Failed to create BigQuery dataset and add replica: failed to create BigQuery client: bigquery: constructing client: credentials: could not find default credentials. See https://cloud.google.com/docs/authentication/external/set-up-adc for more information

Fix Details
The fix ensures that the bootstrapping code uses the exact same authenticated TokenSource and User Agent as the Terraform provider itself.

Updated AddBigQueryDatasetReplica and CleanupBigQueryDatasetAndReplica in bootstrap_test_utils.go.tmpl to accept t *testing.T and initialize the BigQuery client using the provider's TokenSource.
Updated the test templates to correctly pass the test object t to these helper functions.

References
Fixes https://buganizer.corp.google.com/issues/478720548 , https://buganizer.corp.google.com/issues/478719495

Supersedes logic from PR #16156

See Write release notes for guidance.

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jan 27, 2026
@github-actions github-actions Bot requested a review from NickElliot January 27, 2026 06:14
@github-actions
Copy link
Copy Markdown

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@NickElliot, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@github-actions
Copy link
Copy Markdown

@NickElliot This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@modular-magician modular-magician added service/bigquery and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Jan 29, 2026
@modular-magician
Copy link
Copy Markdown
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 ( 1 file changed, 13 insertions(+), 4 deletions(-))
google-beta provider: Diff ( 3 files changed, 17 insertions(+), 8 deletions(-))

@modular-magician
Copy link
Copy Markdown
Collaborator

🔴 The provider crashed while running the VCR tests in REPLAYING mode
Please fix it to complete your PR.
View the build log

@okvidhi
Copy link
Copy Markdown
Contributor Author

okvidhi commented Jan 31, 2026

Hey @wj-chen @NickElliot , are these fails related to our change?

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jan 31, 2026
@okvidhi
Copy link
Copy Markdown
Contributor Author

okvidhi commented Jan 31, 2026

Hey, can anyone run the VCR tests again please?

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

@GoogleCloudPlatform/terraform-team @NickElliot This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

@wj-chen
Copy link
Copy Markdown
Member

wj-chen commented Feb 2, 2026

I also don't have permission to trigger test runs. @NickElliot could you review?

@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Feb 2, 2026
@modular-magician
Copy link
Copy Markdown
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 ( 1 file changed, 44 insertions(+), 17 deletions(-))
google-beta provider: Diff ( 3 files changed, 48 insertions(+), 21 deletions(-))

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 5986
Passed tests: 5351
Skipped tests: 633
Affected tests: 2

Click here to see the affected service packages

All service packages are affected

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccAccessContextManager__service_perimeter_dry_run_egress_policy
  • TestAccAccessContextManager__service_perimeter_dry_run_ingress_policy

Get to know how VCR tests work

@modular-magician
Copy link
Copy Markdown
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccAccessContextManager__access_level [Debug log]
TestAccAccessContextManager__access_level_condition [Debug log]
TestAccAccessContextManager__access_level_custom [Debug log]
TestAccAccessContextManager__access_level_full [Debug log]
TestAccAccessContextManager__access_levels [Debug log]
TestAccAccessContextManager__access_policy [Debug log]
TestAccAccessContextManager__access_policy_scoped [Debug log]
TestAccAccessContextManager__authorized_orgs_desc [Debug log]
TestAccAccessContextManager__service_perimeter [Debug log]
TestAccAccessContextManager__service_perimeter_dry_run_egress_policy [Debug log]
TestAccAccessContextManager__service_perimeter_dry_run_ingress_policy [Debug log]
TestAccAccessContextManager__service_perimeter_update [Debug log]
TestAccAccessContextManager__service_perimeters [Debug log]

🔴 Tests failed when rerunning REPLAYING mode:
TestAccAccessContextManager__service_perimeter_dry_run_egress_policy [Error message] [Debug log]

Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made.

Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer.


🟢 All tests passed!

View the build log or the debug log for each test

@okvidhi
Copy link
Copy Markdown
Contributor Author

okvidhi commented Feb 3, 2026

I feel the fail - TestAccAccessContextManager__service_perimeter_dry_run_egress_policy is not related to our changes.Can anyone review my PR please @wj-chen @NickElliot

Copy link
Copy Markdown
Contributor

@NickElliot NickElliot left a comment

Choose a reason for hiding this comment

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

LGTM!

wuchris-g pushed a commit to wuchris-g/magic-modules that referenced this pull request Feb 5, 2026
JianweiQ pushed a commit to JianweiQ/magic-modules that referenced this pull request Feb 20, 2026
kapoorne-g pushed a commit to kapoorne-g/magic-modules that referenced this pull request Feb 24, 2026
kefang2 pushed a commit to kefang2/magic-modules that referenced this pull request Feb 28, 2026
aditikumarii-google pushed a commit to aditikumarii-google/magic-modules that referenced this pull request Mar 10, 2026
ChuAmberZhang pushed a commit to ChuAmberZhang/magic-modules that referenced this pull request Apr 29, 2026
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.

4 participants