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

azurerm_api_management fix to pass all acctests #7603

Merged
merged 15 commits into from
Nov 25, 2020

Conversation

yupwei68
Copy link
Contributor

@yupwei68 yupwei68 commented Jul 7, 2020

Fix: #7299

  1. developer_portal certificate keeps being updated, because in read function, when it gets d.Get("hostname_configuration") using key is strings.Lower("DeveloperPortal") instead "developer_portal"

  2. identity.0.type=None causes plan diff not empty, because it'll not be returned back. Fulfill the identity type in schema setting when identity.0.type=None.

  3. When VirtualNetworkType = VirtualNetworkTypeInternal, call sign_in, sign_up, policy service api causes error.

  4. One default custom domain has been ignored because it causes plan refresh diff

  5. key vault acctest needs to separate the steps because it depends on the permission assignment. But permission assignment depends on its identity. So it'll be a cycle dependency. Thus it needs to be separated into 3 steps

test:
=== RUN TestAccAzureRMApiManagement_basic
=== PAUSE TestAccAzureRMApiManagement_basic
=== CONT TestAccAzureRMApiManagement_basic
--- PASS: TestAccAzureRMApiManagement_basic (2751.90s)
=== RUN TestAccAzureRMApiManagement_requiresImport
=== PAUSE TestAccAzureRMApiManagement_requiresImport
=== CONT TestAccAzureRMApiManagement_requiresImport
--- PASS: TestAccAzureRMApiManagement_requiresImport (2500.16s)
=== RUN TestAccAzureRMApiManagement_customProps
=== PAUSE TestAccAzureRMApiManagement_customProps
=== CONT TestAccAzureRMApiManagement_customProps
--- PASS: TestAccAzureRMApiManagement_customProps (2551.24s)
=== RUN TestAccAzureRMApiManagement_complete
=== PAUSE TestAccAzureRMApiManagement_complete
=== CONT TestAccAzureRMApiManagement_complete
--- PASS: TestAccAzureRMApiManagement_complete (1451.06s)
=== RUN TestAccAzureRMApiManagement_signInSignUpSettings
=== PAUSE TestAccAzureRMApiManagement_signInSignUpSettings
=== CONT TestAccAzureRMApiManagement_signInSignUpSettings
--- PASS: TestAccAzureRMApiManagement_signInSignUpSettings (2473.22s)
=== RUN TestAccAzureRMApiManagement_policy
=== PAUSE TestAccAzureRMApiManagement_policy
=== CONT TestAccAzureRMApiManagement_policy
--- PASS: TestAccAzureRMApiManagement_policy (2488.46s)
=== RUN TestAccAzureRMApiManagement_virtualNetworkInternal
=== PAUSE TestAccAzureRMApiManagement_virtualNetworkInternal
=== CONT TestAccAzureRMApiManagement_virtualNetworkInternal
--- PASS: TestAccAzureRMApiManagement_virtualNetworkInternal (2593.72s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultId
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultId
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultId
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultId (3016.47s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultId
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultId
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultId
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultId (2984.86s)
=== RUN TestAccAzureRMApiManagement_identityUserAssigned
=== PAUSE TestAccAzureRMApiManagement_identityUserAssigned
=== CONT TestAccAzureRMApiManagement_identityUserAssigned
--- PASS: TestAccAzureRMApiManagement_identityUserAssigned (2584.16s)
=== RUN TestAccAzureRMApiManagement_identityNoneUpdateUserAssigned
=== PAUSE TestAccAzureRMApiManagement_identityNoneUpdateUserAssigned
=== CONT TestAccAzureRMApiManagement_identityNoneUpdateUserAssigned
--- PASS: TestAccAzureRMApiManagement_identityNoneUpdateUserAssigned (4731.82s)
=== RUN TestAccAzureRMApiManagement_identityUserAssignedUpdateNone
=== PAUSE TestAccAzureRMApiManagement_identityUserAssignedUpdateNone
=== CONT TestAccAzureRMApiManagement_identityUserAssignedUpdateNone
--- PASS: TestAccAzureRMApiManagement_identityUserAssignedUpdateNone (4973.29s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssigned
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssigned
=== CONT TestAccAzureRMApiManagement_identitySystemAssigned
--- PASS: TestAccAzureRMApiManagement_identitySystemAssigned (2417.97s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUpdateNone
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUpdateNone
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUpdateNone
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUpdateNone (4725.02s)
=== RUN TestAccAzureRMApiManagement_identityNoneUpdateSystemAssigned
=== PAUSE TestAccAzureRMApiManagement_identityNoneUpdateSystemAssigned
=== CONT TestAccAzureRMApiManagement_identityNoneUpdateSystemAssigned
--- PASS: TestAccAzureRMApiManagement_identityNoneUpdateSystemAssigned (4483.66s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateNone
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateNone
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateNone
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateNone (5097.89s)
=== RUN TestAccAzureRMApiManagement_identityNoneUpdateSystemAssignedUserAssigned
=== PAUSE TestAccAzureRMApiManagement_identityNoneUpdateSystemAssignedUserAssigned
=== CONT TestAccAzureRMApiManagement_identityNoneUpdateSystemAssignedUserAssigned
--- PASS: TestAccAzureRMApiManagement_identityNoneUpdateSystemAssignedUserAssigned (4758.50s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUserAssigned
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUserAssigned
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUserAssigned
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUserAssigned (2421.46s)

@ghost ghost added the size/XL label Jul 7, 2020
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

Left a few comments inline but this otherwise LGTM 👍

@@ -820,6 +829,11 @@ func flattenApiManagementHostnameConfigurations(input *[]apimanagement.HostnameC
output["host_name"] = *config.HostName
}

// There'll always be a default custom domain with hostName "apim_name.azure-api.net" and Type "Proxy", which should be ignored
if *config.HostName == strings.ToLower(name)+".azure-api.net" && config.Type == apimanagement.HostnameTypeProxy {
Copy link
Contributor

Choose a reason for hiding this comment

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

azure-api.net is only valid in Azure Public - looks like this'll need to be fetched/added to the environments list in Azure/go-autorest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upstream issue opened: Azure/azure-rest-api-specs#10065

@tombuildsstuff tombuildsstuff added this to the v2.18.0 milestone Jul 7, 2020
@yupwei68 yupwei68 closed this Jul 8, 2020
@yupwei68 yupwei68 reopened this Jul 8, 2020
@katbyte katbyte added the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label Jul 9, 2020
@katbyte katbyte modified the milestones: v2.18.0, Blocked Jul 9, 2020
@tombuildsstuff tombuildsstuff added the sdk/requires-upgrade This is dependent upon upgrading an SDK label Jul 10, 2020
@tombuildsstuff
Copy link
Contributor

Dependent on Azure/go-autorest#540

@EklipZgit
Copy link

@tombuildsstuff hey can this get merged? This bug is annoying.

@ghost ghost removed the waiting-response label Sep 15, 2020
@yupwei68
Copy link
Contributor Author

@tombuildsstuff I've rebased to the latest master branch. Thanks for your comments. All tests have passed. Please continue reviewing.

=== RUN TestAccAzureRMApiManagement_basic
=== PAUSE TestAccAzureRMApiManagement_basic
=== CONT TestAccAzureRMApiManagement_basic
--- PASS: TestAccAzureRMApiManagement_basic (2430.77s)
=== RUN TestAccAzureRMApiManagement_requiresImport
=== PAUSE TestAccAzureRMApiManagement_requiresImport
=== CONT TestAccAzureRMApiManagement_requiresImport
--- PASS: TestAccAzureRMApiManagement_requiresImport (2640.95s)
=== RUN TestAccAzureRMApiManagement_customProps
=== PAUSE TestAccAzureRMApiManagement_customProps
=== CONT TestAccAzureRMApiManagement_customProps
--- PASS: TestAccAzureRMApiManagement_customProps (2205.83s)
=== RUN TestAccAzureRMApiManagement_complete
=== PAUSE TestAccAzureRMApiManagement_complete
=== CONT TestAccAzureRMApiManagement_complete
--- PASS: TestAccAzureRMApiManagement_complete (1588.05s)
=== RUN TestAccAzureRMApiManagement_signInSignUpSettings
=== PAUSE TestAccAzureRMApiManagement_signInSignUpSettings
=== CONT TestAccAzureRMApiManagement_signInSignUpSettings
--- PASS: TestAccAzureRMApiManagement_signInSignUpSettings (2177.03s)
=== RUN TestAccAzureRMApiManagement_policy
=== PAUSE TestAccAzureRMApiManagement_policy
=== CONT TestAccAzureRMApiManagement_policy
--- PASS: TestAccAzureRMApiManagement_policy (2793.47s)
=== RUN TestAccAzureRMApiManagement_virtualNetworkInternal
=== PAUSE TestAccAzureRMApiManagement_virtualNetworkInternal
=== CONT TestAccAzureRMApiManagement_virtualNetworkInternal
--- PASS: TestAccAzureRMApiManagement_virtualNetworkInternal (3318.60s)
=== RUN TestAccAzureRMApiManagement_virtualNetworkInternalAdditionalLocation
=== PAUSE TestAccAzureRMApiManagement_virtualNetworkInternalAdditionalLocation
=== CONT TestAccAzureRMApiManagement_virtualNetworkInternalAdditionalLocation
--- PASS: TestAccAzureRMApiManagement_virtualNetworkInternalAdditionalLocation (2541.65s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultId
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultId
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultId
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultId (2978.04s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultId
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultId
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultId
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultId (3141.35s)
=== RUN TestAccAzureRMApiManagement_identityUserAssigned
=== PAUSE TestAccAzureRMApiManagement_identityUserAssigned
=== CONT TestAccAzureRMApiManagement_identityUserAssigned
--- PASS: TestAccAzureRMApiManagement_identityUserAssigned (2513.36s)
=== RUN TestAccAzureRMApiManagement_identityNoneUpdateUserAssigned
=== PAUSE TestAccAzureRMApiManagement_identityNoneUpdateUserAssigned
=== CONT TestAccAzureRMApiManagement_identityNoneUpdateUserAssigned
--- PASS: TestAccAzureRMApiManagement_identityNoneUpdateUserAssigned (3054.05s)
=== RUN TestAccAzureRMApiManagement_identityUserAssignedUpdateNone
=== PAUSE TestAccAzureRMApiManagement_identityUserAssignedUpdateNone
=== CONT TestAccAzureRMApiManagement_identityUserAssignedUpdateNone
--- PASS: TestAccAzureRMApiManagement_identityUserAssignedUpdateNone (2514.02s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssigned
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssigned
=== CONT TestAccAzureRMApiManagement_identitySystemAssigned
--- PASS: TestAccAzureRMApiManagement_identitySystemAssigned (2429.85s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUpdateNone
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUpdateNone
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUpdateNone
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUpdateNone (2552.19s)
=== RUN TestAccAzureRMApiManagement_identityNoneUpdateSystemAssigned
=== PAUSE TestAccAzureRMApiManagement_identityNoneUpdateSystemAssigned
=== CONT TestAccAzureRMApiManagement_identityNoneUpdateSystemAssigned
--- PASS: TestAccAzureRMApiManagement_identityNoneUpdateSystemAssigned (2967.79s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUserAssigned
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUserAssigned
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUserAssigned
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUserAssigned (2692.14s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateNone
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateNone
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateNone
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateNone (2380.81s)
=== RUN TestAccAzureRMApiManagement_identityNoneUpdateSystemAssignedUserAssigned
=== PAUSE TestAccAzureRMApiManagement_identityNoneUpdateSystemAssignedUserAssigned
=== CONT TestAccAzureRMApiManagement_identityNoneUpdateSystemAssignedUserAssigned
--- PASS: TestAccAzureRMApiManagement_identityNoneUpdateSystemAssignedUserAssigned (2512.43s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateSystemAssigned
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateSystemAssigned
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateSystemAssigned
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateSystemAssigned (2740.42s)
=== RUN TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateUserAssigned
=== PAUSE TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateUserAssigned
=== CONT TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateUserAssigned
--- PASS: TestAccAzureRMApiManagement_identitySystemAssignedUserAssignedUpdateUserAssigned (2392.75s)

@tombuildsstuff tombuildsstuff removed the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label Oct 21, 2020
@yupwei68
Copy link
Contributor Author

@manicminer All tests have passed. Please continue reviewing.

@ghost ghost removed the waiting-response label Nov 13, 2020
Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@yupwei68 Thanks, this looks great. I have a couple suggestions regarding the virtual_network_type attribute and tidying up the tests a little.

Since the outputs of testAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultId(), testAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionlessKeyVaultIdUpdateCD(), testAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultId() and testAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurationsVersionedKeyVaultIdUpdateCD() are almost identical, could we consolidate these into a testAccAzureRMApiManagement_identitySystemAssignedUpdateHostnameConfigurations_template() function and only embed the differences in the other funcs? It would make the tests easier to reason about.

Aside from that, this looks good to me!

@@ -121,6 +121,9 @@ func resourceArmApiManagementService() *schema.Resource {
},
},

// Here we could not remove the `ForceNew` of the vnet type. Once we update the vnet type from `Internal` `External` to `None`, the destroy will fail because the subnet is still in use.
// In the above case, it doesn't remove the link to subnet immediately. It'll be removed within 3 hours.
// But if we destroy the APIM service with VNET type `Internal` or `External`, the subnet could be destroyed
Copy link
Contributor

@manicminer manicminer Nov 13, 2020

Choose a reason for hiding this comment

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

If we can safely change from virtual_network_type = "None" to one of the other values, it might be worth conditionally enforcing ForceNew?

e.g.

		CustomizeDiff: customdiff.All(
			customdiff.ForceNewIfChange("virtual_network_type", func(old, new, meta interface{}) bool {
				return (old.(string) == string(apimanagement.VirtualNetworkTypeExternal) ||
					old.(string) == string(apimanagement.VirtualNetworkTypeInternal)) &&
					new.(string) == string(apimanagement.VirtualNetworkTypeNone)
			}),
		),

@manicminer
Copy link
Contributor

@yupwei68 is this ready for re-review?

@yupwei68 yupwei68 closed this Nov 19, 2020
@yupwei68 yupwei68 reopened this Nov 19, 2020
@yupwei68 yupwei68 closed this Nov 19, 2020
@yupwei68 yupwei68 reopened this Nov 19, 2020
@ghost ghost removed the waiting-response label Nov 19, 2020
@yupwei68 yupwei68 requested a review from manicminer November 19, 2020 02:37
@yupwei68 yupwei68 closed this Nov 23, 2020
@yupwei68 yupwei68 reopened this Nov 23, 2020
@yupwei68
Copy link
Contributor Author

@manicminer Thanks for comments. Please continue reviewing.
=== RUN TestAccAzureRMApiManagement_virtualNetworkInternalUpdate
=== PAUSE TestAccAzureRMApiManagement_virtualNetworkInternalUpdate
=== CONT TestAccAzureRMApiManagement_virtualNetworkInternalUpdate
--- PASS: TestAccAzureRMApiManagement_virtualNetworkInternalUpdate (5153.10s)

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Many thanks @yupwei68, this LGTM 🚀

Test results:
Screenshot 2020-11-25 at 12 23 48

@manicminer manicminer added this to the v2.38.0 milestone Nov 25, 2020
@manicminer manicminer merged commit c5e9867 into hashicorp:master Nov 25, 2020
manicminer added a commit that referenced this pull request Nov 25, 2020
@ghost
Copy link

ghost commented Nov 27, 2020

This has been released in version 2.38.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.38.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Dec 25, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 25, 2020
@yupwei68 yupwei68 deleted the wyp-apim-apim branch June 7, 2021 06:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

azurerm_api_management keeps updating developer_portal certificates
6 participants