Skip to content

[1.29.30] CI on GitHub Actions#3224

Merged
jirihnidek merged 26 commits intosubscription-manager-1.29.30from
mhorky/github-actions-1.29.30-rhel9.1
Mar 9, 2023
Merged

[1.29.30] CI on GitHub Actions#3224
jirihnidek merged 26 commits intosubscription-manager-1.29.30from
mhorky/github-actions-1.29.30-rhel9.1

Conversation

@m-horky
Copy link
Contributor

@m-horky m-horky commented Mar 8, 2023

m-horky added 25 commits March 8, 2023 13:23
* Card ID: ENT-5317

We've seen some strange issues when the full test suite has been run
several times in a row. A process responsible for creating DBus session
was not being destroyed *every time* -- when it wasn't, the next DBus
test would try to claim the same DBus address again. That would raise an
exception in child thread (that was not handled), pytest would get stuck
until the timeout happened; the main thread was still asleep, resulting
in INTERNALERRORs.

This new approach addresses this in several ways:

- DBus server is created for whole DBus class, not for every one of the
  tests. That means that even if the probability of hanging up stayed
  here, the chance of that happening decreases by an order of magnitude.

- The tests aren't using DBus to pass data around now. While the server
  is needed to instantiate the DBus classes, we can use Python magic to
  access original functions that were decorated and call them instead,
  circumventing all DBus communication.

This has a side effect of speeding up the tests, as both server creation
and DBus transmission added non-zero delay to each of DBus tests.

(Cherry-picked from 2e5dd64)
* Card ID: ENT-5317

TODOs were sources from description of commit 7da6982.

(Cherry-picked from dff6d71)
* Card ID: ENT-5317

(Cherry-picked from de9730e)
* Card ID: ENT-5317

(Cherry-picked from 2472cfc)
* Card ID: ENT-5317

(Cherry-picked from fec8833)
* Card ID: ENT-5317

(Cherry-picked from eaac363)
* Card ID: ENT-5317

(Cherry-picked from 5e4d77c)
* Card ID: ENT-5317

(Cherry-picked from 521cf61)
When tests were run in container, without having sub-man packages
installed, two things happened:

- Container detection kicked in and prevented CPProvider from being
  created.
  NOTE: rhsm/unit/test_config.py::InContainerTests do not inherit from
  fixture.py::SubManFixture and are not affected by this patch.

- TCP handshake was attempted by opening a connection. Because the
  connection requires RHSM certificates to be installed on the system,
  this step crashed, when subscription-manager-rhsm-certificates (e.g.,
  /etc/rhsm/ca/ directory) was not present.

(Cherry-picked from d1b716f)
Because 'get_config_parser()' and 'in_container()' functions were being
imported directly, instead of as reference, the mocks that tests perform
were not applying to them, causing test suite to fail when run from
inside a container. Future-wise it is better to manage mocks on one
place, instead of patching the functions whenever they are being
imported.

(Cherry-picked from 0b78761)
* Card ID: ENT-5536

Subprocess calls to 'touch' were sometimes failing to update the
modification date (race condition, probably?), making the tests fail.
When 'os.utime' is used, this is no longer the case and the files are
always reported as modified.

(Cherry-picked from 68acefc)
* Card ID: ENT-3759

(Cherry-picked from 124db8c. It does not include changes of
test/rhsmlib/dbus/test_facts.py.)
* Card ID: ENT-5541

Publish coverage report as a comment under the PR.
- To send the comment only once, not for every matrix system, only
  'Fedora latest' is used as a data source.
- Because of how GitHub permissions work, the comment is only sent if
  the PR originates from a feature branch; nothing will be sent for a PR
  originating from some fork. Full coverage is still displayed in CI
  output, it is just not sent as a comment.
- Package 'pytest-cov' is used instead of 'coverage'. It is still using
  coverage in a background, but it runs it as a pytest addon instead,
  allowing us to pass its arguments into pytest, instead of wrapping
  whole pytest call inside of a coverage invocation.

(Cherry-picked from ea495a6)
* Card ID: ENT-5543

(Cherry-picked from 9fa7469)
* Card ID: ENT-5542

(Cherry-picked from 2791a52)
When the package is not available, one test from
test/test_dnf_content_plugin.py is skipped.

(Cherry-picked from a894837)
They were required because of recent bug in systemd:
- https://bugzilla.redhat.com/show_bug.cgi?id=2167468
- systemd/systemd#26366

With this fix, we can remove the test deselections.

(Cherry-picked from 8f20aad)
- Rename argument 'auto_spec' to 'autospec'
  It was valid in older versions of the 'mock' library.

(Partially cherry-picked from f6c4404)
This could help us with debugging errors when a test crashes on CI, but
not locally.

(Cherry-picked from f636251)
The markers were removed before, but the D-Bus tests tend to fail
*sometimes*, so it is useful to keep this in. All D-Bus tests inherit
from this class, so we only have to do it here in one place.

(Cherry-picked from 24e47e4)
Our test that checks if it is possible to connect to newly created
socket started failing with 'Permission denied' when the code tried to
use it. Pytest cannot write into '/run', moving it to '/tmp' solves the
issue.

Additionally, as a result of relatively recent D-Bus implementation
changes, 'tmpdir' and 'dir' behave the same and create regular socket,
not an abstract socket. Connecting with "\0" prefix (which signifies the
abstract one) now fails and thus has been removed from the tests.

(Cherry-picked from bae7ce3)
This ensures all the injections have been initiated. Without them, the
tests may fail on attempts to write '/etc/pki/product' or similar root
directories.

(Cherry-picked from 729b4f8)
This small patch ensures all injections have been initialized before
running the test suite. Without them, inheriting from SubManFixture
would have no effect.

(Cherry-picked from 4f7ae98)
@cnsnyder cnsnyder requested review from a team and ptoscano and removed request for a team March 8, 2023 12:38
@github-actions
Copy link

github-actions bot commented Mar 8, 2023

Coverage

Coverage (computed on Fedora latest) •
FileStmtsMissCoverMissing
rhsmlib/dbus
   server.py18311039%57–58, 74, 76, 79, 81–86, 88–97, 99–100, 102–107, 109, 112–113, 115–134, 136–140, 142, 151, 155, 162–170, 173–175, 183–184, 186, 194, 197, 199, 206–207, 209–210, 224, 227–230, 242–246, 269, 274–278, 282–286, 288–289, 291, 298, 320, 341–342
rhsmlib/dbus/objects
   entitlement.py1043170%63, 69–71, 86–87, 105–107, 109, 111–113, 115–117, 119–121, 123–126, 135–139, 225, 227–228
rhsmlib/services
   entitlement.py2455876%70–73, 119–120, 122–123, 126–127, 129, 141–147, 150–151, 153–155, 168–169, 171, 173, 241, 283, 288, 302–305, 308–310, 312–313, 315, 468, 529, 589–593, 601, 603–605, 608–610, 612, 614–615, 617
subscription_manager
   repolib.py3645086%71–76, 79, 84, 90, 121, 124, 171–172, 226–227, 237–243, 245, 391–394, 396–397, 399, 401, 403–405, 416–422, 465–468, 476–477, 484, 538, 628
subscription_manager/cli_command
   remove.py1112478%86, 98, 102–105, 107–109, 127–128, 145, 160, 163–166, 168–171, 199–201
TOTAL17776441075% 

Tests Skipped Failures Errors Time
2594 5 💤 0 ❌ 0 🔥 57.206s ⏱️

findProductId() returns an int, either -1 or 1 depending on whether it
was possible to find the product ID in the specified certificate.
The problem with this kind of return value is that's very easy to
mistake for a boolean, and indeed installProductId() has a boolean-like
check that it is always true, no matter the return value of
findProductId().

As a fix, change the return type of findProductId() to gboolean, with
true returned whether the search succeeded:
- reduce the scope of the 'ret_val' variable, so there are less chances
  to use it wrongly
- make 'ret_val' false by default, only changing it to true in the only
  place where it needs to be like that
- adapt the tests accordingly

(Cherry-picked from 77aee7e)
@jirihnidek jirihnidek self-assigned this Mar 9, 2023
Copy link
Contributor

@jirihnidek jirihnidek left a comment

Choose a reason for hiding this comment

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

LGTM

@jirihnidek jirihnidek merged commit 8f63eda into subscription-manager-1.29.30 Mar 9, 2023
@jirihnidek jirihnidek deleted the mhorky/github-actions-1.29.30-rhel9.1 branch March 9, 2023 13:36
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.

3 participants