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 3E951F14C for ; Thu, 11 Apr 2013 22:13:20 +0000 (UTC) Received: (qmail 95293 invoked by uid 500); 11 Apr 2013 22:13:11 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 95254 invoked by uid 500); 11 Apr 2013 22:13: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 94785 invoked by uid 99); 11 Apr 2013 22:13:10 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Apr 2013 22:13:10 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C98C4880EBE; Thu, 11 Apr 2013 22:13:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bfederle@apache.org To: commits@cloudstack.apache.org Date: Thu, 11 Apr 2013 22:13:44 -0000 Message-Id: <610386745b3041d1bbe7801bcd518b91@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [36/48] git commit: updated refs/heads/ui-vm-affinity to 96999be affinity group tests moved into the test folder Signed-off-by: Prasanna Santhanam Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e52bf522 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e52bf522 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e52bf522 Branch: refs/heads/ui-vm-affinity Commit: e52bf5223848ec4f470499ae2aaef8258e724c3f Parents: d38bf8a Author: Prasanna Santhanam Authored: Fri Apr 5 15:17:20 2013 +0530 Committer: Prachi Damle Committed: Thu Apr 11 13:23:30 2013 -0700 ---------------------------------------------------------------------- test/integration/smoke/test_affinity_groups.py | 157 +++++++++++++++ .../demo/live/testDeployVMWithAffinityGroup.py | 157 --------------- .../marvin/sandbox/demo/live/testaffinitygroup.cfg | 45 ---- 3 files changed, 157 insertions(+), 202 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e52bf522/test/integration/smoke/test_affinity_groups.py ---------------------------------------------------------------------- diff --git a/test/integration/smoke/test_affinity_groups.py b/test/integration/smoke/test_affinity_groups.py new file mode 100644 index 0000000..432751c --- /dev/null +++ b/test/integration/smoke/test_affinity_groups.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + + +import marvin +from marvin.cloudstackTestCase import * +from marvin.remoteSSHClient import remoteSSHClient +import hashlib +import random + +class TestDeployVmWithAffinityGroup(cloudstackTestCase): + """ + This test deploys a virtual machine into a user account + using the small service offering and builtin template + """ + def setUp(self): + """ + CloudStack internally saves its passwords in md5 form and that is how we + specify it in the API. Python's hashlib library helps us to quickly hash + strings as follows + """ + mdf = hashlib.md5() + mdf.update('password') + mdf_pass = mdf.hexdigest() + + self.apiClient = self.testClient.getApiClient() #Get ourselves an API client + + self.acct = createAccount.createAccountCmd() #The createAccount command + self.acct.accounttype = 0 #We need a regular user. admins have accounttype=1 + self.acct.firstname = 'test' + self.acct.lastname = 'user' #What's up doc? + self.acct.password = mdf_pass #The md5 hashed password string + self.acct.username = 'testuser' + self.acct.email = 'testuser@xyz.com' + self.acct.account = 'testacct' + self.acct.domainid = 1 #The default ROOT domain + self.acctResponse = self.apiClient.createAccount(self.acct) + # And upon successful creation we'll log a helpful message in our logs + # using the default debug logger of the test framework + self.debug("successfully created account: %s, user: %s, id: \ + %s"%(self.acctResponse.account.account, \ + self.acctResponse.account.username, \ + self.acctResponse.account.id)) + + + self.zone = listZones.listZonesCmd() + self.zone.uuid = self.apiClient.listZones(self.zone)[0].id + + self.service_offering = listServiceOfferings.listServiceOfferingsCmd() + self.service_offering.uuid = self.apiClient.listServiceOfferings(self.service_offering)[0].id + + self.template = listTemplates.listTemplatesCmd() + self.template.templatefilter = 'featured' + self.template.name = 'CentOS' + self.template.uuid = self.apiClient.listTemplates(self.template)[0].id + + def test_DeployVm(self): + """ + Let's start by defining the attributes of our VM that we will be + deploying on CloudStack. We will be assuming a single zone is available + and is configured and all templates are Ready + + The hardcoded values are used only for brevity. + + First create the host anti-affinity group for this account + """ + createAGCmd = createAffinityGroup.createAffinityGroupCmd() + createAGCmd.name = 'webvms1' + createAGCmd.type = 'host anti-affinity' + createAGCmd.account = self.acct.account + createAGCmd.domainid = self.acct.domainid + + createAGResponse = self.apiClient.createAffinityGroup(createAGCmd) + self.debug("AffinityGroup %s was created in the job %s"%(createAGResponse.id, createAGResponse.jobid)) + + + deployVmCmd = deployVirtualMachine.deployVirtualMachineCmd() + deployVmCmd.zoneid = self.zone.uuid + deployVmCmd.templateid = self.template.uuid #CentOS 5.6 builtin + deployVmCmd.serviceofferingid = self.service_offering.uuid + deployVmCmd.account = self.acct.account + deployVmCmd.domainid = self.acct.domainid + deployVmCmd.affinitygroupnames=[] + deployVmCmd.affinitygroupnames.append(str(createAGResponse.name)) + deployVmResponse = self.apiClient.deployVirtualMachine(deployVmCmd) + self.debug("VM %s was deployed in the job %s"%(deployVmResponse.id, deployVmResponse.jobid)) + + # At this point our VM is expected to be Running. Let's find out what + # listVirtualMachines tells us about VMs in this account + + listVmCmd = listVirtualMachines.listVirtualMachinesCmd() + listVmCmd.id = deployVmResponse.id + listVmResponse = self.apiClient.listVirtualMachines(listVmCmd) + + self.assertNotEqual(len(listVmResponse), 0, "Check if the list API \ + returns a non-empty response") + + vm = listVmResponse[0] + self.assertEqual(vm.state, "Running", "Check if VM has reached Running state in CS") + + VM1hostid = vm.hostid + + #Deploy another VM in same affinity group + deployVm2Cmd = deployVirtualMachine.deployVirtualMachineCmd() + deployVm2Cmd.zoneid = self.zone.uuid + deployVm2Cmd.templateid = self.template.uuid #CentOS 5.6 builtin + deployVm2Cmd.serviceofferingid = self.service_offering.uuid + deployVm2Cmd.account = self.acct.account + deployVm2Cmd.domainid = self.acct.domainid + deployVm2Cmd.affinitygroupnames=[] + deployVm2Cmd.affinitygroupnames.append(str(createAGResponse.name)) + + deployVm2Response = self.apiClient.deployVirtualMachine(deployVm2Cmd) + self.debug("VM2 %s was deployed in the job %s"%(deployVm2Response.id, deployVm2Response.jobid)) + + # At this point our VM is expected to be Running. Let's find out what + # listVirtualMachines tells us about VMs in this account + + listVm2Cmd = listVirtualMachines.listVirtualMachinesCmd() + listVm2Cmd.id = deployVm2Response.id + listVm2Response = self.apiClient.listVirtualMachines(listVm2Cmd) + + self.assertNotEqual(len(listVm2Response), 0, "Check if the list API \ + returns a non-empty response") + + vm2 = listVm2Response[0] + self.assertEqual(vm2.state, "Running", "Check if VM has reached Running state in CS") + + VM2hostid = vm2.hostid + + self.assertNotEqual(VM1hostid, VM2hostid, "The hosts of the 2 VM's in the host anti-affinity group are not different, test failed") + + def tearDown(self): + """ + And finally let us cleanup the resources we created by deleting the + account. All good unittests are atomic and rerunnable this way + """ + deleteAcct = deleteAccount.deleteAccountCmd() + deleteAcct.id = self.acctResponse.account.id + self.apiClient.deleteAccount(deleteAcct) + self.testClient.close() http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e52bf522/tools/marvin/marvin/sandbox/demo/live/testDeployVMWithAffinityGroup.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/sandbox/demo/live/testDeployVMWithAffinityGroup.py b/tools/marvin/marvin/sandbox/demo/live/testDeployVMWithAffinityGroup.py deleted file mode 100644 index 93c6571..0000000 --- a/tools/marvin/marvin/sandbox/demo/live/testDeployVMWithAffinityGroup.py +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env python -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - - - -import marvin -from marvin.cloudstackTestCase import * -from marvin.remoteSSHClient import remoteSSHClient -import hashlib -import random - -class TestDeployVmWithAffinityGroup(cloudstackTestCase): - """ - This test deploys a virtual machine into a user account - using the small service offering and builtin template - """ - def setUp(self): - """ - CloudStack internally saves its passwords in md5 form and that is how we - specify it in the API. Python's hashlib library helps us to quickly hash - strings as follows - """ - mdf = hashlib.md5() - mdf.update('password') - mdf_pass = mdf.hexdigest() - - self.apiClient = self.testClient.getApiClient() #Get ourselves an API client - - self.acct = createAccount.createAccountCmd() #The createAccount command - self.acct.accounttype = 0 #We need a regular user. admins have accounttype=1 - self.acct.firstname = 'test' - self.acct.lastname = 'user' #What's up doc? - self.acct.password = mdf_pass #The md5 hashed password string - self.acct.username = 'testuser' - self.acct.email = 'testuser@xyz.com' - self.acct.account = 'testacct' - self.acct.domainid = 1 #The default ROOT domain - self.acctResponse = self.apiClient.createAccount(self.acct) - # And upon successful creation we'll log a helpful message in our logs - # using the default debug logger of the test framework - self.debug("successfully created account: %s, user: %s, id: \ - %s"%(self.acctResponse.account.account, \ - self.acctResponse.account.username, \ - self.acctResponse.account.id)) - - - self.zone = listZones.listZonesCmd() - self.zone.uuid = self.apiClient.listZones(self.zone)[0].id - - self.service_offering = listServiceOfferings.listServiceOfferingsCmd() - self.service_offering.uuid = self.apiClient.listServiceOfferings(self.service_offering)[0].id - - self.template = listTemplates.listTemplatesCmd() - self.template.templatefilter = 'featured' - self.template.name = 'CentOS' - self.template.uuid = self.apiClient.listTemplates(self.template)[0].id - - def test_DeployVm(self): - """ - Let's start by defining the attributes of our VM that we will be - deploying on CloudStack. We will be assuming a single zone is available - and is configured and all templates are Ready - - The hardcoded values are used only for brevity. - - First create the host anti-affinity group for this account - """ - createAGCmd = createAffinityGroup.createAffinityGroupCmd() - createAGCmd.name = 'webvms1' - createAGCmd.type = 'host anti-affinity' - createAGCmd.account = self.acct.account - createAGCmd.domainid = self.acct.domainid - - createAGResponse = self.apiClient.createAffinityGroup(createAGCmd) - self.debug("AffinityGroup %s was created in the job %s"%(createAGResponse.id, createAGResponse.jobid)) - - - deployVmCmd = deployVirtualMachine.deployVirtualMachineCmd() - deployVmCmd.zoneid = self.zone.uuid - deployVmCmd.templateid = self.template.uuid #CentOS 5.6 builtin - deployVmCmd.serviceofferingid = self.service_offering.uuid - deployVmCmd.account = self.acct.account - deployVmCmd.domainid = self.acct.domainid - deployVmCmd.affinitygroupnames=[] - deployVmCmd.affinitygroupnames.append(str(createAGResponse.name)) - deployVmResponse = self.apiClient.deployVirtualMachine(deployVmCmd) - self.debug("VM %s was deployed in the job %s"%(deployVmResponse.id, deployVmResponse.jobid)) - - # At this point our VM is expected to be Running. Let's find out what - # listVirtualMachines tells us about VMs in this account - - listVmCmd = listVirtualMachines.listVirtualMachinesCmd() - listVmCmd.id = deployVmResponse.id - listVmResponse = self.apiClient.listVirtualMachines(listVmCmd) - - self.assertNotEqual(len(listVmResponse), 0, "Check if the list API \ - returns a non-empty response") - - vm = listVmResponse[0] - self.assertEqual(vm.state, "Running", "Check if VM has reached Running state in CS") - - VM1hostid = vm.hostid - - #Deploy another VM in same affinity group - deployVm2Cmd = deployVirtualMachine.deployVirtualMachineCmd() - deployVm2Cmd.zoneid = self.zone.uuid - deployVm2Cmd.templateid = self.template.uuid #CentOS 5.6 builtin - deployVm2Cmd.serviceofferingid = self.service_offering.uuid - deployVm2Cmd.account = self.acct.account - deployVm2Cmd.domainid = self.acct.domainid - deployVm2Cmd.affinitygroupnames=[] - deployVm2Cmd.affinitygroupnames.append(str(createAGResponse.name)) - - deployVm2Response = self.apiClient.deployVirtualMachine(deployVm2Cmd) - self.debug("VM2 %s was deployed in the job %s"%(deployVm2Response.id, deployVm2Response.jobid)) - - # At this point our VM is expected to be Running. Let's find out what - # listVirtualMachines tells us about VMs in this account - - listVm2Cmd = listVirtualMachines.listVirtualMachinesCmd() - listVm2Cmd.id = deployVm2Response.id - listVm2Response = self.apiClient.listVirtualMachines(listVm2Cmd) - - self.assertNotEqual(len(listVm2Response), 0, "Check if the list API \ - returns a non-empty response") - - vm2 = listVm2Response[0] - self.assertEqual(vm2.state, "Running", "Check if VM has reached Running state in CS") - - VM2hostid = vm2.hostid - - self.assertNotEqual(VM1hostid, VM2hostid, "The hosts of the 2 VM's in the host anti-affinity group are not different, test failed") - - def tearDown(self): - """ - And finally let us cleanup the resources we created by deleting the - account. All good unittests are atomic and rerunnable this way - """ - deleteAcct = deleteAccount.deleteAccountCmd() - deleteAcct.id = self.acctResponse.account.id - self.apiClient.deleteAccount(deleteAcct) - self.testClient.close() http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e52bf522/tools/marvin/marvin/sandbox/demo/live/testaffinitygroup.cfg ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/sandbox/demo/live/testaffinitygroup.cfg b/tools/marvin/marvin/sandbox/demo/live/testaffinitygroup.cfg deleted file mode 100644 index a814016..0000000 --- a/tools/marvin/marvin/sandbox/demo/live/testaffinitygroup.cfg +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# This config is designed to run as an advanced network, with management server in devcloud -# It also requires an 'apt-get install dnsmasq' to run a resolver in devcloud for internal dns - -{ - "dbSvr": { - "dbSvr": "127.0.0.1", - "passwd": "cloud", - "db": "cloud", - "port": 3306, - "user": "cloud" - }, - "logger": [ - { - "name": "TestClient", - "file": "C:\\var\\log\\testclient.log" - }, - { - "name": "TestCase", - "file": "C:\\var\\log\\testcase.log" - } - ], - "mgtSvr": [ - { - "mgtSvrIp": "127.0.0.1", - "port": 8096 - } - ] -}