diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/openrc_conf/admin-openrc.sh | 8 | ||||
-rw-r--r-- | tests/data/openrc_conf/globals_odl.yml | 2 | ||||
-rw-r--r-- | tests/unit/post/test_post_execute.py | 9 | ||||
-rw-r--r-- | tests/unit/test_daisy_server.py | 9 | ||||
-rw-r--r-- | tests/unit/test_environment.py | 9 | ||||
-rw-r--r-- | tests/unit/test_placeholder.py | 10 | ||||
-rw-r--r-- | tests/unit/test_tempest.py | 28 |
7 files changed, 65 insertions, 10 deletions
diff --git a/tests/data/openrc_conf/admin-openrc.sh b/tests/data/openrc_conf/admin-openrc.sh index 3db0bcf3..2440fda8 100644 --- a/tests/data/openrc_conf/admin-openrc.sh +++ b/tests/data/openrc_conf/admin-openrc.sh @@ -1,3 +1,11 @@ +############################################################################## +# Copyright (c) 2018 ZTE Corporation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## export OS_PROJECT_DOMAIN_NAME=Default export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_NAME=admin diff --git a/tests/data/openrc_conf/globals_odl.yml b/tests/data/openrc_conf/globals_odl.yml index 588dd927..2598ccbb 100644 --- a/tests/data/openrc_conf/globals_odl.yml +++ b/tests/data/openrc_conf/globals_odl.yml @@ -11,3 +11,5 @@ neutron_external_interface: ens8 openstack_release: 4.0.2 storage_interface: ens3 tunnel_interface: ens3 +opendaylight_haproxy_restconf_port: '8087' +opendaylight_haproxy_restconf_port_backup: '8181' diff --git a/tests/unit/post/test_post_execute.py b/tests/unit/post/test_post_execute.py index 55e345a2..0ca00941 100644 --- a/tests/unit/post/test_post_execute.py +++ b/tests/unit/post/test_post_execute.py @@ -169,9 +169,12 @@ def test__config_kolla_admin_openrc(globals_file_name, openrc_conf_file_dir, tmp elif globals_file_name == 'globals_odl.yml': diff = DeepDiff(src_openrc_lines, dst_openrc_lines, ignore_order=True) assert len(diff) == 1 and diff.get('iterable_item_added') is not None - assert len(diff['iterable_item_added']) == 1 - for val in diff['iterable_item_added'].values(): - assert 'export SDN_CONTROLLER_IP' in val + assert len(diff['iterable_item_added']) == 3 + diffvals = ','.join(diff['iterable_item_added'].values()) + assert 'export SDN_CONTROLLER_IP' in diffvals + assert 'export SDN_CONTROLLER_WEBPORT=' in diffvals + assert 'export SDN_CONTROLLER_RESTCONFPORT=' in diffvals + tmpdir.remove() diff --git a/tests/unit/test_daisy_server.py b/tests/unit/test_daisy_server.py index ea9c495c..007279a7 100644 --- a/tests/unit/test_daisy_server.py +++ b/tests/unit/test_daisy_server.py @@ -1,3 +1,12 @@ +############################################################################## +# Copyright (c) 2018 ZTE Corporation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + import os import pytest import mock diff --git a/tests/unit/test_environment.py b/tests/unit/test_environment.py index f7cf5985..a0b39ffd 100644 --- a/tests/unit/test_environment.py +++ b/tests/unit/test_environment.py @@ -1,3 +1,12 @@ +############################################################################## +# Copyright (c) 2018 ZTE Corporation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + import os import copy import mock diff --git a/tests/unit/test_placeholder.py b/tests/unit/test_placeholder.py index 457e464c..7fa104ff 100644 --- a/tests/unit/test_placeholder.py +++ b/tests/unit/test_placeholder.py @@ -1,2 +1,12 @@ +############################################################################## +# Copyright (c) 2018 ZTE Corporation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + def test_holder(): assert True diff --git a/tests/unit/test_tempest.py b/tests/unit/test_tempest.py index 9a70aec5..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') @@ -218,7 +221,7 @@ def test_update_hosts_interface(isbare, tmpdir): 'interfaces': [{'name': 'ens8', 'mac': '11:11:11:11:11:11', 'assigned_networks': [{'ip': '', 'name': 'EXTERNAL'}]}], 'hugepagesize': '1G', - 'hugepages': '20', + 'hugepages': '80', } assert client.hosts.get(host_id2).metadata == { 'id': host_id2, 'name': 'controller02', 'cluster_id': cluster_id, @@ -232,7 +235,7 @@ def test_update_hosts_interface(isbare, tmpdir): {'ip': '', 'name': 'physnet1'}], 'vswitch_type': 'dvs'}], 'hugepagesize': '1G', - 'hugepages': '20', + 'hugepages': '80', } assert client.hosts.get(host_id3).metadata == { 'id': host_id3, 'name': 'computer01', 'cluster_id': cluster_id, @@ -241,7 +244,7 @@ def test_update_hosts_interface(isbare, tmpdir): 'interfaces': [{'name': 'ens9', 'mac': '33:33:33:33:33:33', 'assigned_networks': [{'ip': '', 'name': 'HEARTBEAT'}]}], 'hugepagesize': '1G', - 'hugepages': '20', + 'hugepages': '80', } else: assert client.hosts.get(host_id1).metadata == { @@ -250,7 +253,7 @@ def test_update_hosts_interface(isbare, tmpdir): 'interfaces': [{'name': 'ens8', 'mac': '11:11:11:11:11:11', 'assigned_networks': [{'ip': '', 'name': 'EXTERNAL'}]}], 'hugepagesize': '1G', - 'hugepages': '20', + 'hugepages': '80', } assert client.hosts.get(host_id2).metadata == { 'id': host_id2, 'name': 'controller02', 'cluster_id': cluster_id, @@ -263,7 +266,7 @@ def test_update_hosts_interface(isbare, tmpdir): {'ip': '', 'name': 'physnet1'}], 'vswitch_type': 'dvs'}], 'hugepagesize': '1G', - 'hugepages': '20', + 'hugepages': '80', } assert client.hosts.get(host_id3).metadata == { 'id': host_id3, 'name': 'computer01', 'cluster_id': cluster_id, @@ -271,11 +274,22 @@ def test_update_hosts_interface(isbare, tmpdir): 'interfaces': [{'name': 'ens9', 'mac': '33:33:33:33:33:33', 'assigned_networks': [{'ip': '', 'name': 'HEARTBEAT'}]}], 'hugepagesize': '1G', - 'hugepages': '20', + 'hugepages': '80', } 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}), |