You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sa...@apache.org on 2014/11/22 00:38:24 UTC
git commit: updated refs/heads/master to 3a6f248
Repository: cloudstack
Updated Branches:
refs/heads/master 9ac93d3e4 -> 3a6f248e3
CLOUDSTACK-7956: Fixed the script 'test_project_usage.py' - Register Template in the Project to test the Template limits on the project
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3a6f248e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3a6f248e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3a6f248e
Branch: refs/heads/master
Commit: 3a6f248e3af0b5d0ba3af7748fc650c44a280ec7
Parents: 9ac93d3
Author: Chandan Purushothama <Ch...@citrix.com>
Authored: Thu Nov 20 13:45:35 2014 -0800
Committer: Sangeetha Hariharan <sa...@citrix.com>
Committed: Fri Nov 21 18:24:15 2014 -0800
----------------------------------------------------------------------
.../integration/component/test_project_usage.py | 79 +++++++++++++++++---
1 file changed, 67 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3a6f248e/test/integration/component/test_project_usage.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_usage.py b/test/integration/component/test_project_usage.py
index 2627504..29d381a 100644
--- a/test/integration/component/test_project_usage.py
+++ b/test/integration/component/test_project_usage.py
@@ -39,7 +39,9 @@ from marvin.lib.base import (Project,
from marvin.lib.common import (get_domain,
get_zone,
get_template,
- list_volumes)
+ list_volumes,
+ get_builtin_template_info)
+import time
class Services:
"""Test Snapshots Services
@@ -784,23 +786,76 @@ class TestTemplateUsage(cloudstackTestCase):
"""
# Validate the following
# 1. Create a account
- # 2. Upload a template from this account. template.create event is
+ # 2. Register template in the project. template.create event is
# recorded in cloud.usage_event table for this account
# 3. Delete the template. template.delete event is recorded in
# cloud.usage_event tables for this account
# 4. Destroy the account
- #Create template from Virtual machine and Volume ID
- self.template = Template.create(
- self.userapiclient,
- self.services["templates"],
- self.volume.id,
- projectid=self.project.id
- )
- self.debug("Created template with ID: %s" % self.template.id)
+ # Register the First Template in the project
+ self.debug("Register a Template in the project")
+ builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
+ self.services["templates"]["url"] = builtin_info[0]
+ self.services["templates"]["hypervisor"] = builtin_info[1]
+ self.services["templates"]["format"] = builtin_info[2]
+
+ # Register new template
+ template = Template.register(
+ self.userapiclient,
+ self.services["templates"],
+ zoneid=self.zone.id,
+ projectid=self.project.id
+ )
+ self.debug(
+ "Registered a template of format: %s with ID: %s" % (
+ self.services["templates"]["format"],
+ template.id
+ ))
+
+ # Wait for template status to be changed across
+ time.sleep(self.services["sleep"])
+ timeout = self.services["timeout"]
+ while True:
+ list_template_response = Template.list(
+ self.apiclient,
+ templatefilter='all',
+ id=template.id,
+ zoneid=self.zone.id,
+ projectid=self.project.id,
+ )
+ if list_template_response[0].isready is True:
+ break
+ elif timeout == 0:
+ raise Exception("Template state is not ready, it is %s" % list_template_response[0].isready)
+
+ time.sleep(self.services["sleep"])
+ timeout = timeout - 1
+
+ #Verify template response to check whether template added successfully
+ self.assertEqual(
+ isinstance(list_template_response, list),
+ True,
+ "Check for list template response return valid data"
+ )
+
+ self.assertNotEqual(
+ len(list_template_response),
+ 0,
+ "Check template available in List Templates"
+ )
+
+ template_response = list_template_response[0]
+ self.assertEqual(
+ template_response.isready,
+ True,
+ "Template state is not ready, it is %s" % template_response.isready
+ )
+
+ self.debug("Created template with ID: %s" % template.id)
+
# Delete template
- self.template.delete(self.apiclient)
- self.debug("Deleted template with ID: %s" % self.template.id)
+ template.delete(self.apiclient)
+ self.debug("Deleted template with ID: %s" % template.id)
# Fetch project account ID from project UUID
self.debug(