0fcb1e
From 88b9be29036a3580a8bccd31986fc30faa9852df Mon Sep 17 00:00:00 2001
0fcb1e
From: mbhalodi <mbhalodi@redhat.com>
0fcb1e
Date: Tue, 14 Feb 2023 15:04:58 +0530
0fcb1e
Subject: [PATCH] ipatests: ensure that ipa automember-rebuild prints a warning
0fcb1e
0fcb1e
ipa automember-rebuild now prints a warning about CPU usage.
0fcb1e
Ensure that the warning is properly displayed.
0fcb1e
0fcb1e
Related: https://pagure.io/freeipa/issue/9320
0fcb1e
0fcb1e
Signed-off-by: mbhalodi <mbhalodi@redhat.com>
0fcb1e
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
0fcb1e
---
0fcb1e
 ipatests/test_integration/test_automember.py | 13 ++++++++++---
0fcb1e
 1 file changed, 10 insertions(+), 3 deletions(-)
0fcb1e
0fcb1e
diff --git a/ipatests/test_integration/test_automember.py b/ipatests/test_integration/test_automember.py
0fcb1e
index f013964140714db046a1aa6a92409244b2137727..7acd0d7bf895fec970f2bda8b54f4496280525b6 100644
0fcb1e
--- a/ipatests/test_integration/test_automember.py
0fcb1e
+++ b/ipatests/test_integration/test_automember.py
0fcb1e
@@ -10,6 +10,9 @@ from ipapython.dn import DN
0fcb1e
 from ipatests.pytest_ipa.integration import tasks
0fcb1e
 from ipatests.test_integration.base import IntegrationTest
0fcb1e
 
0fcb1e
+msg = ('IMPORTANT: In case of a high number of users, hosts or '
0fcb1e
+       'groups, the operation may require high CPU usage.')
0fcb1e
+
0fcb1e
 
0fcb1e
 class TestAutounmembership(IntegrationTest):
0fcb1e
     """Tests for autounmembership feature.
0fcb1e
@@ -206,11 +209,13 @@ class TestAutounmembership(IntegrationTest):
0fcb1e
             assert self.is_user_member_of_group(user2, group1)
0fcb1e
 
0fcb1e
             # Running automember-build so that user is part of correct group
0fcb1e
-            self.master.run_command(['ipa', 'automember-rebuild',
0fcb1e
-                                     '--users=%s' % user2])
0fcb1e
+            result = self.master.run_command(['ipa', 'automember-rebuild',
0fcb1e
+                                              '--users=%s' % user2])
0fcb1e
             assert self.is_user_member_of_group(user2, group2)
0fcb1e
             assert not self.is_user_member_of_group(user2, group1)
0fcb1e
 
0fcb1e
+            assert msg in result.stdout_text
0fcb1e
+
0fcb1e
         finally:
0fcb1e
             # testcase cleanup
0fcb1e
             self.remove_user_automember(user2, raiseonerr=False)
0fcb1e
@@ -240,12 +245,14 @@ class TestAutounmembership(IntegrationTest):
0fcb1e
             assert self.is_host_member_of_hostgroup(host2, hostgroup1)
0fcb1e
 
0fcb1e
             # Running the automember-build so host is part of correct hostgroup
0fcb1e
-            self.master.run_command(
0fcb1e
+            result = self.master.run_command(
0fcb1e
                 ['ipa', 'automember-rebuild', '--hosts=%s' % host2]
0fcb1e
             )
0fcb1e
             assert self.is_host_member_of_hostgroup(host2, hostgroup2)
0fcb1e
             assert not self.is_host_member_of_hostgroup(host2, hostgroup1)
0fcb1e
 
0fcb1e
+            assert msg in result.stdout_text
0fcb1e
+
0fcb1e
         finally:
0fcb1e
             # testcase cleanup
0fcb1e
             self.remove_host_automember(host2, raiseonerr=False)
0fcb1e
-- 
0fcb1e
2.39.1
0fcb1e