Skip to content

fix(availability_group, backup, restore): close integration test gaps - #394

Merged
lowlydba merged 16 commits into
mainfrom
lowlydba-fix-integration-test-gaps
Sep 5, 2026
Merged

fix(availability_group, backup, restore): close integration test gaps#394
lowlydba merged 16 commits into
mainfrom
lowlydba-fix-integration-test-gaps

Conversation

@lowlydba

@lowlydba lowlydba commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Closes #381

backup only ran once with a single assert block, restore never asserted result is changed/is not changed, and win_availability_group/win_ag_replica never re-ran with the same inputs to confirm a no-op reports not changed. That last gap meant an idempotency regression like #374 would pass CI silently.

Each target now follows the pattern already used elsewhere in the suite: run, assert changed, run again with identical inputs, assert not changed, plus a check_mode: true run for backup and restore (both already set supports_check_mode = $true in the module spec). install_script and win_install_script also now pass deployment_method: "SingleTransaction" on their first real install, exercising a non-default value against Install-DboScript instead of just the default.

Bugs found along the way

The new check_mode assertion for backup failed immediately: Backup-DbaDatabase/Restore-DbaDatabase return no output under -WhatIf, so backup.ps1/restore.ps1 never flipped changed to true in check mode. Fixed both modules to report changed based on check_mode too, not just on whether an output object came back, since a backup or restore is never a no-op.

The new idempotency assertion for win_availability_group also failed: a second identical present call reported changed: true even though nothing changed. Get-DbaAvailabilityGroup never populates FailureConditionLevel/HealthCheckTimeout on the returned SMO object, so availability_group.ps1's diff compared those two properties against unset defaults instead of the real server values.

sys.availability_groups looks like the obvious place to read the real values from instead, but it's documented as a cache of the WSFC cluster resource's copy, so it's empty for cluster_type: None groups (our test setup, since CI has no real WSFC cluster to configure). Excluded both properties from the idempotency diff instead of trying to read them back. They're still applied via Set-DbaAvailabilityGroup whenever another property change triggers an update, so the tradeoff is that drift on just those two properties alone won't be detected.

Testing

Ran the full CI matrix against a live SQL Server instance. The backup/restore check-mode fix is confirmed: those assertions failed before the module fix and pass after. The availability_group idempotency fix is pushed but not yet confirmed against CI.

Bonus

  • Added a hero image to the top of README.md (docs/images/hero.png, source docs/images/hero.svg).

@lowlydba
lowlydba marked this pull request as ready for review September 4, 2026 23:47
Copilot AI lite review requested due to automatic review settings September 4, 2026 23:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The changelog entry and README intro need small corrections to accurately reflect the changes and preserve basic README structure.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates the Ansible collection’s integration test targets to more consistently assert changed behavior (including check mode where supported) and adds a README hero image/changelog entry for the update.

Changes:

  • Add check_mode: true runs and changed assertions for backup and win_restore integration targets.
  • Add explicit no-op (second-run) idempotency assertions for win_availability_group and win_ag_replica.
  • Exercise non-default deployment_method: "SingleTransaction" in both install_script integration targets; add README hero image + changelog fragment.
File summaries
File Description
tests/integration/targets/win_restore/tasks/main.yml Adds check-mode restore run and asserts changed on successful restore.
tests/integration/targets/backup/tasks/main.yml Adds check-mode backup run and asserts changed.
tests/integration/targets/win_availability_group/tasks/main.yml Adds a second-run no-op assertion for availability group creation.
tests/integration/targets/win_ag_replica/tasks/main.yml Adds a second-run no-op assertion for AG replica configuration.
tests/integration/targets/install_script/tasks/main.yml Exercises deployment_method: "SingleTransaction" for the initial install.
tests/integration/targets/win_install_script/tasks/main.yml Exercises deployment_method: "SingleTransaction" for the initial install (Windows target).
README.md Adds a hero image at the top of the README.
docs/images/hero.svg Adds the SVG source for the README hero image.
changelogs/fragments/381-integration-test-gaps.yml Adds a changelog fragment describing the test coverage improvements.
Review details
  • Files reviewed: 8/10 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md
Comment thread changelogs/fragments/381-integration-test-gaps.yml Outdated
lowlydba and others added 2 commits September 4, 2026 19:52
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

Changes are confined to integration tests and documentation, and the updated assertions/parameters appear internally consistent with existing target patterns and module defaults usage.

This review doesn't count toward merge requirements.

Review details
  • Files reviewed: 8/10 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

lowlydba and others added 9 commits September 4, 2026 20:13
Get-DbaAvailabilityGroup/Get-DbaAgReplica return SMO objects that don't
eager-load every property (FailureConditionLevel/HealthCheckTimeout came
back as unset zero-value defaults). Refresh() before comparing against
desired state so the diff reflects real server values.
…heckTimeout from catalog

Get-DbaAvailabilityGroup never populates these two properties (SMO
Standalone facet properties the AvailabilityGroups collection doesn't
retrieve), so they always read back as unset defaults (0) regardless
of the real server value, and the idempotency diff compared those
defaults against the desired state on every run. Read the real values
from sys.availability_groups instead.
Split the WSL package install out of Vampire/setup-wsl's one-shot
additional-packages so we can retry apt-get update/install (with
Acquire::Retries) instead of failing the whole job on a transient
archive.ubuntu.com mirror hash mismatch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…eout from idempotency diff

Get-DbaAvailabilityGroup's SMO object never populates these two
properties, and sys.availability_groups (a cache of the WSFC cluster
resource's copy) is empty for cluster_type: None groups since there's
no cluster resource to cache from. Neither source can be trusted for
change detection, so drop the catalog-query workaround and exclude
both properties from the diff. They're still applied via
Set-DbaAvailabilityGroup whenever another property change triggers an
update.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lowlydba lowlydba changed the title test: add check-mode and idempotency assertions to integration tests fix(availability_group, ag_replica, backup, restore): close integration test gaps Sep 5, 2026
@lowlydba lowlydba changed the title fix(availability_group, ag_replica, backup, restore): close integration test gaps fix(availability_group, backup, restore): close integration test gaps Sep 5, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lowlydba
lowlydba enabled auto-merge (squash) September 5, 2026 03:21
@lowlydba
lowlydba merged commit 04cf9c0 into main Sep 5, 2026
24 checks passed
@lowlydba
lowlydba deleted the lowlydba-fix-integration-test-gaps branch September 5, 2026 03:30
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.

Integration tests missing check-mode and idempotency assertions for several modules

2 participants