[PR #5786] [MERGED] [client] Fix flaky TestServiceLifecycle/Restart on FreeBSD #28530

Closed
opened 2026-08-05 08:06:30 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5786
Author: @lixmal
Created: 4/2/2026
Status: Merged
Merged: 4/2/2026
Merged by: @lixmal

Base: mainHead: fix-freebsd-service-test-flaky


📝 Commits (1)

  • 63faa36 Fix flaky TestServiceLifecycle/Restart on FreeBSD

📊 Changes

1 file changed (+46 additions, -0 deletions)

View changed files

📝 client/cmd/service_test.go (+46 -0)

📄 Description

Describe your changes

Fix flaky TestServiceLifecycle/Restart on the FreeBSD CI job. The rc.d service script runs the test binary via daemon(8) -r with service run ... arguments. Since the test binary can't handle cobra CLI args, it exits immediately, and daemon -r respawns it rapidly until hitting FreeBSD's rate limit. By then the daemon has exited, so service restart fails with exit code 1.

  • Add TestMain that detects when the test binary is invoked as a daemon subprocess and blocks on SIGTERM instead of exiting
  • Add t.Cleanup to ensure the service is stopped and uninstalled even if a subtest fails (previously a Restart failure left the service installed on the VM)

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Test-only change, no user-facing behavior modified.

Summary by CodeRabbit

  • Tests
    • Enhanced service lifecycle test cleanup and improved signal handling for better test reliability and proper service termination during testing.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/5786 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 4/2/2026 **Status:** ✅ Merged **Merged:** 4/2/2026 **Merged by:** [@lixmal](https://github.com/lixmal) **Base:** `main` ← **Head:** `fix-freebsd-service-test-flaky` --- ### 📝 Commits (1) - [`63faa36`](https://github.com/netbirdio/netbird/commit/63faa36d212dd044987794e598b4e3ef300689e3) Fix flaky TestServiceLifecycle/Restart on FreeBSD ### 📊 Changes **1 file changed** (+46 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `client/cmd/service_test.go` (+46 -0) </details> ### 📄 Description ## Describe your changes Fix flaky `TestServiceLifecycle/Restart` on the FreeBSD CI job. The rc.d service script runs the test binary via `daemon(8) -r` with `service run ...` arguments. Since the test binary can't handle cobra CLI args, it exits immediately, and `daemon -r` respawns it rapidly until hitting FreeBSD's rate limit. By then the daemon has exited, so `service restart` fails with exit code 1. - Add `TestMain` that detects when the test binary is invoked as a daemon subprocess and blocks on SIGTERM instead of exiting - Add `t.Cleanup` to ensure the service is stopped and uninstalled even if a subtest fails (previously a Restart failure left the service installed on the VM) ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Test-only change, no user-facing behavior modified. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Enhanced service lifecycle test cleanup and improved signal handling for better test reliability and proper service termination during testing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:06:30 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#28530