aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/ansible_library/modules
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-05 22:30:32 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-06 16:51:18 +0800
commit62460407a8fbcc99c154df3eabb8732c1908992e (patch)
tree081d35dc52c776999b69dd080abe7c1e7a960972 /tests/unit/ansible_library/modules
parent13dc7659e55ac6f569422fd194e35f8fdc189180 (diff)
Add ansible module `fuel`
This module will be used to generate a dynamic inventory of fuel nodes for performance testing Change-Id: Idaa491c5fc3050abfb8ba36328f2113cf2885179 Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'tests/unit/ansible_library/modules')
-rw-r--r--tests/unit/ansible_library/modules/fuel_test.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/unit/ansible_library/modules/fuel_test.py b/tests/unit/ansible_library/modules/fuel_test.py
new file mode 100644
index 00000000..6a440e0d
--- /dev/null
+++ b/tests/unit/ansible_library/modules/fuel_test.py
@@ -0,0 +1,60 @@
+###############################################################
+# Copyright (c) 2017 ZTE Corporation
+#
+# 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 json
+import os
+
+from qtip.ansible_library.modules import fuel
+
+
+def test_generate_inventory(data_root):
+ nodes = json.load(open(os.path.join(data_root, 'external', 'fuel', 'fuel-node.json')))
+ inventory = fuel.generate_inventory(nodes)
+ assert dict(inventory['hosts']) == {
+ u'ceph-osd': [u'node-26', u'node-28', u'node-27'],
+ 'cluster-4': [u'node-24',
+ u'node-26',
+ u'node-23',
+ u'node-28',
+ u'node-25',
+ u'node-27'],
+ u'compute': [u'node-26', u'node-28', u'node-27'],
+ u'controller': [u'node-24', u'node-23', u'node-25'],
+ 'hw-zte-servers': [u'node-24',
+ u'node-26',
+ u'node-23',
+ u'node-28',
+ u'node-25',
+ u'node-27'],
+ u'mongo': [u'node-24'],
+ 'node-23': [u'node-23'],
+ 'node-24': [u'node-24'],
+ 'node-25': [u'node-25'],
+ 'node-26': [u'node-26'],
+ 'node-27': [u'node-27'],
+ 'node-28': [u'node-28']}
+ assert dict(inventory['hosts_meta']) == {
+ u'node-23': {'ansible_ssh_host': u'10.20.11.10', 'cluster': 4, 'ip': u'10.20.11.10',
+ 'mac': u'74:4a:a4:01:71:61', 'name': u'Untitled (71:61)', 'online': True, 'os_platform': u'ubuntu',
+ 'status': u'ready'},
+ u'node-24': {'ansible_ssh_host': u'10.20.11.11', 'cluster': 4, 'ip': u'10.20.11.11',
+ 'mac': u'74:4a:a4:01:73:50', 'name': u'Untitled (73:50)', 'online': True, 'os_platform': u'ubuntu',
+ 'status': u'ready'},
+ u'node-25': {'ansible_ssh_host': u'10.20.11.12', 'cluster': 4, 'ip': u'10.20.11.12',
+ 'mac': u'74:4a:a4:00:d8:76', 'name': u'Untitled (d8:76)', 'online': True, 'os_platform': u'ubuntu',
+ 'status': u'ready'},
+ u'node-26': {'ansible_ssh_host': u'10.20.11.15', 'cluster': 4, 'ip': u'10.20.11.15',
+ 'mac': u'74:4a:a4:01:61:ae', 'name': u'Untitled (61:ae)', 'online': True, 'os_platform': u'ubuntu',
+ 'status': u'ready'},
+ u'node-27': {'ansible_ssh_host': u'10.20.11.13', 'cluster': 4, 'ip': u'10.20.11.13',
+ 'mac': u'74:4a:a4:01:82:c0', 'name': u'Untitled (82:c0)', 'online': True, 'os_platform': u'ubuntu',
+ 'status': u'ready'},
+ u'node-28': {'ansible_ssh_host': u'10.20.11.14', 'cluster': 4, 'ip': u'10.20.11.14',
+ 'mac': u'74:4a:a4:01:74:63', 'name': u'Untitled (74:63)', 'online': True, 'os_platform': u'ubuntu',
+ 'status': u'ready'}}