Skip to content

Improve test reliability by waiting for resources to be fully deleted - #472

Merged
felix-kaestner merged 5 commits into
mainfrom
feat/test-reliability
Aug 3, 2026
Merged

Improve test reliability by waiting for resources to be fully deleted#472
felix-kaestner merged 5 commits into
mainfrom
feat/test-reliability

Conversation

@adamtrizuljak-sap

@adamtrizuljak-sap adamtrizuljak-sap commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

While working on #426 I noticed that the tests are unreliable. Typical rate was 1-2 fails out of 10 runs of the test suite. Different tests would fail each time and it was hard to reproduce the failures reliably.

The root cause seems to be this. Envtest doesn't run any controllers, therefore the tests need to delete the created resources manually. This is already handled in the existing AfterEach blocks. However the deletion could happen too quickly, before the controller could finalize the resource(s). This would then trigger a cascade failure, where resources that should have been deleted are still present (or vice versa) and other related conditions.

For example in the Device tests, the added Eventually(IsNotFound) waits after deleting the primary resource and before deleting the Device in AfterEach. Without the wait, the Device could be deleted before the controller had a chance to finalize the resource — causing GetDeviceByName to fail, the finalizer to never be removed, and the provider state to never be cleaned up.

Also the EthernetSegmentController was registered in suite_test.go without RequeueInterval, meaning it would always run only 1 round of reconciliation and never get polled again.

This PR consists of the extracted test fixes from #426 + several small additional fixes that were required to make this PR pass the tests on its own.

Also adding the generated cover.html file to gitignore

Added `Eventually(IsNotFound)` waits after deleting the primary resource and before deleting the Device in `AfterEach`. Without the wait, the Device could be deleted before the controller had a chance to finalize the resource — causing `GetDeviceByName` to fail, the finalizer to never be removed, and the provider state to never be cleaned up.

Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/internal/controller/core 61.58% (-0.04%) 👎

Coverage by file

Changed unit test files

  • github.com/ironcore-dev/network-operator/internal/controller/core/acl_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/banner_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/bgp_peer_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/certificate_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/dhcprelay_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/dns_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/isis_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/lldp_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/managementaccess_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/ntp_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/ospf_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/pim_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/prefixset_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/snmp_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/suite_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/syslog_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/user_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/controller/core/vlan_controller_test.go

@adamtrizuljak-sap

Copy link
Copy Markdown
Contributor Author

Extracting just the test fixes from the Configured condition PR does not fully fix the tests. The fix must depend on some other code and logic changes that have been introduced in that PR. I would like to merge this as-is and keep building upon it.

@felix-kaestner
felix-kaestner merged commit bf649e9 into main Aug 3, 2026
24 checks passed
@felix-kaestner
felix-kaestner deleted the feat/test-reliability branch August 3, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants