blob: 54eb5b3fa2d235a46fe2550f0f7c075590f0ab65 [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}
32config.underlay.ssh_keys = [
33 {"public": "AAAARRRGGHHHhh", "private": "--- BLABLA-KEY ---"}
34]
35
36
37def find_yaml_paths():
38 exts = ['.yml', '.yaml']
39 for root, subFolder, files in os.walk('./tcp_tests/templates/'):
40 for filename in files:
41 if any([filename.endswith(ext) for ext in exts]):
42 yield str(os.path.join(root, filename))
43
44
45@pytest.mark.parametrize("yaml_path", find_yaml_paths())
46@pytest.mark.unit_tests
47@mock.patch('os.environ', autospec=True)
48def test_jinja_render_yaml_file(mock_os_environ, yaml_path):
49 def os_environ_getitem(name):
50 return "=< Mock value >="
51
52 def os_environ_get(name, default_value):
53 return default_value or "=< Mock value >="
54
55 mock_os_environ.__getitem__ = mock.Mock(side_effect=os_environ_getitem)
56 mock_os_environ.get = mock.Mock(side_effect=os_environ_get)
57
58 options = {
59 'config': config,
60 }
61 env_config.yaml_template_load(yaml_path, options=options,
62 log_env_vars=False)