Debian Codegraph @

test/verify/check-system-tuned

raw
1 #!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv)
2
3 #
4 # Copyright (C) 2015 Red Hat, Inc.
5 # SPDX-License-Identifier: LGPL-2.1-or-later
6
7
8 import testlib
9
10
11 @testlib.nondestructive
12 @testlib.skipOstree("No tuned packaged")
13 class TestTuned(testlib.MachineCase):
14
15 def testBasic(self) -> None:
16 b = self.browser
17 m = self.machine
18
19 recommended_profile = m.execute("tuned-adm recommend").strip()
20
21 # Stop tuned in case it is running by default, as on RHEL.
22
23 m.execute("systemctl stop tuned")
24 m.execute("systemctl disable tuned")
25 self.addCleanup(m.execute, "tuned-adm auto_profile") # Enable and set default profile
26
27 # Login and check initial state
28
29 self.login_and_go("/system")
30
31 def check_status_tooltip(expected: str) -> None:
32 b.mouse("#tuned-status-button", "mouseenter")
33 b.wait_text("#tuned-status-tooltip", expected)
34 # move mouse away again, to let the tooltip disappear and update
35 b.mouse("#tuned-status-button", "mouseleave")
36 b.wait_not_present("#tuned-status-tooltip")
37
38 b.wait_text('#tuned-status-button', "none")
39 check_status_tooltip("Tuned is not running")
40
41 # Start tuned manually. The recommended profile will be activated automatically.
42 m.execute("systemctl start tuned")
43 b.wait_text('#tuned-status-button', recommended_profile)
44 check_status_tooltip("This system is using the recommended profile")
45
46 # Disabled when not authorized
47 b.relogin('/system', superuser=False)
48 b.wait_text('#tuned-status-button.pf-m-aria-disabled', recommended_profile)
49 # page adjusts to privilege changes, button becomes clickable
50 b.become_superuser()
51
52 # Switch the profile
53
54 b.wait_text('#tuned-status-button', recommended_profile)
55 b.click('#tuned-status-button')
56 b.wait_text(".pf-v6-c-modal-box__title-text", "Change performance profile")
57 b.wait_visible(".pf-v6-c-modal-box li > button.pf-m-selected p")
58
59 # Make sure we see the recommended profile and its badges
60 b.wait_in_text(".pf-v6-c-modal-box li > button.pf-m-selected p", recommended_profile)
61 b.wait_visible(".pf-v6-c-modal-box li > button.pf-m-selected .pf-v6-c-label:contains('recommended')")
62 b.wait_visible(".pf-v6-c-modal-box li > button.pf-m-selected .pf-v6-c-label:contains('active')")
63
64 b.click(".pf-v6-c-modal-box li[data-value='desktop'] > button")
65 b.wait_in_text(".pf-v6-c-modal-box li > button.pf-m-selected p", "desktop")
66
67 b.click(".pf-v6-c-modal-box button.pf-m-primary")
68 b.wait_not_present(".pf-v6-c-modal-box")
69
70 b.wait_text('#tuned-status-button', "desktop")
71 check_status_tooltip("This system is using a custom profile")
72
73 # Check the status of tuned, it should show the profile
74 output = m.execute("tuned-adm active 2>&1 || true")
75 self.assertIn("desktop", output)
76 output = m.execute("systemctl status tuned")
77 self.assertIn("enabled;", output)
78
79 # Now disable tuned
80 b.click('#tuned-status-button')
81 b.wait_text(".pf-v6-c-modal-box__title-text", "Change performance profile")
82 b.wait_visible(".pf-v6-c-modal-box li > button.pf-m-selected p")
83
84 b.click(".pf-v6-c-modal-box li > button p:contains('None')")
85 b.wait_in_text(".pf-v6-c-modal-box li > button.pf-m-selected p", "None")
86 b.click(".pf-v6-c-modal-box button.pf-m-primary")
87 b.wait_not_present(".pf-v6-c-modal-box")
88
89 b.wait_text('#tuned-status-button', "none")
90
91 # Check the status of tuned, it should show disabled
92 output = m.execute("tuned-adm active 2>&1 || true")
93 self.assertIn("No current active profile", output)
94 output = m.execute("systemctl status tuned")
95 self.assertIn("disabled;", output)
96
97 # Click on the button again
98 b.click('#tuned-status-button')
99 b.wait_text(".pf-v6-c-modal-box__title-text", "Change performance profile")
100
101 # Tuned should still be disabled
102 output = m.execute("systemctl status tuned")
103 self.assertIn("disabled;", output)
104
105
106 if __name__ == '__main__':
107 testlib.test_main()