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

pvital at linux.vnet.ibm.com pvital at linux.vnet.ibm.com
Mon Apr 18 19:21:55 UTC 2016


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

Update test cases to support the creation of netboot templates and creation of
guests without cdrom.

This is part of solution to Issue #372.

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

diff --git a/tests/test_template.py b/tests/test_template.py
index 158bbeb..b9bb216 100644
--- a/tests/test_template.py
+++ b/tests/test_template.py
@@ -80,6 +80,23 @@ class TemplateTests(unittest.TestCase):
         resp = self.request('/plugins/kimchi/templates', req, 'POST')
         self.assertEquals(400, resp.status)
 
+        # Create a netboot template
+        t = {'name': 'test-netboot', 'source_media': 'netboot'}
+        req = json.dumps(t)
+        resp = self.request('/plugins/kimchi/templates', req, 'POST')
+        self.assertEquals(201, resp.status)
+
+        # Verify the netboot template
+        tmpl = json.loads(
+            self.request('/plugins/kimchi/templates/test-netboot').read()
+        )
+        self.assertIsNone(tmpl['cdrom'])
+
+        # Delete the netboot template
+        resp = self.request('/plugins/kimchi/templates/test-netboot', '{}',
+                            'DELETE')
+        self.assertEquals(204, resp.status)
+
         # Create a template
         t = {'name': 'test', 'source_media': MOCK_ISO}
         req = json.dumps(t)
diff --git a/tests/test_vmtemplate.py b/tests/test_vmtemplate.py
index 503d34a..92af9e7 100644
--- a/tests/test_vmtemplate.py
+++ b/tests/test_vmtemplate.py
@@ -135,3 +135,21 @@ 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'), ('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', 'source_media': 'netboot'}
+        t = VMTemplate(args)
+        for name, val in fields:
+            self.assertEquals(val, t.info.get(name))
+
+        self.assertNotIn('cdrom', t.info.keys())
-- 
2.5.5




More information about the Kimchi-devel mailing list