From 8f2ee9b2e21fbd20e088a94f5292ffeb476d2895 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 19 Apr 2018 11:11:54 +0800 Subject: Calculate hugepage num accoding to host's memory Change-Id: I49cfa3265af776e3cdea5de59096ff3257f75fb0 Signed-off-by: Alex Yang --- tests/unit/test_tempest.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'tests/unit/test_tempest.py') diff --git a/tests/unit/test_tempest.py b/tests/unit/test_tempest.py index 3c616bcd..3e229dc9 100644 --- a/tests/unit/test_tempest.py +++ b/tests/unit/test_tempest.py @@ -35,6 +35,7 @@ from deploy.tempest import ( get_hosts, get_cluster, update_hosts_interface, + get_hugepages, add_host_role, enable_cinder_backend, enable_opendaylight @@ -173,7 +174,9 @@ def test_get_cluster(): @pytest.mark.parametrize('isbare', [ (False), (True)]) -def test_update_hosts_interface(isbare, tmpdir): +@mock.patch('deploy.tempest.get_hugepages') +def test_update_hosts_interface(mock_get_hugepages, isbare, tmpdir): + mock_get_hugepages.return_value = 80 res_old_val = deploy.tempest.iso_path deploy.tempest.iso_path = os.path.join(tmpdir.dirname, tmpdir.basename) + '/' iso_file_path = os.path.join(deploy.tempest.iso_path, 'test_os.iso') @@ -276,6 +279,17 @@ def test_update_hosts_interface(isbare, tmpdir): tmpdir.remove() +@pytest.mark.parametrize('host, exp', [ + ({'memory': {'total': ' 65938504 kB'}}, 38), + ({'memory': {'total': ' 131644068 kB'}}, 76), + ({'memory': {'total': ' 100 gB'}}, 60), + ({'memory': {'total': ' 102400 mB'}}, 60), + ({'memory': {'total': ' 107374182400 B'}}, 60), + ({'memory': {'total': ' 107374182400'}}, 60)]) +def test_get_hugepages(host, exp): + assert get_hugepages(host) == exp + + @pytest.mark.parametrize('dha_host_name, cluster_id, host_id, vip, exp', [ ('controller01', 1, 0x1234, '10.20.11.11', {'nodes': [0x1234], 'cluster_id': 1, 'vip': '10.20.11.11'}), ('computer01', 1, 0x2345, '10.20.11.11', {'nodes': [0x2345], 'cluster_id': 1}), -- cgit 1.2.3-korg