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

Fix broken statemon tests #2832

Merged

Conversation

lunkwill42
Copy link
Member

I accidentally discovered that several of the statemon tests were in fact broken. They expect pping code to use the process PID as a packet ID, and end up using this in their assertions.

However, this is only sort-of true: pping actually uses the process PID modulo 2^16, since the value needs to fit in a 16-bit packet header field. If the tests ran on a system where the test runner PID is higher than 65536, these tests would fail for no apparent reason.

This would rarely have been encountered, since the test suite most often runs inside newly created VMs or containers that are torn down immediately after the test run. This way, the test suite would almost always encounter very low PID values. Running the teste on my workstation with a high uptime was a different story, though.

This more or less rewrites the tests to pytest format, so they can easily re-use a fixture to get the proper "PID" value.

I accidentally discovered that several of the statemon tests were in
fact broken.  They expect pping code to use the process PID as a packet
ID, and end up using this in their assertions.

However, this is only sort-of true: pping actually uses the process PID
modulo 2^16, since the value needs to fit in a 16-bit packet header
field.  If the tests ran on a system where the test runner PID is
higher than 65536, these tests would fail for no apparent reason.

This would rarely have been encountered, since the test suite most often
runs inside newly created VMs or containers that are torn down
immediately after the test run.  This way, the test suite would almost
always encounter very low PID values.  Running the teste on my
workstation with a high uptime was a different story, though.

This more or less rewrites the tests to pytest format, so they can
easily re-use a fixture to get the proper "PID" value.
Copy link

sonarcloud bot commented Feb 27, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

codecov bot commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.10%. Comparing base (de2a90b) to head (0f31258).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2832   +/-   ##
=======================================
  Coverage   57.10%   57.10%           
=======================================
  Files         567      567           
  Lines       41278    41278           
=======================================
  Hits        23571    23571           
  Misses      17707    17707           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Test results

     12 files       12 suites   11m 56s ⏱️
3 303 tests 3 303 ✔️ 0 💤 0
9 384 runs  9 384 ✔️ 0 💤 0

Results for commit 0f31258.

@lunkwill42 lunkwill42 merged commit 0c15d1a into Uninett:master Feb 28, 2024
12 checks passed
@lunkwill42 lunkwill42 deleted the test/fix-broken-statemon-tests branch February 28, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants