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 EF45B107E4 for ; Mon, 4 Nov 2013 11:30:51 +0000 (UTC) Received: (qmail 41175 invoked by uid 500); 4 Nov 2013 11:30:49 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 41096 invoked by uid 500); 4 Nov 2013 11:30:37 -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 41089 invoked by uid 99); 4 Nov 2013 11:30:35 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Nov 2013 11:30:35 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1B9BB3A545; Mon, 4 Nov 2013 11:30:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: talluri@apache.org To: commits@cloudstack.apache.org Message-Id: <899f090c4dca4f139ff810f0a89f57f9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/4.2 to 9bf3047 Date: Mon, 4 Nov 2013 11:30:35 +0000 (UTC) Updated Branches: refs/heads/4.2 d6420cd91 -> 9bf30479f CLOUDSTACK-2272: testscript validates the vmdeployment with userdata Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9bf30479 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9bf30479 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9bf30479 Branch: refs/heads/4.2 Commit: 9bf30479fc088a8d0dc8dafebbf9de5824287f81 Parents: d6420cd Author: suresh Authored: Sat Oct 12 13:28:55 2013 +0530 Committer: SrikanteswaraRao Talluri Committed: Mon Nov 4 16:58:55 2013 +0530 ---------------------------------------------------------------------- .../component/test_deploy_vm_userdata_reg.py | 220 +++++++++++++++++++ 1 file changed, 220 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9bf30479/test/integration/component/test_deploy_vm_userdata_reg.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_deploy_vm_userdata_reg.py b/test/integration/component/test_deploy_vm_userdata_reg.py new file mode 100755 index 0000000..ca9179d --- /dev/null +++ b/test/integration/component/test_deploy_vm_userdata_reg.py @@ -0,0 +1,220 @@ +# 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 script will cover VMdeployment with Userdata tests + +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.integration.lib.base import * +from marvin.integration.lib.utils import * +from marvin.integration.lib.common import * +from nose.plugins.attrib import attr +from marvin import remoteSSHClient +import unittest +import random +import string + +_multiprocess_shared_ = True +import os + +class Services: + def __init__(self): + self.services = { + "account": { + "email": "test@test.com", + "firstname": "Test", + "lastname": "User", + "username": "test", + "password": "password", + }, + "virtual_machine": { + "displayname": "TesVM1", + "username": "root", + "password": "password", + "ssh_port": 22, + "hypervisor": 'XenServer', + "privateport": 22, + "publicport": 22, + "protocol": 'TCP', + }, + "ostype": 'CentOS 5.3 (64-bit)', + "service_offering": { + "name": "Tiny Instance", + "displaytext": "Tiny Instance", + "cpunumber": 1, + "cpuspeed": 100, + "memory": 256, + }, + } + + + + + +class TestDeployVmWithUserData(cloudstackTestCase): + """Tests for UserData + """ + + @classmethod + def setUpClass(cls): + cls.apiClient = super(TestDeployVmWithUserData, cls).getClsTestClient().getApiClient() + cls.services = Services().services + cls.zone = get_zone(cls.apiClient, cls.services) + if cls.zone.localstorageenabled: + #For devcloud since localstroage is enabled + cls.services["service_offering"]["storagetype"] = "local" + cls.service_offering = ServiceOffering.create( + cls.apiClient, + cls.services["service_offering"] + ) + cls.account = Account.create(cls.apiClient, services=cls.services["account"]) + cls.cleanup = [cls.account] + cls.template = get_template( + cls.apiClient, + cls.zone.id, + cls.services["ostype"] + ) + # Generate userdata of 2500 bytes. This is larger than the 2048 bytes limit. + # CS however allows for upto 4K bytes in the code. So this must succeed. + # Overall, the query length must not exceed 4K, for then the json decoder + # will fail this operation at the marvin client side itcls. + + + cls.userdata = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2500)) + cls.user_data_2k= ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2000)) + cls.user_data_2kl = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(1900)) + + + + @attr(tags=["simulator", "devcloud", "basic", "advanced"]) + def test_deployvm_userdata_post(self): + """Test userdata as POST, size > 2k + """ + + + self.userdata=base64.b64encode(self.userdata) + self.services["virtual_machine"]["userdata"] = self.userdata + + deployVmResponse = VirtualMachine.create( + self.apiClient, + services=self.services["virtual_machine"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + templateid=self.template.id, + zoneid=self.zone.id, + method="POST" + + ) + + vms = list_virtual_machines( + self.apiClient, + account=self.account.name, + domainid=self.account.domainid, + id=deployVmResponse.id + ) + self.assert_(len(vms) > 0, "There are no Vms deployed in the account %s" % self.account.name) + vm = vms[0] + self.assert_(vm.id == str(deployVmResponse.id), "Vm deployed is different from the test") + self.assert_(vm.state == "Running", "VM is not in Running state") + ip_addr=deployVmResponse.ipaddress + if self.zone.networktype == "Basic": + list_router_response = list_routers( + self.apiClient, + listall="true" + ) + else: + list_router_response = list_routers( + self.apiClient, + account=self.account.name, + domainid=self.account.domainid + ) + self.assertEqual( + isinstance(list_router_response, list), + True, + "Check list response returns a valid list" + ) + router = list_router_response[0] + + hosts = list_hosts( + self.apiClient, + zoneid=router.zoneid, + type='Routing', + state='Up', + id=router.hostid + ) + self.assertEqual( + isinstance(hosts, list), + True, + "Check list host returns a valid list" + ) + host = hosts[0] + self.debug("Router ID: %s, state: %s" % (router.id, router.state)) + + self.assertEqual( + router.state, + 'Running', + "Check list router response for router state" + ) + host.user="root" + host.passwd="password" + cmd="cat /var/www/html/userdata/"+deployVmResponse.ipaddress+"/user-data" + + if self.apiClient.hypervisor.lower() == 'vmware': + + try: + result = get_process_status( + self.apiClient.connection.mgtSvr, + 22, + self.apiClient.connection.user, + self.apiClient.connection.passwd, + router.linklocalip, + cmd, + hypervisor=self.apiClient.hypervisor + ) + res = str(result) + self.assertEqual(res.__contains__(self.userdata),True,"Userdata Not applied Check the failures") + + + except KeyError: + self.skipTest("Marvin configuration has no host credentials to check USERDATA") + + else: + try: + result = get_process_status( + host.ipaddress, + 22, + host.user, + host.passwd, + router.linklocalip, + cmd + ) + res = str(result) + self.assertEqual(res.__contains__(self.userdata),True,"Userdata Not applied Check the failures") + except KeyError: + self.skipTest("Marvin configuration has no host credentials to check router user data") + + + + @classmethod + def tearDownClass(cls): + try: + #Cleanup resources used + cleanup_resources(cls.apiClient, cls.cleanup) + + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e)