Skip to content

azurerm_api_management_logger: fixes TestAccApiManagementLogger_update#31537

Merged
rigalGit merged 1 commit intomainfrom
jitendra/fix-TestAccApiManagementLogger_update
Feb 4, 2026
Merged

azurerm_api_management_logger: fixes TestAccApiManagementLogger_update#31537
rigalGit merged 1 commit intomainfrom
jitendra/fix-TestAccApiManagementLogger_update

Conversation

@rigalGit
Copy link
Copy Markdown
Contributor

@rigalGit rigalGit commented Jan 20, 2026

…e because of ForceNew attributes

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

TestAccApiManagementLogger_update was failing with replace action error because application_insights, eventhub are mutually exclusive and ForceNew attributes. In application_insights resource_id is also ForceNew and to test that behaviour I changed order of testcase also.

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevant documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

Local testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_resource - support for the thing1 property [GH-00000]

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #0000

AI Assistance Disclosure

  • AI Assisted - This contribution was made by, or with the assistance of, AI/LLMs

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the provider.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

Comment on lines +187 to +194
Config: r.basicEventHub(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("buffered").HasValue("true"),
check.That(data.ResourceName).Key("description").HasValue(""),
check.That(data.ResourceName).Key("eventhub.#").HasValue("0"),
check.That(data.ResourceName).Key("application_insights.#").HasValue("1"),
check.That(data.ResourceName).Key("application_insights.0.instrumentation_key").Exists(),
check.That(data.ResourceName).Key("eventhub.#").HasValue("1"),
check.That(data.ResourceName).Key("eventhub.0.name").Exists(),
check.That(data.ResourceName).Key("eventhub.0.connection_string").Exists(),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In application_insights, resource_id is also ForceNew and to test that behaviour I changed order of test configs.

basicApplicationInsights config does not have resource_id field but complete config has resource_id,
hence moved eventhub config -> basicApplicationInsights -> complete to test resource_id change should cause recreation.

Copy link
Copy Markdown
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Hi @rigalGit thanks for taking a look at this. I think we need to handle this test a bit differently. Since this test is meant to cover updating an existing resource, the fix should be to change or add config that only updates non ForceNew properties, rather than changing the test to expect a ForceNew update.

For a bit of context, these tests weren’t previously checking whether a ForceNew property was being updated. Now that that check is in place, a lot of tests are failing even though they were actually passing incorrectly before. Because of that, the config needs to be updated to reflect a valid update.

@rigalGit
Copy link
Copy Markdown
Contributor Author

rigalGit commented Feb 2, 2026

Hi @rigalGit thanks for taking a look at this. I think we need to handle this test a bit differently. Since this test is meant to cover updating an existing resource, the fix should be to change or add config that only updates non ForceNew properties, rather than changing the test to expect a ForceNew update.

For a bit of context, these tests weren’t previously checking whether a ForceNew property was being updated. Now that that check is in place, a lot of tests are failing even though they were actually passing incorrectly before. Because of that, the config needs to be updated to reflect a valid update.

thanks @catriona-m , I've created a new config to test update changes.
Also added a new testCase for switch between application_insights and eventhub ( draft pr )

Copy link
Copy Markdown
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this up @rigalGit - I just left one comment inline, but otherwise this looks good. Thanks!

},
{
Config: r.complete(data, "Logger from Terraform test", "false"),
Config: r.applicationInsightsUpdate(data, "Logger from Terraform test", "false"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

since we are only using this config in one place, could we set the description and buffered values directly in the config rather than passing them in here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks, addressed it.

Initially I thought of having test steps something like this

basicApplicationInsights (unset desc) -> applicationInsightsUpdate (desc_1,buffered)-> applicationInsightsUpdate (desc_2,buffered) -> basicApplicationInsights ( unset desc , buffered)

but current changes ( 1 less step) seems to be sufficient to check functionality.

@rigalGit rigalGit closed this Feb 4, 2026
@rigalGit rigalGit force-pushed the jitendra/fix-TestAccApiManagementLogger_update branch from b0c78c0 to d4385c1 Compare February 4, 2026 05:31
@github-actions github-actions Bot added size/XS and removed size/L labels Feb 4, 2026
@rigalGit rigalGit reopened this Feb 4, 2026
@github-actions github-actions Bot added size/M and removed size/XS labels Feb 4, 2026
Copy link
Copy Markdown
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Thanks @rigalGit LGTM!

@rigalGit rigalGit merged commit f67263a into main Feb 4, 2026
51 checks passed
@rigalGit rigalGit deleted the jitendra/fix-TestAccApiManagementLogger_update branch February 4, 2026 12:23
@github-actions github-actions Bot added this to the v4.59.0 milestone Feb 4, 2026
anurag-hashicorp pushed a commit to anurag-hashicorp/terraform-provider-azurerm that referenced this pull request Feb 19, 2026
@rcskosir rcskosir added the tests label Feb 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 28, 2026
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.

4 participants