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

fix TestAccFirebaseWebApp_firebaseWebAppFull #9251

Merged
merged 3 commits into from
Nov 14, 2023

Conversation

shuyama1
Copy link
Member

@shuyama1 shuyama1 commented Oct 12, 2023

fixes hashicorp/terraform-provider-google#16164

Release Note Template for Downstream PRs (will be copied)


@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.

Terraform Beta: Diff ( 1 file changed, 1 insertion(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3144
Passed tests 2827
Skipped tests: 316
Affected tests: 1

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
TestAccCloudRunService_cloudRunServiceSqlExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccCloudRunService_cloudRunServiceSqlExample[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@shuyama1
Copy link
Member Author

shuyama1 commented Nov 9, 2023

/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.

Terraform Beta: Diff ( 1 file changed, 1 insertion(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3225
Passed tests 2896
Skipped tests: 329
Affected tests: 0

$\textcolor{green}{\textsf{All tests passed in REPLAYING mode.}}$
View the build log

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a bug in the API. Just to unblock this test, could you change the two instances ofbrowser_key_restrictions to allowed_referrers = []?

@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.

Terraform Beta: Diff ( 1 file changed, 3 insertions(+), 3 deletions(-))

@shuyama1
Copy link
Member Author

shuyama1 commented Nov 9, 2023

new failure is

vcr_utils.go:152: Step 1/4 error: After applying this test step, the plan was not empty.
        stdout:
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        Terraform will perform the following actions:
          # google_apikeys_key.key1 will be updated in-place
          ~ resource "google_apikeys_key" "key1" {
                id           = "projects/ci-test-project-188019/locations/global/keys/tf-test-api-key1csojhfm2gn"
                name         = "tf-test-api-key1csojhfm2gn"
                # (4 unchanged attributes hidden)
              ~ restrictions {
                  + browser_key_restrictions {
                      + allowed_referrers = [
                          + "",
                        ]
                    }
                }
            }
          # google_apikeys_key.key2 will be updated in-place
          ~ resource "google_apikeys_key" "key2" {
                id           = "projects/ci-test-project-188019/locations/global/keys/tf-test-api-key2csojhfm2gn"
                name         = "tf-test-api-key2csojhfm2gn"
                # (4 unchanged attributes hidden)
              ~ restrictions {
                  + browser_key_restrictions {
                      + allowed_referrers = [
                          + "",
                        ]
                    }
                }
            }
        Plan: 0 to add, 2 to change, 0 to destroy.

Looks like the API (google_apikeys_key) doesn't return back the empty list the list with empty strings, nor empty list (tested it locally)

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3225
Passed tests 2896
Skipped tests: 329
Affected tests: 0

$\textcolor{green}{\textsf{All tests passed in REPLAYING mode.}}$
View the build log

@rainshen49
Copy link
Contributor

That is weird. Since the purpose of this test is just to update the apiKeyId on the WebApp, let's remove the restrictions blocks altogether then. I'll look into restoring this test as part of b/310012020

@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.

Terraform GA: Diff ( 1 file changed, 5 insertions(+))
Terraform Beta: Diff ( 1 file changed, 1 insertion(+), 13 deletions(-))

@shuyama1
Copy link
Member Author

shuyama1 commented Nov 10, 2023

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3225
Passed tests 2896
Skipped tests: 329
Affected tests: 0

$\textcolor{green}{\textsf{All tests passed in REPLAYING mode.}}$
View the build log

@shuyama1 shuyama1 requested review from a team, hao-nan-li and NickElliot and removed request for a team and hao-nan-li November 13, 2023 20:55
Copy link
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.

TestAccFirebaseWebApp_firebaseWebAppCustomApiKeyExample appears to be passing while still having the removed block in this test using the wildcard, do we know why the scenarios are different? I assume it's the b/310012020 issue, but the failure above suggests the error happening before an update step was hit, and if the issue is still present in the provider should the test highlighting it still be temporarily changed?

@rainshen49
Copy link
Contributor

The API only checks the the allowed referrers of the API key when trying to update the WebApp entity. On creation, the API key is accepted as-is, which is why TestAccFirebaseWebApp_firebaseWebAppCustomApiKeyExample passed. Therefore, if the user just follows the example code in TestAccFirebaseWebApp_firebaseWebAppCustomApiKeyExample, terraform apply will succeed.

@NickElliot
Copy link
Contributor

NickElliot commented Nov 14, 2023

Sorry, I kept editing my above comment so I think the specific thing I'm asking got missed -- the failure posted above seemed to suggest it was a permadiff being hit before the update case was attempted (i.e. step 1/4 plan was not empty), so all that happened was the initial creation, and the only other difference is the presence of the data.google_firebase_web_app_config source, and a second (but currently unreferenced) apikey.

@rainshen49
Copy link
Contributor

rainshen49 commented Nov 14, 2023

There are two separate failures.

1.TestAccFirebaseWebApp_firebaseWebAppFull updates the api_key_id field of google_firebase_web_app with a mismatched allowed_referrers. TestAccFirebaseWebApp_firebaseWebAppCustomApiKeyExample only creates the google_firebase_web_app with a custom API key, but doesn't update, so it doesn't hit the issue.
2. To fix TestAccFirebaseWebApp_firebaseWebAppFull, I suggested using an empty list for allowed_referrers, but it turns out the google_apikeys_key resource doesn't distinguish between empty list and unset browser_key_restrictions, thus the permadiff in #9251 (comment). You're right that the creation of both google_apikeys_keys happens before the creation of the google_firebase_web_app.

Therefore, the only option at the moment is to make an unrestricted API key for testing updating the api_key_id field of google_firebase_web_app.

Copy link
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.

Ah ok I'm seeing now, the perma-diff happened with an empty field as opposed to a wildcard. Since as you said the point of the test here is to verify the ability to update the API key, LGTM

@shuyama1 shuyama1 merged commit c6f6183 into GoogleCloudPlatform:main Nov 14, 2023
12 checks passed
@shuyama1 shuyama1 deleted the fix_16164 branch November 14, 2023 23:42
davcen pushed a commit to davcen/gcp-magic-modules that referenced this pull request Nov 17, 2023
trodge pushed a commit to trodge/magic-modules that referenced this pull request Nov 27, 2023
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Nov 28, 2023
jialei-chen pushed a commit to jialei-chen/magic-modules that referenced this pull request Nov 29, 2023
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.

Failing test(s): TestAccFirebaseWebApp_firebaseWebAppFull
4 participants