summaryrefslogtreecommitdiffstats
path: root/hpa/tests/test_hpa_discovery.py
diff options
context:
space:
mode:
authorHaibin Huang <haibin.huang@intel.com>2019-11-12 17:20:03 +0800
committerHaibin Huang <haibin.huang@intel.com>2020-01-20 16:31:46 +0800
commit5f8e9379af90e81ad4a4d27b8cf6afb6edb40569 (patch)
tree17061ffe8fee62f458aee7defbb5faf3b3cccbee /hpa/tests/test_hpa_discovery.py
parent860d099f352eb762f1f181f189867ed2c3f322a9 (diff)
Make hpa discovery as plugin
Issue-ID: MULTICLOUD-695 Change-Id: I04547cfe664dfed457a228c04dfdf71c96b0ded0 Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Diffstat (limited to 'hpa/tests/test_hpa_discovery.py')
-rw-r--r--hpa/tests/test_hpa_discovery.py105
1 files changed, 105 insertions, 0 deletions
diff --git a/hpa/tests/test_hpa_discovery.py b/hpa/tests/test_hpa_discovery.py
new file mode 100644
index 00000000..c63f377f
--- /dev/null
+++ b/hpa/tests/test_hpa_discovery.py
@@ -0,0 +1,105 @@
+import unittest
+
+from hpa import hpa_discovery
+
+class TestDiscovery(unittest.TestCase):
+ def test_hpa_discovery(self):
+ """
+ Test that it can discovery hpa capability
+ """
+
+ flavor = {
+ "vcpus": 2,
+ "ram": "2048",
+ "disk": "2G",
+ "swap": False,
+ "OS-FLV-EXT-DATA:ephemeral": False
+ }
+
+ # Add cloud_extra_info in convert_vim_info
+ viminfo = {
+ "createTime": "2017-04-01 02:22:27",
+ "domain": "Default",
+ "name": "TiS_R4",
+ "password": "admin",
+ "tenant": "admin",
+ "type": "openstack",
+ "url": "http://128.224.180.14:5000/v3",
+ "userName": "admin",
+ "vendor": "WindRiver",
+ "version": "newton",
+ "vimId": "windriver-hudson-dc_RegionOne",
+ 'cloud_owner': 'windriver-hudson-dc',
+ 'cloud_region_id': 'RegionOne',
+ 'insecure': 'True',
+ 'cloud_extra_info': '{ \
+ "ovsDpdk": { \
+ "version": "v1", \
+ "arch": "Intel64", \
+ "libname": "dataProcessingAccelerationLibrary", \
+ "libversion": "v12.1" \
+ } \
+ }'
+ }
+
+ # flavor extra specs
+ extra_specs = [
+ # HPA UT1: CPU-Pinning
+ {
+ "aggregate_instance_extra_specs:storage": "local_image",
+ "capabilities:cpu_info:model": "Haswell",
+ "hw:cpu_policy": "dedicated",
+ "hw:cpu_thread_policy": "prefer"
+ },
+ # HPA UT2: CPU-Topology
+ {
+ "aggregate_instance_extra_specs:storage": "local_image",
+ "capabilities:cpu_info:model": "Haswell",
+ "hw:cpu_sockets": "2",
+ "hw:cpu_cores": "4",
+ "hw:cpu_threads": "16"
+ },
+ # HPA UT3: mem_page_size
+ {
+ "aggregate_instance_extra_specs:storage": "local_image",
+ "capabilities:cpu_info:model": "Haswell",
+ "hw:mem_page_size": "large"
+ },
+ # HPA UT4: numa_nodes
+ {
+ "aggregate_instance_extra_specs:storage": "local_image",
+ "capabilities:cpu_info:model": "Haswell",
+ "hw:numa_nodes": "2",
+ "hw:numa_cpus.0": "0,1",
+ "hw:numa_cpus.1": "2,3,4,5",
+ "hw:numa_mem.0": "2048",
+ "hw:numa_mem.1": "2048"
+ },
+ # HPA UT5: instruction set
+ {
+ "aggregate_instance_extra_specs:storage": "local_image",
+ "capabilities:cpu_info:model": "Haswell",
+ "hw:capabilities:cpu_info:features": "avx,acpi"
+ },
+ # HPA UT6: pci passthrough
+ {
+ "aggregate_instance_extra_specs:storage": "local_image",
+ "capabilities:cpu_info:model": "Haswell",
+ "pci_passthrough:alias": "sriov-vf-intel-8086-15b3:4"
+ },
+ # HPA UT7: sriov-nic
+ {
+ "aggregate_instance_extra_specs:sriov_nic": "sriov-nic-intel-8086-15b3-physnet-1:1",
+ "capabilities:cpu_info:model": "Haswell"
+ }
+ ]
+
+ vimtype = "windriver"
+ hpa = hpa_discovery.HPA_Discovery()
+ for extra_spec in extra_specs:
+ data = {"flavor": flavor, "extra_specs": extra_spec, "viminfo": viminfo, "vimtype": vimtype}
+ results = hpa.get_hpa_capabilities(data)
+
+if __name__ == '__main__':
+ unittest.main()
+