Skip to content

Conversation

@luckyswaminathan
Copy link
Contributor

@luckyswaminathan luckyswaminathan commented Aug 15, 2025

hashicorp/terraform-provider-google#12595 part of this initiative

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

autogeneration of tests enabled

@luckyswaminathan luckyswaminathan changed the title remake pr autogeneration of tests for singular datasources Aug 15, 2025
@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 ( 3 files changed, 142 insertions(+), 12 deletions(-))
google-beta provider: Diff ( 3 files changed, 142 insertions(+), 12 deletions(-))

@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 ( 3 files changed, 142 insertions(+), 12 deletions(-))
google-beta provider: Diff ( 3 files changed, 142 insertions(+), 12 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 123
Passed tests: 101
Skipped tests: 20
Affected tests: 2

Click here to see the affected service packages
  • iap
  • redis

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
  • TestAccDataSourceIapClient_basic
  • TestAccDataSourceRedisCluster_basic

Get to know how VCR tests work

1 similar comment
@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 123
Passed tests: 101
Skipped tests: 20
Affected tests: 2

Click here to see the affected service packages
  • iap
  • redis

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
  • TestAccDataSourceIapClient_basic
  • TestAccDataSourceRedisCluster_basic

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccDataSourceRedisCluster_basic [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🔴 Tests failed during RECORDING mode:
TestAccDataSourceIapClient_basic [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccDataSourceRedisCluster_basic [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🔴 Tests failed during RECORDING mode:
TestAccDataSourceIapClient_basic [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@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 ( 2 files changed, 77 insertions(+), 12 deletions(-))
google-beta provider: Diff ( 2 files changed, 77 insertions(+), 12 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 35
Passed tests: 35
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • redis

🟢 All tests passed!

View the build log

@luckyswaminathan luckyswaminathan marked this pull request as ready for review August 18, 2025 17:23
@github-actions
Copy link

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.

@melinath, 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 github-actions bot requested a review from melinath August 18, 2025 17:24
Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

Rather than converting a new datasource to have generated tests, could you take a resource that already has a generated datasource and convert its tests?

Ideally, it would be nice to rename the handwritten test file to have the same name as the generated file in a separate PR, then remove the handwritten test file in this PR. That would make the diff easier to review.

autogen_async: true
datasource:
generate: true
generate_tests: true
Copy link
Member

Choose a reason for hiding this comment

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

Given there are only four datasources generated at the moment, could we actually just convert all four in this PR (with simplified diffs) and make that the default behavior, instead of having a generate_tests flag that needs to be set?

Copy link
Contributor Author

@luckyswaminathan luckyswaminathan Aug 18, 2025

Choose a reason for hiding this comment

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

so the problem with this is that there are generatable datasources (ie storagecontrol) that don't have generatable tests, as they only have handrolled tests, so no real way of generating from that template

Copy link
Member

Choose a reason for hiding this comment

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

yeah, we probably want to have an exclude_test attribute that you can set to not generate, similar to the exclude_docs & exclude_test for examples, which defaults to false.

The alternative would be to make generate_test default to true (advantage being that we wouldn't end up with a double-negative) but we generally try to avoid that at the moment (I forget why - maybe hard to tell the difference between "unset" and "set to false"?)

Copy link
Member

Choose a reason for hiding this comment

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

Basically, the default behavior should be "generate tests" since that's what we expect people to do in most cases.

@github-actions github-actions bot requested a review from melinath August 18, 2025 19:25
@luckyswaminathan
Copy link
Contributor Author

Rather than converting a new datasource to have generated tests, could you take a resource that already has a generated datasource and convert its tests?

Ideally, it would be nice to rename the handwritten test file to have the same name as the generated file in a separate PR, then remove the handwritten test file in this PR. That would make the diff easier to review.

I can for certain datasources yeah, I think it might best to keep the flag(so datasources with handrolled resource tests are compatible), but still replacing tests for compatible datasources such as the redis/iapclient ones done in this PR, let me know if you think this isn't the right way

@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 ( 3 files changed, 69 insertions(+), 86 deletions(-))
google-beta provider: Diff ( 3 files changed, 69 insertions(+), 86 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 121
Passed tests: 100
Skipped tests: 20
Affected tests: 1

Click here to see the affected service packages
  • iap
  • redis

Action taken

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

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccDataSourceIapClient_basic [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🟢 All tests passed!

View the build log or the debug log for each test

if err := os.MkdirAll(targetFolder, os.ModePerm); err != nil {
log.Println(fmt.Errorf("error creating parent directory %v: %v", targetFolder, err))
}
targetFilePath := path.Join(targetFolder, fmt.Sprintf("data_source_%s_test.go", t.ResourceGoFilename(object)))
Copy link
Member

Choose a reason for hiding this comment

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

👍 doing this for now so the diff is clearer seems reasonable - we should switch to _generated_test.go in the near future, but that can be in a separate PR.

{{ $fieldName }} = {{ $e.ResourceType $.Res.TerraformName }}.{{ $e.PrimaryResourceId }}.{{ $fieldName }}
{{- end }}
}`,
testAcc{{ $e.TestSlug $.Res.ProductMetadata.Name $.Res.Name }}(context),
Copy link
Member

Choose a reason for hiding this comment

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

We should probably inline the configuration (similar to what IAM tests do) rather than using string formatting - string formatting like this makes it harder to read the final result (both for humans and for the missing test detector).

@github-actions github-actions bot requested a review from melinath August 19, 2025 17:00
@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 ( 3 files changed, 134 insertions(+), 62 deletions(-))
google-beta provider: Diff ( 3 files changed, 134 insertions(+), 62 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 121
Passed tests: 99
Skipped tests: 20
Affected tests: 2

Click here to see the affected service packages
  • iap
  • redis

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
  • TestAccDataSourceIapClient_basic
  • TestAccDataSourceRedisCluster_basic

Get to know how VCR tests work

@melinath
Copy link
Member

I think this is probably working but it's hard to tell because the test runs were interleaved. Rerunning.

/gcbrun

@modular-magician modular-magician added awaiting-approval Pull requests that need reviewer's approval to run presubmit tests and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 27, 2025
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 28, 2025
@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 28, 2025
@modular-magician modular-magician added awaiting-approval Pull requests that need reviewer's approval to run presubmit tests and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 28, 2025
@modular-magician

This comment was marked as outdated.

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 28, 2025
@github-actions github-actions bot requested a review from melinath August 28, 2025 17:37
@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 28, 2025
@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 ( 1 file changed, 24 insertions(+), 19 deletions(-))
google-beta provider: Diff ( 1 file changed, 24 insertions(+), 19 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 103
Passed tests: 79
Skipped tests: 24
Affected tests: 0

Click here to see the affected service packages
  • iap

🟢 All tests passed!

View the build log

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

LGTM, diff looks correct

@melinath melinath added this pull request to the merge queue Aug 28, 2025
Merged via the queue into GoogleCloudPlatform:main with commit d6166b5 Aug 28, 2025
27 of 28 checks passed
NandiniAgrawal15 pushed a commit to NandiniAgrawal15/magic-modules that referenced this pull request Sep 4, 2025
…#14872)

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Sep 26, 2025
…#14872)

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
jkrish-c pushed a commit to jkrish-c/magic-modules that referenced this pull request Oct 14, 2025
…#14872)

Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.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.

3 participants