Skip to content

Commit

Permalink
test: break insights-client in a different way
Browse files Browse the repository at this point in the history
The sequence of events in the test is the following:
1) register with insights-client, a new machine-id is generated
2) the test moves away the machine-id file
3) a new data upload is triggered by starting the systemd service
4) insights-client eagerly generates a new machine-id file to check
   whether it is registered even if it is not the case (that's another
   issue, much harder to fix)
5) the newly generated machine-id has nothing associated to it
6) a proper warning is shown as expected
7) the original machine-id is restored
8) everything else continues as usual

This worked fine until recent times, as the new machine-id always had
a new UUID. After recent changes in insights-core [1], now the default
machine-id generated by insights-client when the system is registered
with subscription-manager is the subscription-manager UUID. Thus, the
machine-id file generated during step (4) is now always the same, which
then allows insights-client to query for its own details as if nothing
happened.

To break insights-client again, the changes are in the following step
of the above sequence:
4) a new random UUID is written as machine-id file

This new "wrong" machine-id file makes insights-client think that the
status is not correct, and thus the test can keep going as expected.

[1] RedHatInsights/insights-core#4057
  • Loading branch information
ptoscano committed Apr 17, 2024
1 parent 69d1cc0 commit bbac2c3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/check-subscriptions
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
import sys
import unittest
import uuid

# import Cockpit's machinery for test VMs and its browser test API
TEST_DIR = os.path.dirname(__file__)
Expand Down Expand Up @@ -444,8 +445,10 @@ class TestSubscriptions(SubscriptionsCase):

b.wait_visible("button:contains('Connected to Insights')")

# Break the next upload and expect the warning triangle to tell us about it
m.execute(["mv", "/etc/insights-client/machine-id", "/etc/insights-client/machine-id.lost"])
# Break the next upload and expect the warning triangle to tell us about it;
# write over the original file so its SELinux attributes are preserved.
m.execute(["cp", "/etc/insights-client/machine-id", "/etc/insights-client/machine-id.orig"])
m.write("/etc/insights-client/machine-id", str(uuid.uuid4()))
m.execute(["systemctl", "start", "insights-client"])

with b.wait_timeout(60):
Expand All @@ -456,7 +459,7 @@ class TestSubscriptions(SubscriptionsCase):
b.click("button.cancel")

# Unbreak it and retry.
m.execute(["mv", "/etc/insights-client/machine-id.lost", "/etc/insights-client/machine-id"])
m.execute(["mv", "/etc/insights-client/machine-id.orig", "/etc/insights-client/machine-id"])
m.execute(
"systemctl start insights-client; "
"while systemctl --quiet is-active insights-client; do sleep 1; done",
Expand Down

0 comments on commit bbac2c3

Please sign in to comment.