From 1738c931ab93816007b5434c17d46842e488424a Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 6 Feb 2018 10:34:33 +0000 Subject: 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 --- yardstick/tests/unit/common/test_utils.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'yardstick/tests/unit/common/test_utils.py') 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) -- cgit 1.2.3-korg