Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(servstate): enhance checkstate and reaper tests #283

Merged
merged 2 commits into from
Aug 22, 2023

Conversation

flotter
Copy link
Contributor

@flotter flotter commented Aug 18, 2023

The following commits are included:

test(servstate): enhance zombie reaper test

TestReapZombies have some timing sensitive code which can result in CI failures under heavy CPU load.

This PR adds a file based trigger mechanism to ensure there is a controlled window of opportunity to:

  • Read the grandchild PID from the child process stdout.
  • Observe the grandchild process in zombie status before its reaped.

test(servstate): remove checks related races

The following tests had a check which relied on the checkstate failure counter:

  • TestOnCheckFailureRestartWhileRunning
  • TestOnCheckFailureIgnore
  • TestOnCheckFailureShutdown

However, this counter increments every time after the check timeout expires, even after the service was notified (which happens once only). This counter is a detail that is covered by the checkstate unit tests. Expecting an exact value from the async testing thread makes the test timing sensitive and racey, without adding any value from the servstate package perspective.

Change the failure counter check to >= 1 to remove timing sensitivity from the following tests.

Copy link
Contributor

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Excellent, thanks. Just a couple of nit comments.

internals/overlord/servstate/manager_test.go Outdated Show resolved Hide resolved
internals/overlord/servstate/manager_test.go Show resolved Hide resolved
internals/overlord/servstate/manager_test.go Outdated Show resolved Hide resolved
The following tests had a check which relied on the checkstate failure
counter:

TestOnCheckFailureRestartWhileRunning
TestOnCheckFailureIgnore
TestOnCheckFailureShutdown

However, this counter increments every time after the check timeout expires,
even after the service was notified (which happens once only). This counter
is a detail that is covered by the checkstate unit tests. Expecting an exact
value from the async testing thread makes the test timing sensitive and
racey, without adding any value from the servstate package perspective.

Change the failure counter check to >= 1 to remove timing sensitivity from
the following tests.
TestReapZombies have some timing sensitive code which can result in
CI failures under heavy CPU load.

This PR adds a file based trigger mechanism to ensure there is a
controlled window of opportunity to:

- Read the grandchild PID from the child process stdout.

- Observe the grandchild process in zombie status before its reaped.
@jnsgruk jnsgruk linked an issue Aug 22, 2023 that may be closed by this pull request
@jnsgruk jnsgruk merged commit 00bf704 into canonical:master Aug 22, 2023
13 checks passed
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.

Intermittent test failures: servstate.TestOnCheckFailure*
3 participants