Add pytest file for prepare/execute.py 73/39573/3
authorzhongjun <zhong.jun@zte.com.cn>
Fri, 18 Aug 2017 08:58:57 +0000 (16:58 +0800)
committerzhongjun <zhong.jun@zte.com.cn>
Fri, 18 Aug 2017 09:12:57 +0000 (17:12 +0800)
1.Add pytest file test_execute.py for prepare/execute.py.
2.Change the makedirs mode from 0600 to 0700 for test env.

Change-Id: Ie29e9e4b4210b170f448faf4df907e55bff1435f
Signed-off-by: zhongjun <zhong.jun@zte.com.cn>
deploy/prepare/execute.py
tests/prepare/test_execute.py [new file with mode: 0644]

index 2b46119..11939b8 100644 (file)
@@ -16,7 +16,7 @@ KOLLA_CONF_PATH = '/etc/kolla/config'
 
 def _make_dirs(path):
     if not os.path.isdir(path):
-        os.makedirs(path, mode=0644)
+        os.makedirs(path, mode=0744)
 
 
 def _write_conf_file(conf_file, conf):
diff --git a/tests/prepare/test_execute.py b/tests/prepare/test_execute.py
new file mode 100644 (file)
index 0000000..6eb2702
--- /dev/null
@@ -0,0 +1,55 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corp 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 deploy.prepare.execute
+from deploy.prepare.execute import (
+    _set_qemu_compute,
+    _set_default_floating_pool,
+    _set_trusts_auth
+)
+
+deploy.prepare.execute.KOLLA_CONF_PATH = '/tmp'
+
+
+@pytest.fixture(scope="module")
+def kolla_conf_file_nov_path():
+    return os.path.join(deploy.prepare.execute.KOLLA_CONF_PATH, 'nova')
+
+
+@pytest.fixture(scope="module")
+def kolla_conf_file_heat_dir():
+    return os.path.join(deploy.prepare.execute.KOLLA_CONF_PATH, 'heat')
+
+
+@pytest.fixture(scope="module")
+def conf_file_dir(data_root):
+    return os.path.join(data_root, 'lab_conf')
+
+
+def test__set_qemu_compute(kolla_conf_file_nov_path):
+    _set_qemu_compute()
+    exp_conf_file = os.path.join(kolla_conf_file_nov_path, 'nova-compute.conf')
+    assert os.path.isfile(exp_conf_file)
+
+
+def test__set_default_floating_pool(kolla_conf_file_nov_path, conf_file_dir):
+    network_conf_file = os.path.join(conf_file_dir, 'network_virtual1.yml')
+    _set_default_floating_pool(network_conf_file)
+    exp_conf_file = os.path.join(kolla_conf_file_nov_path, 'nova-api.conf')
+    assert os.path.isfile(exp_conf_file)
+
+
+def test__set_trusts_auth(kolla_conf_file_heat_dir):
+    _set_trusts_auth()
+    exp_conf_file_1 = os.path.join(kolla_conf_file_heat_dir, 'heat-api.conf')
+    exp_conf_file_2 = os.path.join(kolla_conf_file_heat_dir, 'heat-engine.conf')
+    assert (os.path.isfile(exp_conf_file_1) and os.path.isfile(exp_conf_file_2))