Skip to content

Commit

Permalink
test: Tolerate slow failures of insights-client
Browse files Browse the repository at this point in the history
Insights-client seems to have gotten slower recently, so let's wait
longer for it to fail the upload.

And also, provoke the upload failure by returning a proper error code
from mock-insights.

Also also, allow more time for the initial registration in
testInsights.
  • Loading branch information
mvollmer committed Apr 4, 2024
1 parent 82827d0 commit a874cae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
21 changes: 16 additions & 5 deletions test/check-subscriptions
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ class TestSubscriptions(SubscriptionsCase):

dialog_register_button_sel = "footer .pf-m-primary"
b.click(dialog_register_button_sel)
b.wait_not_present(dialog_register_button_sel)
with b.wait_timeout(360):
b.wait_not_present(dialog_register_button_sel)

b.click("button:contains('Not connected')")
b.wait_visible('.pf-c-modal-box__body:contains("This system is not connected")')
Expand Down Expand Up @@ -440,8 +441,17 @@ 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"])
m.execute(["systemctl", "start", "insights-client"])
# We also avoid retrying the upload.
m.execute(
["sed", "-i", "-e", "s/--retry 3/--retry 1/", "/usr/lib/systemd/system/insights-client.service"]
)
m.execute(["systemctl", "daemon-reload"])
m.execute(["touch", "/etc/insights-client/mock-upload-fail"])
m.execute(
"systemctl start insights-client; "
"while systemctl --quiet is-active insights-client; do sleep 1; done",
timeout=360,
)

b.wait_visible("button .pf-c-button__icon svg[fill='orange']")

Expand All @@ -450,7 +460,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(["rm", "/etc/insights-client/mock-upload-fail"])
m.execute(
"systemctl start insights-client; "
"while systemctl --quiet is-active insights-client; do sleep 1; done",
Expand All @@ -460,7 +470,8 @@ class TestSubscriptions(SubscriptionsCase):
b.wait_not_present("button .pf-c-button__icon svg[fill='orange']")

b.click("button:contains('Unregister')")
b.wait_not_in_text("#overview", "Insights")
with b.wait_timeout(60):
b.wait_not_in_text("#overview", "Insights")
m.execute(["test", "-f", "/etc/insights-client/.unregistered"])


Expand Down
10 changes: 7 additions & 3 deletions test/files/mock-insights
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,13 @@ class handler(BaseHTTPRequestHandler):

m = self.match("/r/insights/uploads/([^/])+")
if m:
self.send_response(200)
self.end_headers()
self.wfile.write(b'{ "reports": [ "foo", "bar" ] }\n')
if os.path.exists("/etc/insights-client/mock-upload-fail"):
self.send_response(403)
self.end_headers()
else:
self.send_response(200)
self.end_headers()
self.wfile.write(b'{ "reports": [ "foo", "bar" ] }\n')
return

self.send_response(404)
Expand Down

0 comments on commit a874cae

Please sign in to comment.