From 0c146e14c645811c02d6e3c74fd24ed5b3a2953c Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 4 Oct 2016 23:55:46 +0530 Subject: [PATCH] CLOUDSTACK-9532: Use macchinina as a template for failing tests - Switches to macchinina as template for VM in the tests - Modifies the ostype of the macchinina template to 'Other Linux (64-bit)' - Check template download status, fixes Nonetype iterable issue Signed-off-by: Rohit Yadav --- test/integration/smoke/test_internal_lb.py | 8 +- test/integration/smoke/test_privategw_acl.py | 4 +- .../smoke/test_routers_network_ops.py | 76 ++++++++++++++++-- test/integration/smoke/test_snapshots.py | 79 ++++++++++++++++--- test/integration/smoke/test_vpc_redundant.py | 62 +++++++++++++-- test/integration/smoke/test_vpc_vpn.py | 8 +- tools/marvin/marvin/lib/base.py | 5 +- 7 files changed, 205 insertions(+), 37 deletions(-) diff --git a/test/integration/smoke/test_internal_lb.py b/test/integration/smoke/test_internal_lb.py index d8a45c0fa8b..f2f93649fec 100644 --- a/test/integration/smoke/test_internal_lb.py +++ b/test/integration/smoke/test_internal_lb.py @@ -226,7 +226,7 @@ class Services: "displaytext": "macchinina kvm", "format": "qcow2", "hypervisor": "kvm", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", "requireshvm": "True" }, @@ -235,7 +235,7 @@ class Services: "displaytext": "macchinina xen", "format": "vhd", "hypervisor": "xenserver", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", "requireshvm": "True", }, @@ -244,7 +244,7 @@ class Services: "displaytext": "macchinina xen", "format": "vhd", "hypervisor": "hyperv", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", "requireshvm": "True", }, @@ -253,7 +253,7 @@ class Services: "displaytext": "macchinina vmware", "format": "ova", "hypervisor": "vmware", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", "requireshvm": "True", } diff --git a/test/integration/smoke/test_privategw_acl.py b/test/integration/smoke/test_privategw_acl.py index 9d39bdb2a6b..33a5d3f1e24 100644 --- a/test/integration/smoke/test_privategw_acl.py +++ b/test/integration/smoke/test_privategw_acl.py @@ -242,7 +242,7 @@ class TestPrivateGwACL(cloudstackTestCase): qresultset = self.dbclient.execute( "select vnet from op_dc_vnet_alloc where physical_network_id=\ - (select id from physical_network where uuid='%s' ) and taken is NULL;" % physical_network.id + (select id from physical_network where uuid='%s' ) and taken is NULL and reservation_id is NULL and account_id is NULL ORDER BY id DESC;" % physical_network.id ) vlans = qresultset vlan_1 = int(vlans[0][0]) @@ -369,7 +369,7 @@ class TestPrivateGwACL(cloudstackTestCase): self.fail("No Physical Networks found!") qresultset = self.dbclient.execute( "select vnet from op_dc_vnet_alloc where physical_network_id=\ - (select id from physical_network where uuid='%s' ) and taken is NULL;" % physical_network.id + (select id from physical_network where uuid='%s' ) and taken is NULL and reservation_id is NULL and account_id is NULL ORDER BY id DESC;" % physical_network.id ) vlans = qresultset vlan_1 = int(vlans[0][0]) diff --git a/test/integration/smoke/test_routers_network_ops.py b/test/integration/smoke/test_routers_network_ops.py index a15150d40a2..93563e29818 100644 --- a/test/integration/smoke/test_routers_network_ops.py +++ b/test/integration/smoke/test_routers_network_ops.py @@ -16,6 +16,7 @@ # under the License. # Import Local Modules +from marvin.codes import PASS, FAILED from nose.plugins.attrib import attr from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackAPI import (stopVirtualMachine, @@ -27,6 +28,7 @@ from marvin.lib.utils import (cleanup_resources, from marvin.lib.base import (ServiceOffering, VirtualMachine, Account, + Template, ServiceOffering, NATRule, NetworkACL, @@ -52,6 +54,7 @@ from marvin.lib.common import (get_zone, import time import logging + def check_router_command(virtual_machine, public_ip, ssh_command, check_string, test_case, retries=5): result = 'failed' try: @@ -63,6 +66,58 @@ def check_router_command(virtual_machine, public_ip, ssh_command, check_string, logging.debug("Result from SSH into the Virtual Machine: %s" % result) return result.count(check_string) + +class Templates: + """Test data for templates + """ + + def __init__(self): + self.templates = { + "macchinina": { + "kvm": { + "name": "tiny-kvm", + "displaytext": "macchinina kvm", + "format": "qcow2", + "hypervisor": "kvm", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "xenserver": { + "name": "tiny-xen", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "xen", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "hyperv": { + "name": "tiny-hyperv", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "hyperv", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", + "requireshvm": "True", + "ispublic": "True", + }, + "vmware": { + "name": "tiny-vmware", + "displaytext": "macchinina vmware", + "format": "ova", + "hypervisor": "vmware", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", + "requireshvm": "True", + "ispublic": "True", + }, + } + } + + class TestRedundantIsolateNetworks(cloudstackTestCase): @classmethod @@ -81,12 +136,20 @@ class TestRedundantIsolateNetworks(cloudstackTestCase): cls.domain = get_domain(cls.api_client) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype - cls.template = get_template( - cls.api_client, - cls.zone.id, - cls.services["ostype"] - ) + + macchinina = Templates().templates["macchinina"] + cls.hypervisor = cls.testClient.getHypervisorInfo() + cls.logger.debug("Downloading Template: %s from: %s" % (macchinina[cls.hypervisor.lower()], + macchinina[cls.hypervisor.lower()]["url"])) + cls.template = Template.register(cls.api_client, macchinina[cls.hypervisor.lower()], + cls.zone.id, hypervisor=cls.hypervisor.lower(), domainid=cls.domain.id) + cls.template.download(cls.api_client) + + if cls.template == FAILED: + assert False, "get_template() failed to return template" + cls.services["virtual_machine"]["zoneid"] = cls.zone.id + cls.services["virtual_machine"]["template"] = cls.template.id # Create an account, network, VM and IP addresses cls.account = Account.create( @@ -122,7 +185,8 @@ class TestRedundantIsolateNetworks(cloudstackTestCase): cls._cleanup = [ cls.service_offering, - cls.account + cls.account, + cls.template ] return diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py index 7cd56c8ff72..29a2d7286d8 100644 --- a/test/integration/smoke/test_snapshots.py +++ b/test/integration/smoke/test_snapshots.py @@ -22,6 +22,7 @@ from marvin.lib.utils import (cleanup_resources, is_snapshot_on_nfs) from marvin.lib.base import (VirtualMachine, Account, + Template, ServiceOffering, Snapshot) from marvin.lib.common import (get_domain, @@ -32,6 +33,57 @@ from marvin.lib.common import (get_domain, from marvin.lib.decoratorGenerators import skipTestIf +class Templates: + """Test data for templates + """ + + def __init__(self): + self.templates = { + "macchinina": { + "kvm": { + "name": "tiny-kvm", + "displaytext": "macchinina kvm", + "format": "qcow2", + "hypervisor": "kvm", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "xenserver": { + "name": "tiny-xen", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "xen", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "hyperv": { + "name": "tiny-hyperv", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "hyperv", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", + "requireshvm": "True", + "ispublic": "True", + }, + "vmware": { + "name": "tiny-vmware", + "displaytext": "macchinina vmware", + "format": "ova", + "hypervisor": "vmware", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", + "requireshvm": "True", + "ispublic": "True", + }, + } + } + + class TestSnapshotRootDisk(cloudstackTestCase): @classmethod @@ -52,18 +104,18 @@ class TestSnapshotRootDisk(cloudstackTestCase): cls._cleanup = [] if not cls.hypervisorNotSupported: - template = get_template( - cls.apiclient, - cls.zone.id, - cls.services["ostype"] - ) - if template == FAILED: - assert False, "get_template() failed to return template with description %s" % cls.services[ - "ostype"] + macchinina = Templates().templates["macchinina"] + cls.template = Template.register(cls.apiclient, macchinina[cls.hypervisor.lower()], + cls.zone.id, hypervisor=cls.hypervisor.lower(), domainid=cls.domain.id) + cls.template.download(cls.apiclient) + + if cls.template == FAILED: + assert False, "get_template() failed to return template" + cls.services["domainid"] = cls.domain.id cls.services["small"]["zoneid"] = cls.zone.id - cls.services["templates"]["ostypeid"] = template.ostypeid + cls.services["templates"]["ostypeid"] = cls.template.ostypeid cls.services["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc @@ -72,23 +124,26 @@ class TestSnapshotRootDisk(cloudstackTestCase): cls.services["account"], domainid=cls.domain.id ) - cls._cleanup.append(cls.account) cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["tiny"] ) - cls._cleanup.append(cls.service_offering) cls.virtual_machine = cls.virtual_machine_with_disk = \ VirtualMachine.create( cls.apiclient, cls.services["small"], - templateid=template.id, + templateid=cls.template.id, accountid=cls.account.name, domainid=cls.account.domainid, zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, mode=cls.services["mode"] ) + + cls._cleanup.append(cls.virtual_machine) + cls._cleanup.append(cls.service_offering) + cls._cleanup.append(cls.account) + cls._cleanup.append(cls.template) return @classmethod diff --git a/test/integration/smoke/test_vpc_redundant.py b/test/integration/smoke/test_vpc_redundant.py index 9e4038a32d6..2c7f4aeac61 100644 --- a/test/integration/smoke/test_vpc_redundant.py +++ b/test/integration/smoke/test_vpc_redundant.py @@ -18,6 +18,7 @@ """ Test redundancy features for VPC routers """ +from marvin.codes import PASS, FAILED from nose.plugins.attrib import attr from marvin.cloudstackTestCase import cloudstackTestCase from marvin.lib.base import (stopRouter, @@ -25,6 +26,7 @@ from marvin.lib.base import (stopRouter, destroyRouter, rebootRouter, Account, + Template, VpcOffering, VPC, ServiceOffering, @@ -191,8 +193,49 @@ class Services: "publicport": 22, "protocol": 'TCP', }, - "ostype": 'CentOS 5.3 (64-bit)', "timeout": 10, + "template": { + "kvm": { + "name": "tiny-kvm", + "displaytext": "macchinina kvm", + "format": "qcow2", + "hypervisor": "kvm", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "xenserver": { + "name": "tiny-xen", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "xen", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", + "requireshvm": "True", + "ispublic": "True", + }, + "hyperv": { + "name": "tiny-hyperv", + "displaytext": "macchinina xen", + "format": "vhd", + "hypervisor": "hyperv", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", + "requireshvm": "True", + "ispublic": "True", + }, + "vmware": { + "name": "tiny-vmware", + "displaytext": "macchinina vmware", + "format": "ova", + "hypervisor": "vmware", + "ostype": "Other Linux (64-bit)", + "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", + "requireshvm": "True", + "ispublic": "True", + } + } } @@ -210,17 +253,22 @@ class TestVPCRedundancy(cloudstackTestCase): # Get Zone, Domain and templates 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.services["ostype"]) + + cls.hypervisor = cls.testClient.getHypervisorInfo() + cls.template = Template.register(cls.api_client, cls.services["template"][cls.hypervisor.lower( + )], cls.zone.id, hypervisor=cls.hypervisor.lower(), domainid=cls.domain.id) + cls.template.download(cls.api_client) + + if cls.template == FAILED: + assert False, "get_template() failed to return template" + cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"]) - cls._cleanup = [cls.service_offering] + cls._cleanup = [cls.service_offering, cls.template] cls.logger = logging.getLogger('TestVPCRedundancy') cls.stream_handler = logging.StreamHandler() @@ -592,7 +640,7 @@ class TestVPCRedundancy(cloudstackTestCase): gc_interval = Configurations.list(self.apiclient, name="network.gc.interval") self.logger.debug("network.gc.wait is ==> %s" % gc_wait) - self.logger.debug("network.gc.interval is ==> %s" % gc_wait) + self.logger.debug("network.gc.interval is ==> %s" % gc_interval) total_sleep = 120 if gc_wait and gc_interval: diff --git a/test/integration/smoke/test_vpc_vpn.py b/test/integration/smoke/test_vpc_vpn.py index a0639d52263..966f40d4071 100644 --- a/test/integration/smoke/test_vpc_vpn.py +++ b/test/integration/smoke/test_vpc_vpn.py @@ -222,7 +222,7 @@ class Services: "displaytext": "macchinina kvm", "format": "qcow2", "hypervisor": "kvm", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-kvm.qcow2.bz2", "requireshvm": "True", }, @@ -232,7 +232,7 @@ class Services: "displaytext": "macchinina xen", "format": "vhd", "hypervisor": "xen", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2", "requireshvm": "True", }, @@ -242,7 +242,7 @@ class Services: "displaytext": "macchinina xen", "format": "vhd", "hypervisor": "hyperv", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-hyperv.vhd.zip", "requireshvm": "True", }, @@ -252,7 +252,7 @@ class Services: "displaytext": "macchinina vmware", "format": "ova", "hypervisor": "vmware", - "ostype": "Other PV (64-bit)", + "ostype": "Other Linux (64-bit)", "url": "http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova", "requireshvm": "True", } diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 91e7fdcee21..3b81b978e4b 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -1250,7 +1250,7 @@ class Template: if isinstance(template_response, list): template = template_response[0] - if retries >=0 and not hasattr(template, 'status'): + if not hasattr(template, 'status') or not template or not template.status: retries = retries - 1 continue @@ -1390,9 +1390,10 @@ class Iso: if isinstance(iso_response, list): response = iso_response[0] - if retries >= 0 and not hasattr(response, 'status'): + if not hasattr(response, 'status') or not response or not response.status: retries = retries - 1 continue + # Check whether download is in progress(for Ex:10% Downloaded) # or ISO is 'Successfully Installed' if response.status == 'Successfully Installed' and response.isready: