Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0572E200AC0 for ; Tue, 24 May 2016 11:49:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0406D160A2F; Tue, 24 May 2016 09:49:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 25CB6160A2D for ; Tue, 24 May 2016 11:49:08 +0200 (CEST) Received: (qmail 122 invoked by uid 500); 24 May 2016 09:49:07 -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 99417 invoked by uid 99); 24 May 2016 09:49:07 -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, 24 May 2016 09:49:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 45CAADFFD9; Tue, 24 May 2016 09:49:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dahn@apache.org To: commits@cloudstack.apache.org Date: Tue, 24 May 2016 09:49:15 -0000 Message-Id: <93cb239778f94051af213766d3b39911@git.apache.org> In-Reply-To: <9f6d5bfbd239492394945380f6b96af9@git.apache.org> References: <9f6d5bfbd239492394945380f6b96af9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [10/48] git commit: updated refs/heads/4.9-bountycastle-daan to 98bf0ca archived-at: Tue, 24 May 2016 09:49:10 -0000 Marvin script for cloudstack-9365 Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9df51faa Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9df51faa Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9df51faa Branch: refs/heads/4.9-bountycastle-daan Commit: 9df51faa8a2f0678e7927ac6ef23752b1eae8f71 Parents: 71c9c90 Author: rahul singal Authored: Mon May 9 13:24:53 2016 +0200 Committer: Nick Livens Committed: Wed May 11 07:59:38 2016 +0200 ---------------------------------------------------------------------- .../test_deploy_vm_userdata_multi_nic.py | 188 +++++++++++++++++++ 1 file changed, 188 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9df51faa/test/integration/component/test_deploy_vm_userdata_multi_nic.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_deploy_vm_userdata_multi_nic.py b/test/integration/component/test_deploy_vm_userdata_multi_nic.py new file mode 100755 index 0000000..86c0f13 --- /dev/null +++ b/test/integration/component/test_deploy_vm_userdata_multi_nic.py @@ -0,0 +1,188 @@ +# 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 for MultiNic + +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.lib.base import (Account, + Network, + NetworkOffering, + ServiceOffering, + VirtualMachine) +from marvin.lib.common import (get_domain, + get_template, + get_zone, + list_virtual_machines) +from marvin.lib.utils import cleanup_resources +from nose.plugins.attrib import attr +import base64 +import random +import string + +_multiprocess_shared_ = True + + +class TestDeployVmWithUserDataMultiNic(cloudstackTestCase): + """Tests for UserData + """ + + @classmethod + def setUpClass(cls): + cls.testClient = super(TestDeployVmWithUserDataMultiNic, cls).getClsTestClient() + cls.api_client = cls.testClient.getApiClient() + cls.test_data = cls.testClient.getParsedTestDataConfig() + + # Get Domain, Zone, Template + cls.domain = get_domain(cls.api_client) + cls.zone = get_zone( + cls.api_client, + cls.testClient.getZoneForTests()) + cls.template = get_template( + cls.api_client, + cls.zone.id, + cls.test_data["ostype"] + ) + if cls.zone.localstorageenabled: + cls.storagetype = 'local' + cls.test_data["service_offerings"][ + "tiny"]["storagetype"] = 'local' + else: + cls.storagetype = 'shared' + cls.test_data["service_offerings"][ + "tiny"]["storagetype"] = 'shared' + + cls.service_offering = ServiceOffering.create( + cls.api_client, + cls.test_data["service_offerings"]["tiny"] + ) + + # Create Network offering without userdata + cls.network_offering_nouserdata = NetworkOffering.create( + cls.api_client, + cls.test_data["network_offering"] + ) + # Enable Network offering + cls.network_offering_nouserdata.update(cls.api_client, state='Enabled') + + # Create Network Offering with all the serices + cls.network_offering_all = NetworkOffering.create( + cls.api_client, + cls.test_data["isolated_network_offering"] + ) + # Enable Network offering + cls.network_offering_all.update(cls.api_client, state='Enabled') + + cls._cleanup = [ + cls.service_offering, + cls.network_offering_nouserdata, + cls.network_offering_all + ] + + # 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)) + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.hypervisor = self.testClient.getHypervisorInfo() + self.dbclient = self.testClient.getDbConnection() + self.account = Account.create( + self.apiclient, + self.test_data["account"], + admin=True, + domainid=self.domain.id + ) + self.cleanup = [] + return + + def tearDown(self): + try: + self.account.delete(self.apiclient) + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + @attr(tags=["simulator", "devcloud", "basic", "advanced"], required_hardware="false") + def test_deployvm_multinic(self): + """Test userdata update when non default nic is without userdata for deploy and update + """ + + self.userdata = base64.b64encode(self.userdata) + + network1 = Network.create( + self.apiclient, + self.test_data["isolated_network"], + accountid=self.account.name, + domainid=self.account.domainid, + networkofferingid=self.network_offering_all.id, + zoneid=self.zone.id + ) + + self.test_data["network_without_acl"]["netmask"] = "255.255.255.128" + + network2 = Network.create( + self.apiclient, + self.test_data["network_without_acl"], + accountid=self.account.name, + domainid=self.account.domainid, + networkofferingid=self.network_offering_nouserdata.id, + gateway="10.2.1.1", + zoneid=self.zone.id + ) + + deployVmResponse = VirtualMachine.create( + self.apiclient, + services=self.test_data["virtual_machine_userdata"], + accountid=self.account.name, + domainid=self.account.domainid, + serviceofferingid=self.service_offering.id, + networkids=[str(network1.id), str(network2.id)], + templateid=self.template.id, + zoneid=self.zone.id + ) + + 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") + + try: + updateresponse = deployVmResponse.update(self.apiclient, userdata=self.userdata) + except Exception as e: + self.fail("Failed to update userdata: %s" % e) + + self.debug("virtual machine update response is: %s" % updateresponse) + + @classmethod + def tearDownClass(cls): + try: + # Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e)