mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
simulator+marvin: include a router test
Added a test that will ensure the advanced router comes up in the account belonging to the deployed VM. It should come up with the publicip, guestip and linklocalip. Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
parent
9c755e11e5
commit
d4dc264917
@ -129,72 +129,79 @@ class Services:
|
|||||||
|
|
||||||
class TestDeployVM(cloudstackTestCase):
|
class TestDeployVM(cloudstackTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
self.apiclient = self.testClient.getApiClient()
|
cls.services = Services().services
|
||||||
self.dbclient = self.testClient.getDbConnection()
|
cls.apiclient = super(TestDeployVM, cls).getClsTestClient().getApiClient()
|
||||||
self.services = Services().services
|
|
||||||
# Get Zone, Domain and templates
|
# Get Zone, Domain and templates
|
||||||
domain = get_domain(self.apiclient, self.services)
|
domain = get_domain(cls.apiclient, cls.services)
|
||||||
zone = get_zone(self.apiclient, self.services)
|
zone = get_zone(cls.apiclient, cls.services)
|
||||||
self.services['mode'] = zone.networktype
|
cls.services['mode'] = zone.networktype
|
||||||
|
|
||||||
#if local storage is enabled, alter the offerings to use localstorage
|
#If local storage is enabled, alter the offerings to use localstorage
|
||||||
#this step is needed for devcloud
|
#this step is needed for devcloud
|
||||||
if zone.localstorageenabled == True:
|
if zone.localstorageenabled == True:
|
||||||
self.services["service_offerings"]["tiny"]["storagetype"] = 'local'
|
cls.services["service_offerings"]["tiny"]["storagetype"] = 'local'
|
||||||
self.services["service_offerings"]["small"]["storagetype"] = 'local'
|
cls.services["service_offerings"]["small"]["storagetype"] = 'local'
|
||||||
self.services["service_offerings"]["medium"]["storagetype"] = 'local'
|
cls.services["service_offerings"]["medium"]["storagetype"] = 'local'
|
||||||
|
|
||||||
template = get_template(
|
template = get_template(
|
||||||
self.apiclient,
|
cls.apiclient,
|
||||||
zone.id,
|
zone.id,
|
||||||
self.services["ostype"]
|
cls.services["ostype"]
|
||||||
)
|
)
|
||||||
# Set Zones and disk offerings
|
# Set Zones and disk offerings
|
||||||
self.services["small"]["zoneid"] = zone.id
|
cls.services["small"]["zoneid"] = zone.id
|
||||||
self.services["small"]["template"] = template.id
|
cls.services["small"]["template"] = template.id
|
||||||
|
|
||||||
self.services["medium"]["zoneid"] = zone.id
|
cls.services["medium"]["zoneid"] = zone.id
|
||||||
self.services["medium"]["template"] = template.id
|
cls.services["medium"]["template"] = template.id
|
||||||
self.services["iso"]["zoneid"] = zone.id
|
cls.services["iso"]["zoneid"] = zone.id
|
||||||
|
|
||||||
# Create Account, VMs, NAT Rules etc
|
cls.account = Account.create(
|
||||||
self.account = Account.create(
|
cls.apiclient,
|
||||||
self.apiclient,
|
cls.services["account"],
|
||||||
self.services["account"],
|
|
||||||
domainid=domain.id
|
domainid=domain.id
|
||||||
)
|
)
|
||||||
|
|
||||||
self.service_offering = ServiceOffering.create(
|
cls.service_offering = ServiceOffering.create(
|
||||||
self.apiclient,
|
cls.apiclient,
|
||||||
self.services["service_offerings"]["tiny"]
|
cls.services["service_offerings"]["tiny"]
|
||||||
)
|
)
|
||||||
# Cleanup
|
|
||||||
self.cleanup = [
|
cls.virtual_machine = VirtualMachine.create(
|
||||||
self.service_offering,
|
cls.apiclient,
|
||||||
self.account
|
cls.services["small"],
|
||||||
|
accountid=cls.account.account.name,
|
||||||
|
domainid=cls.account.account.domainid,
|
||||||
|
serviceofferingid=cls.service_offering.id,
|
||||||
|
mode=cls.services['mode']
|
||||||
|
)
|
||||||
|
|
||||||
|
cls.cleanup = [
|
||||||
|
cls.service_offering,
|
||||||
|
cls.account
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
try:
|
||||||
|
cleanup_resources(cls.apiclient, cls.cleanup)
|
||||||
|
except Exception as e:
|
||||||
|
cls.debug("Warning! Exception in tearDown: %s" % e)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.apiclient = self.testClient.getApiClient()
|
||||||
|
self.dbclient = self.testClient.getDbConnection()
|
||||||
|
|
||||||
|
|
||||||
@attr(tags = ["simulator", "devcloud", "advanced", "advancedns", "smoke", "basic", "sg"])
|
@attr(tags = ["simulator", "devcloud", "advanced", "advancedns", "smoke", "basic", "sg"])
|
||||||
def test_deploy_vm(self):
|
def test_deploy_vm(self):
|
||||||
"""Test Deploy Virtual Machine
|
"""Test Deploy Virtual Machine
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Validate the following:
|
# Validate the following:
|
||||||
# 1. Virtual Machine is accessible via SSH
|
# 1. Virtual Machine is accessible via SSH
|
||||||
# 2. listVirtualMachines returns accurate information
|
# 2. listVirtualMachines returns accurate information
|
||||||
# 3. The Cloud Database contains the valid information
|
|
||||||
|
|
||||||
self.virtual_machine = VirtualMachine.create(
|
|
||||||
self.apiclient,
|
|
||||||
self.services["small"],
|
|
||||||
accountid=self.account.account.name,
|
|
||||||
domainid=self.account.account.domainid,
|
|
||||||
serviceofferingid=self.service_offering.id,
|
|
||||||
mode=self.services['mode']
|
|
||||||
)
|
|
||||||
|
|
||||||
list_vm_response = list_virtual_machines(
|
list_vm_response = list_virtual_machines(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
id=self.virtual_machine.id
|
id=self.virtual_machine.id
|
||||||
@ -204,46 +211,60 @@ class TestDeployVM(cloudstackTestCase):
|
|||||||
"Verify listVirtualMachines response for virtual machine: %s" \
|
"Verify listVirtualMachines response for virtual machine: %s" \
|
||||||
% self.virtual_machine.id
|
% self.virtual_machine.id
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
isinstance(list_vm_response, list),
|
isinstance(list_vm_response, list),
|
||||||
True,
|
True,
|
||||||
"Check list response returns a valid list"
|
"Check list response returns a valid list"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
len(list_vm_response),
|
len(list_vm_response),
|
||||||
0,
|
0,
|
||||||
"Check VM available in List Virtual Machines"
|
"Check VM available in List Virtual Machines"
|
||||||
)
|
)
|
||||||
vm_response = list_vm_response[0]
|
vm_response = list_vm_response[0]
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|
||||||
vm_response.id,
|
vm_response.id,
|
||||||
self.virtual_machine.id,
|
self.virtual_machine.id,
|
||||||
"Check virtual machine id in listVirtualMachines"
|
"Check virtual machine id in listVirtualMachines"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
vm_response.name,
|
vm_response.name,
|
||||||
self.virtual_machine.name,
|
self.virtual_machine.name,
|
||||||
"Check virtual machine name in listVirtualMachines"
|
"Check virtual machine name in listVirtualMachines"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
vm_response.state,
|
vm_response.state,
|
||||||
'Running',
|
'Running',
|
||||||
msg="VM is not in Running state"
|
msg="VM is not in Running state"
|
||||||
)
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@attr(tags = ["simulator", "advanced"])
|
||||||
|
def test_advZoneVirtualRouter(self):
|
||||||
|
"""
|
||||||
|
Test advanced zone virtual router
|
||||||
|
1. Is Running
|
||||||
|
2. is in the account the VM was deployed in
|
||||||
|
3. Has a linklocalip, publicip and a guestip
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
|
routers = list_routers(self.apiclient, account=self.account.account.name)
|
||||||
|
self.assertTrue(len(routers) > 0, msg = "No virtual router found")
|
||||||
|
router = routers[0]
|
||||||
|
|
||||||
|
self.assertEqual(router.state, 'Running', msg="Router is not in running state")
|
||||||
|
self.assertEqual(router.account, self.account.account.name, msg="Router does not belong to the account")
|
||||||
|
|
||||||
|
#Has linklocal, public and guest ips
|
||||||
|
self.assertIsNotNone(router.linklocalip, msg="Router has no linklocal ip")
|
||||||
|
self.assertIsNotNone(router.publicip, msg="Router has no public ip")
|
||||||
|
self.assertIsNotNone(router.guestipaddress, msg="Router has no guest ip")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
pass
|
||||||
cleanup_resources(self.apiclient, self.cleanup)
|
|
||||||
except Exception as e:
|
|
||||||
self.debug("Warning! Exception in tearDown: %s" % e)
|
|
||||||
|
|
||||||
|
|
||||||
class TestVMLifeCycle(cloudstackTestCase):
|
class TestVMLifeCycle(cloudstackTestCase):
|
||||||
|
|||||||
@ -140,28 +140,6 @@
|
|||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<!--execution>
|
|
||||||
<id>pre-integration-test</id>
|
|
||||||
<phase>pre-integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>exec</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<workingDirectory>${basedir}/marvin</workingDirectory>
|
|
||||||
<executable>python</executable>
|
|
||||||
<arguments>
|
|
||||||
<argument>deployAndRun.py</argument>
|
|
||||||
<argument>-c</argument>
|
|
||||||
<argument>${user.dir}/${marvin.config}</argument>
|
|
||||||
<argument>-t</argument>
|
|
||||||
<argument>/tmp/t.log</argument>
|
|
||||||
<argument>-r</argument>
|
|
||||||
<argument>/tmp/r.log</argument>
|
|
||||||
<argument>-f</argument>
|
|
||||||
<argument>${basedir}/marvin/testSetupSuccess.py</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</execution-->
|
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user