blob: a9f10fbf59936d083dd2358ac41bdde6aaa84471 [file] [log] [blame]
Dennis Dmitrievc9b677d2017-11-21 16:42:35 +02001import pytest
2import mock
3import os
4
5from tcp_tests.helpers import env_config
6from tcp_tests import settings_oslo
7
8config = settings_oslo.load_config(config_files=[])
9config.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
26config.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 Dmitrievb6bcc5c2018-09-26 11:07:53 +000032config.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 Dmitrievc9b677d2017-11-21 16:42:35 +020042config.underlay.ssh_keys = [
43 {"public": "AAAARRRGGHHHhh", "private": "--- BLABLA-KEY ---"}
44]
45
46
47def 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)
58def 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)