aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/common/test_utils.py
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-02-06 10:34:33 +0000
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-02-06 14:50:04 +0000
commit1738c931ab93816007b5434c17d46842e488424a (patch)
treea0e217e9e1d2d16c58ff3d51cf389577f105907b /yardstick/tests/unit/common/test_utils.py
parente5775e7efbc55f116b4d4ac11ff87b8d8553247e (diff)
Improve SampleVNF hugepages setup
The goal of this function is to: - Read the default hugepage size. - Set 16GB of hugepages. - Check if the status of the last action. According to [1], the default hugepage size could be read in "/proc/meminfo", always in kB. Then "/proc/sys/vm/nr_hugepages" could be used to set the number of default hugepages. [1] https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt JIRA: YARDSTICK-997 Change-Id: I762d1b16294ba1c1c2feee56610819ac358c7410 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/tests/unit/common/test_utils.py')
-rw-r--r--yardstick/tests/unit/common/test_utils.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/yardstick/tests/unit/common/test_utils.py b/yardstick/tests/unit/common/test_utils.py
index 033bb0243..b4907addc 100644
--- a/yardstick/tests/unit/common/test_utils.py
+++ b/yardstick/tests/unit/common/test_utils.py
@@ -19,6 +19,7 @@ from six.moves import configparser
import unittest
import yardstick
+from yardstick import ssh
from yardstick.common import utils
from yardstick.common import constants
@@ -1075,8 +1076,27 @@ class SafeDecodeUtf8TestCase(unittest.TestCase):
self.assertEqual('this is a byte array', out)
-def main():
- unittest.main()
-
-if __name__ == '__main__':
- main()
+class ReadMeminfoTestCase(unittest.TestCase):
+
+ MEMINFO = (b'MemTotal: 65860500 kB\n'
+ b'MemFree: 28690900 kB\n'
+ b'MemAvailable: 52873764 kB\n'
+ b'Active(anon): 3015676 kB\n'
+ b'HugePages_Total: 8\n'
+ b'Hugepagesize: 1048576 kB')
+ MEMINFO_DICT = {'MemTotal': '65860500',
+ 'MemFree': '28690900',
+ 'MemAvailable': '52873764',
+ 'Active(anon)': '3015676',
+ 'HugePages_Total': '8',
+ 'Hugepagesize': '1048576'}
+
+ def test_read_meminfo(self):
+ ssh_client = ssh.SSH('user', 'host')
+ with mock.patch.object(ssh_client, 'get_file_obj') as \
+ mock_get_client, \
+ mock.patch.object(six, 'BytesIO',
+ return_value=six.BytesIO(self.MEMINFO)):
+ output = utils.read_meminfo(ssh_client)
+ mock_get_client.assert_called_once_with('/proc/meminfo', mock.ANY)
+ self.assertEqual(self.MEMINFO_DICT, output)