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 EB96E173E5 for ; Thu, 9 Apr 2015 05:30:11 +0000 (UTC) Received: (qmail 75526 invoked by uid 500); 9 Apr 2015 05:30:11 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 75499 invoked by uid 500); 9 Apr 2015 05:30:11 -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 75490 invoked by uid 99); 9 Apr 2015 05:30:11 -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; Thu, 09 Apr 2015 05:30:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7DF41DFC3D; Thu, 9 Apr 2015 05:30:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sanjeev@apache.org To: commits@cloudstack.apache.org Message-Id: <25b8c172530e488594bf809cf85e7659@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to 40943e8 Date: Thu, 9 Apr 2015 05:30:11 +0000 (UTC) Repository: cloudstack Updated Branches: refs/heads/master cb2b9e870 -> 40943e85c Hosts without tag are not listed while listing the hosts for migration for instance with tag Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/40943e85 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/40943e85 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/40943e85 Branch: refs/heads/master Commit: 40943e85ca0012f590e76275bc4e3b2eef09a10b Parents: cb2b9e8 Author: sanjeev Authored: Wed Apr 8 19:07:18 2015 +0530 Committer: sanjeev Committed: Thu Apr 9 10:53:59 2015 +0530 ---------------------------------------------------------------------- test/integration/component/test_tags.py | 101 ++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40943e85/test/integration/component/test_tags.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_tags.py b/test/integration/component/test_tags.py index 19ddd56..f0fe72c 100644 --- a/test/integration/component/test_tags.py +++ b/test/integration/component/test_tags.py @@ -19,7 +19,7 @@ # Import Local Modules from nose.plugins.attrib import attr from marvin.cloudstackTestCase import cloudstackTestCase -from marvin.lib.utils import cleanup_resources +from marvin.lib.utils import cleanup_resources, validateList from marvin.lib.base import (Tag, Account, VirtualMachine, @@ -40,8 +40,9 @@ from marvin.lib.base import (Tag, from marvin.lib.common import (get_zone, get_domain, get_template, - find_storage_pool_type) -from marvin.codes import FAILED + find_storage_pool_type, + list_clusters) +from marvin.codes import FAILED, PASS import time @@ -2304,3 +2305,97 @@ class TestResourceTags(cloudstackTestCase): self.fail("Failed to delete the tag - %s" % e) return + + @attr(tags=["advanced", "basic"], required_hardware="false") + def test_23_list_untagged_host_for_vm_migration(self): + """ + @Hosts without tag are not listed while listing the hosts for migration for instance with tag + Steps: + 1.Add tag say "tag1" to host1 in a cluster with min of two hosts + 2.Create compute offering with host tag "tag1" + 3.Deploy vm with the above offering + 4.list hosts for migration for the above deployed vm + 5.All untagged hosts in the cluster must be listed as available hosts for vm migration + """ + tag = "tag1" + clusters = list_clusters(self.apiclient, zoneid=self.zone.id) + self.assertEqual( + validateList(clusters)[0], + PASS, + "list clusters returned invalid response" + ) + hosts = Host.list( + self.apiclient, + clusterid=clusters[0].id) + self.assertEqual( + validateList(hosts)[0], + PASS, + "list hosts returned invalid response" + ) + if len(hosts) < 2: + self.skipTest("Need min of two hosts to run this test") + try: + Host.update( + self.apiclient, + id=hosts[0].id, + hosttags=tag + ) + except Exception as e: + self.fail("Updating host with tags failed with error : {}".format(e)) + host_res = Host.list( + self.apiclient, + id=hosts[0].id + ) + self.assertEqual(validateList(host_res)[0], PASS, "Invalid list host response") + self.assertEqual( + host_res[0].hosttags, + tag, + "host is updated with wrong tag" + ) + self.so_with_tag = ServiceOffering.create( + self.apiclient, + self.services["service_offering"], + hosttags=tag + ) + self.so_res = ServiceOffering.list( + self.apiclient, + id=self.so_with_tag.id + ) + self.assertEqual(validateList(self.so_res)[0], PASS, "Invalid service offering response") + self.assertEqual( + self.so_res[0].hosttags, + tag, + "Service offering has not been created with host tags" + ) + self.vm = VirtualMachine.create( + self.api_client, + self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.so_with_tag.id + ) + self.cleanup.append(self.vm) + self.cleanup.append(self.so_with_tag) + self.assertEqual( + self.vm.hostid, + hosts[0].id, + "vm deployed on wrong host" + ) + hosts_for_migration = Host.listForMigration( + self.apiclient, + virtualmachineid=self.vm.id + ) + self.assertEqual( + validateList(hosts_for_migration)[0], + PASS, + "Untagged hosts are not returned as suitable hosts for vm migration\ + if it is deployed on a tagged host" + ) + host_ids_for_migration = [host.id for host in hosts_for_migration] + #Remove host on which vm was deployed (tagged host) from the hosts list + hosts.pop(0) + host_ids = [host.id for host in hosts] + for id in host_ids: + if not id in host_ids_for_migration: + self.fail("Not all hosts are available for vm migration") + return