Fix TestServerControlSocketActivated flake.
- Clear `runner.ExtraFiles` before calling running other
commands. This appears to be the primary source of
the spurious test failures.
Refactor `TestServerControlSocketActivated` to:
- start server from the test (go)routine instead of a background one;
- process server's output synchrounously in the test goroutine;
- fix race: close the listener file descriptor synchronously in the
test goroutine instead of async, which ensures the descriptor is
closed before sending the first request to the (status) server;
otherwise, shutdown hangs (when the listener close is delayed);
- check and assert server's exit status;
- improve test cleanup: ensure child server process terminates
and is reaped on assertion failure.
Also, address potential race in `TestServerControlSocketActivatedTooManyFDs`
check with explanation comment. There is still a posible race where
the stderr pipe is closed before the background async callback gets
the error message. This will be addressed separately.
Objective: make the tests more robust and reduce random failures.
Preliminary refactoring:
- Accept testing.TB in testenv helpers. This is needed to
use `require.EventuallyWithT` in socket activation tests.
- Rename parameters for clarity
Tests refactoring:
- use t.Cleanup instead of defer where appropriate
- create file handlers in test routine instead of go routines
- remove unnecessary var declaration
- increased wait time to 30 seconds.
- allow running socket activation test on Darwin
Ref:
- #3283
- #3313
- #3318
- upgrade to golangci-lint 2.6.1
- updates for gosec
- updates for govet
- updates for perfsprint
- updates modernize
Leaves out modernize:omitempty due to conflicts with tests
- enable `forcetypeassert` linter in non-test files
- add `//nolint` annotations
- add `testutil.EnsureType` helper for type assertions
- enable `forcetypeassert` linter in test files
* use uint8 for clarity
* unexport writeContentAsyncAndVerify
* fix typo in test function name
* remove commented interface functions
* use atomic.Int32
* cleanups in socket server activation test
* leverage stdlib's maps and slices packages
replace uses of `golang.org/x/exp/maps`
* nit: leverage `maps.Values`