cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanj...@apache.org
Subject git commit: updated refs/heads/master to cc9c868
Date Wed, 26 Aug 2015 12:14:06 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 5f04aa568 -> cc9c86859


verify that when createTemplate is ued to create templates with same name, all of them fet
unique_name under vm_template table so that templates with same name does not get deleted
during template sync
This closes #688


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cc9c8685
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cc9c8685
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cc9c8685

Branch: refs/heads/master
Commit: cc9c8685906e1b3cbe479e34a20b2feb93035966
Parents: 5f04aa5
Author: manasaVeloori <manasa1084@gmail.com>
Authored: Thu Aug 13 10:56:18 2015 +0530
Committer: sanjeev <sanjeev@apache.org>
Committed: Wed Aug 26 17:43:14 2015 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_templates.py | 85 +++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cc9c8685/test/integration/smoke/test_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py
index 4d91d59..1452829 100644
--- a/test/integration/smoke/test_templates.py
+++ b/test/integration/smoke/test_templates.py
@@ -34,9 +34,54 @@ from nose.plugins.attrib import attr
 import urllib
 #Import System modules
 import time
+from marvin.cloudstackAPI import (createTemplate, listOsTypes)
 
 _multiprocess_shared_ = True
 
+# Function to create template with name existing in test_data without any extensions
+
+
+def create(apiclient, services, volumeid=None, account=None, domainid=None, projectid=None):
+    cmd = createTemplate.createTemplateCmd()
+    cmd.displaytext = services["displaytext"]
+    cmd.name = services["name"]
+    if "ostypeid" in services:
+        cmd.ostypeid = services["ostypeid"]
+    elif "ostype" in services:
+        sub_cmd = listOsTypes.listOsTypesCmd()
+        sub_cmd.description = services["ostype"]
+        ostypes = apiclient.listOsTypes(sub_cmd)
+
+        if not isinstance(ostypes, list):
+            raise Exception(
+                "Unable to find Ostype id with desc: %s" % services["ostype"]
+            )
+        cmd.ostypeid = ostypes[0].id
+    else:
+        raise Exception(
+            "Unable to find Ostype is required for creating template")
+
+    cmd.isfeatured = services[
+        "isfeatured"] if "isfeatured" in services else False
+
+    cmd.ispublic = services[
+        "ispublic"] if "ispublic" in services else False
+    cmd.isextractable = services[
+        "isextractable"] if "isextractable" in services else False
+    cmd.passwordenabled = services[
+        "passwordenabled"] if "passwordenabled" in services else False
+
+    if volumeid:
+        cmd.volumeid = volumeid
+    if account:
+        cmd.account = account
+    if domainid:
+        cmd.domainid = domainid
+    if projectid:
+        cmd.projectid = projectid
+    return apiclient.createTemplate(cmd)
+
+
 class TestCreateTemplate(cloudstackTestCase):
 
     def setUp(self):
@@ -148,6 +193,46 @@ class TestCreateTemplate(cloudstackTestCase):
         return
 
     @attr(tags = ["advanced", "advancedns", "smoke"], required_hardware="false")
+    def test_CreateTemplateWithDuplicateName(self):
+        """Test when createTemplate is used to create templates having the same name all
of them get
+        different unique names so that the templates with same name does not get deleted
during template sync"""
+
+        #1. Create 2 templates with same name
+        #2. check the db that the templates with same name have different unique_name
+
+        #Create templates from Virtual machine and Volume ID
+        template1 = create(self.apiclient,
+                           self.services["template"],
+                           self.volume.id,
+                           account=self.account.name)
+        template2 = create(self.apiclient,
+                           self.services["template"],
+                           self.volume.id,
+                           account=self.account.name)
+
+        self.debug("Created template with ID: %s" % template1.id)
+        self.debug("Created template with ID: %s" % template2.id)
+
+        self.assertEqual(
+            template1.name, template2.name, "Created templates with same name")
+
+        self.debug("select unique_name from vm_template where name='%s';"
+                   % template1.name)
+
+        #Db query to check for unique_name for the templates with same name
+
+        qresultset = self.dbclient.execute("select unique_name from vm_template where name='%s'
and removed is NULL ;"
+                                          % template1.name)
+
+
+        self.debug("unique_name of template1 is '%s' and unique_name of template2 is '%s'",
qresultset[0],
+                    qresultset[1])
+
+        self.assertNotEqual(qresultset[0], qresultset[1],
+                            "unique names are different")
+
+
+    @attr(tags = ["advanced", "advancedns", "smoke"], required_hardware="false")
     def test_01_create_template(self):
         """Test create public & private template
         """


Mime
View raw message