Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9DD42179C2 for ; Tue, 20 Jan 2015 06:20:26 +0000 (UTC) Received: (qmail 18328 invoked by uid 500); 20 Jan 2015 06:20:26 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 18193 invoked by uid 500); 20 Jan 2015 06:20:26 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 17938 invoked by uid 99); 20 Jan 2015 06:20:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jan 2015 06:20:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0D502E0839; Tue, 20 Jan 2015 06:20:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bhaisaab@apache.org To: commits@cloudstack.apache.org Date: Tue, 20 Jan 2015 06:20:29 -0000 Message-Id: <4d07afb1050b4e4fa219907e9833030e@git.apache.org> In-Reply-To: <8aa40f284ff74c11b17dae1ef406b5af@git.apache.org> References: <8aa40f284ff74c11b17dae1ef406b5af@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [05/12] git commit: updated refs/heads/4.5 to 4e01d61 CLOUDSTACK-7956: Fixed the script 'test_project_usage.py' - Register Template in the Project to test the Template limits on the project (cherry picked from commit 3a6f248e3af0b5d0ba3af7748fc650c44a280ec7) Signed-off-by: Rohit Yadav Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d1d28852 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d1d28852 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d1d28852 Branch: refs/heads/4.5 Commit: d1d288522de08fe014e91ed8744e38c96e3b0ed1 Parents: 6e5b9da Author: Chandan Purushothama Authored: Thu Nov 20 13:45:35 2014 -0800 Committer: Rohit Yadav Committed: Tue Jan 20 11:30:49 2015 +0530 ---------------------------------------------------------------------- .../integration/component/test_project_usage.py | 79 +++++++++++++++++--- 1 file changed, 67 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1d28852/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(