Dennis Dmitriev | c9b677d | 2017-11-21 16:42:35 +0200 | [diff] [blame] | 1 | import pytest |
| 2 | import mock |
| 3 | import os |
| 4 | |
| 5 | from tcp_tests.helpers import env_config |
| 6 | from tcp_tests import settings_oslo |
| 7 | |
| 8 | config = settings_oslo.load_config(config_files=[]) |
| 9 | config.underlay.ssh = [ |
| 10 | {"node_name": "cfg01.cookied-dop-sl2.local", "host": "10.70.0.15"}, |
| 11 | {"node_name": "cid01.cookied-dop-sl2.local", "host": "10.70.0.91"}, |
| 12 | {"node_name": "cid02.cookied-dop-sl2.local", "host": "10.70.0.92"}, |
| 13 | {"node_name": "cid03.cookied-dop-sl2.local", "host": "10.70.0.93"}, |
| 14 | {"node_name": "ctl01.cookied-dop-sl2.local", "host": "10.70.0.11"}, |
| 15 | {"node_name": "ctl02.cookied-dop-sl2.local", "host": "10.70.0.12"}, |
| 16 | {"node_name": "ctl03.cookied-dop-sl2.local", "host": "10.70.0.13"}, |
| 17 | {"node_name": "mon01.cookied-dop-sl2.local", "host": "10.70.0.71"}, |
| 18 | {"node_name": "mon02.cookied-dop-sl2.local", "host": "10.70.0.72"}, |
| 19 | {"node_name": "mon03.cookied-dop-sl2.local", "host": "10.70.0.73"}, |
| 20 | {"node_name": "prx01.cookied-dop-sl2.local", "host": "10.70.0.81"}, |
| 21 | {"node_name": "cmp001.cookied-dop-sl2.local", "host": "10.70.0.101"}, |
| 22 | {"node_name": "cmp002.cookied-dop-sl2.local", "host": "10.70.0.102"}, |
| 23 | {"node_name": "gtw01.cookied-dop-sl2.local", "host": "10.70.0.224"} |
| 24 | ] |
| 25 | |
| 26 | config.underlay.address_pools = { |
| 27 | "admin-pool01": "10.70.0.0/24", |
| 28 | "private-pool01": "10.60.0.0/24", |
| 29 | "tenant-pool01": "10.80.0.0/24", |
| 30 | "external-pool01": "10.90.0.0/24" |
| 31 | } |
Dennis Dmitriev | b6bcc5c | 2018-09-26 11:07:53 +0000 | [diff] [blame] | 32 | config.underlay.dhcp_ranges = { |
| 33 | "admin-pool01": {"cidr": "10.70.0.0/24", |
| 34 | "start": "10.70.0.10", |
| 35 | "end": "10.70.0.200", |
| 36 | "gateway": "10.70.0.1"}, |
| 37 | "external-pool01": {"cidr": "10.90.0.0/24", |
| 38 | "start": "10.90.0.10", |
| 39 | "end": "10.90.0.200", |
| 40 | "gateway": "10.90.0.1"}, |
| 41 | } |
Dennis Dmitriev | c9b677d | 2017-11-21 16:42:35 +0200 | [diff] [blame] | 42 | config.underlay.ssh_keys = [ |
| 43 | {"public": "AAAARRRGGHHHhh", "private": "--- BLABLA-KEY ---"} |
| 44 | ] |
| 45 | |
| 46 | |
| 47 | def find_yaml_paths(): |
| 48 | exts = ['.yml', '.yaml'] |
| 49 | for root, subFolder, files in os.walk('./tcp_tests/templates/'): |
| 50 | for filename in files: |
| 51 | if any([filename.endswith(ext) for ext in exts]): |
| 52 | yield str(os.path.join(root, filename)) |
| 53 | |
| 54 | |
| 55 | @pytest.mark.parametrize("yaml_path", find_yaml_paths()) |
| 56 | @pytest.mark.unit_tests |
| 57 | @mock.patch('os.environ', autospec=True) |
| 58 | def test_jinja_render_yaml_file(mock_os_environ, yaml_path): |
| 59 | def os_environ_getitem(name): |
| 60 | return "=< Mock value >=" |
| 61 | |
| 62 | def os_environ_get(name, default_value): |
| 63 | return default_value or "=< Mock value >=" |
| 64 | |
| 65 | mock_os_environ.__getitem__ = mock.Mock(side_effect=os_environ_getitem) |
| 66 | mock_os_environ.get = mock.Mock(side_effect=os_environ_get) |
| 67 | |
| 68 | options = { |
| 69 | 'config': config, |
| 70 | } |
| 71 | env_config.yaml_template_load(yaml_path, options=options, |
| 72 | log_env_vars=False) |