[Kimchi-devel] [PATCH] [Kimchi 3/3] Update test cases to support netboot.

pvital at linux.vnet.ibm.com pvital at linux.vnet.ibm.com
Tue Feb 16 21:40:18 UTC 2016


From: Paulo Vital <pvital at linux.vnet.ibm.com>

Update test cases to support the creation of templates without CD-ROM device
information and creation of guests with cdrom set up as 'netboot'.

This is part of solution to Issue #372.

Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
---
 tests/test_template.py   | 18 ++++++++++++++----
 tests/test_vmtemplate.py | 16 ++++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/tests/test_template.py b/tests/test_template.py
index da0037e..b7a9821 100644
--- a/tests/test_template.py
+++ b/tests/test_template.py
@@ -68,12 +68,22 @@ class TemplateTests(unittest.TestCase):
         self.assertEquals(200, resp.status)
         self.assertEquals(0, len(json.loads(resp.read())))
 
-        # Create a template without cdrom and disk specified fails with 400
-        t = {'name': 'test', 'os_distro': 'ImagineOS',
-             'os_version': '1.0', 'memory': 1024, 'cpu_info': {'vcpus': 1}}
+        # Create a template without cdrom - netboot template
+        t = {'name': 'test-netboot'}
         req = json.dumps(t)
         resp = self.request('/plugins/kimchi/templates', req, 'POST')
-        self.assertEquals(400, resp.status)
+        self.assertEquals(201, resp.status)
+
+        # Verify the netboot template
+        tmpl = json.loads(
+            self.request('/plugins/kimchi/templates/test-netboot').read()
+        )
+        self.assertEquals(tmpl['cdrom'], 'netboot')
+
+        # Delete the netboot template
+        resp = self.request('/plugins/kimchi/templates/test-netboot', '{}',
+                            'DELETE')
+        self.assertEquals(204, resp.status)
 
         # Create a template
         t = {'name': 'test', 'cdrom': '/tmp/mock.iso'}
diff --git a/tests/test_vmtemplate.py b/tests/test_vmtemplate.py
index e157198..6784529 100644
--- a/tests/test_vmtemplate.py
+++ b/tests/test_vmtemplate.py
@@ -130,3 +130,19 @@ class VMTemplateTests(unittest.TestCase):
         self.assertEquals(['foo'], t.info.get('networks'))
         self.assertEquals(self.iso, t.info.get('cdrom'))
         self.assertEquals(graphics, t.info.get('graphics'))
+
+    def test_netboot_vmtemplate(self):
+        disk_bus = get_template_default('old', 'disk_bus')
+        memory = get_template_default('old', 'memory')
+        nic_model = get_template_default('old', 'nic_model')
+        fields = (('name', 'test'), ('cdrom', 'netboot'),
+                  ('os_distro', 'unknown'), ('os_version', 'unknown'),
+                  ('cpu_info', {'vcpus': 1, 'maxvcpus': 1}),
+                  ('memory', memory), ('networks', ['default']),
+                  ('disk_bus', disk_bus), ('nic_model', nic_model),
+                  ('graphics', {'type': 'vnc', 'listen': '127.0.0.1'}))
+
+        args = {'name': 'test', 'cdrom': 'netboot'}
+        t = VMTemplate(args)
+        for name, val in fields:
+            self.assertEquals(val, t.info.get(name))
-- 
2.5.0




More information about the Kimchi-devel mailing list