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 envvar GOOGLE_CHRONICLE_INSTANCE_ID for tests #12536

Merged
merged 4 commits into from
Dec 18, 2024
Merged

Conversation

roaks3
Copy link
Contributor

@roaks3 roaks3 commented Dec 10, 2024

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.


@roaks3 roaks3 requested review from a team and shuyama1 and removed request for a team December 10, 2024 16:23
.ci/gcb-generate-diffs-new.yml Outdated Show resolved Hide resolved
@@ -16,6 +16,7 @@ var ccEnvironmentVariables = [...]string{
"GOCACHE",
"GOPATH",
"GOOGLE_BILLING_ACCOUNT",
"GOOGLE_CHRONICLE_INSTANCE_ID",
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this is backward-compatible. It seems the current change requires all PRs to rebase to include the updates in the cloud build configuration .yml file. Otherwise, the build process might fail due to the missing environment variable GOOGLE_CHRONICLE_INSTANCE_ID.

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 you could be right, but I don't know enough about how this is set up. Could you elaborate a bit? Is there a set of .ci functionality that runs off of main, and needs to be updated as a "step 1"? (also, is any of this documented for me to get clarification on my own?)

Copy link
Member

Choose a reason for hiding this comment

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

Among the files modified, .ci/gcb-pr-downstream-generation-and-test.yml (we usually call it the generate-diff job) is the only one that runs off the PR branch's head. The previously used .ci/gcb-generate-diffs-new.yml file has already been removed and replaced with this new configuration, we can safely remove it from this PR. This behavior occurs because the Cloud Build trigger is configured to respond to pull request events, invoking the configuration file from the PR branch.

In contrast, other YAML files are for triggers working directly with the main branch and can immediately adapt to code changes once merged.

For the generate-diff job, the Magician code should sync at the beginning of execution. Therefore, any updates to the Magician source code take immediate effect for all PRs once the change is merged.

To ensure backward compatibility when introducing a new environment variable, we generally have two options:

  1. Split the change in two PRs.

    • The first PR updates the configuration yml file
    • The second PR updates the Magician source code.
    • Allow a soak period after merging the first PR to ensure most PRs already have the updated configuration checked in before merging the second PR.
  2. Make the source code backward compatible

    • Currently, the Magician checks for existence of all env variables, as seen in this code: 

    env := make(map[string]string, len(ttvEnvironmentVariables))
    for _, ev := range ttvEnvironmentVariables {
    	val, ok := os.LookupEnv(ev)
    	if !ok {
    		return fmt.Errorf("did not provide %s environment variable", ev)
    	}
    	env[ev] = val
    }
    

    (https://github.com/GoogleCloudPlatform/magic-modules/blob/main/.ci/magician/cmd/test_terraform_vcr.go#L108-L115)

    • To add a new env var without breaking existing functionality, we should make an exception for the new variable, ensuring it does not trigger an error if it is missing. This approach allows the change to take effect immediately for PRs rebased off main after the change is merged.

I hope this helps clarify things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be updated now with optional env vars, thanks for the help!

@roaks3 roaks3 force-pushed the add-chronicle-envvar branch from bed3d1f to 7677564 Compare December 17, 2024 17:49
@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 ( 4 files changed, 32 insertions(+))
google-beta provider: Diff ( 1 file changed, 12 insertions(+))

@roaks3 roaks3 force-pushed the add-chronicle-envvar branch from 7677564 to 9c3df70 Compare December 17, 2024 22:42
@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 ( 4 files changed, 32 insertions(+))
google-beta provider: Diff ( 1 file changed, 12 insertions(+))

@shuyama1
Copy link
Member

It seems the issue is due to permission issues with the secret value. I've granted access to the relevant service accounts and will retry now.

/gcbrun

@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 ( 4 files changed, 32 insertions(+))
google-beta provider: Diff ( 1 file changed, 12 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 4370
Passed tests: 3951
Skipped tests: 415
Affected tests: 4

Click here to see the affected service packages

All service packages are affected

Action taken

Found 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccDataSourceGoogleGkeHubFeature_basic
  • TestAccDataSourceGoogleQuotaInfo_basic
  • TestAccEphemeralServiceAccountKey_basic
  • TestAccSecureSourceManagerInstance_secureSourceManagerInstancePrivatePscBackendExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

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

🔴 Tests failed when rerunning REPLAYING mode:
TestAccDataSourceGoogleGkeHubFeature_basic [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.


🔴 Tests failed during RECORDING mode:
TestAccDataSourceGoogleQuotaInfo_basic [Error message] [Debug log]
TestAccEphemeralServiceAccountKey_basic [Error message] [Debug log]
TestAccSecureSourceManagerInstance_secureSourceManagerInstancePrivatePscBackendExample [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

@roaks3
Copy link
Contributor Author

roaks3 commented Dec 18, 2024

Test failures appear unrelated (same showing in other PRs like #12580)

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.

3 participants