Skip to content

Commit 8df8094

Browse files
author
sanjeev
committed
Merge pull request #1218 from pritisarap12/CLOUDSTACK-9140-Testcase-to-verify-if-Dedicated-cluster-is-used-for-virtual-routers-that-belong-to-non-dedicated-account
CLOUDSTACK-9140: Testcase to verify if Dedicated cluster is used for virtual routers that belong to non dedicated account * pr/1218: CLOUDSTACK-9140: Testcase to verify if Dedicated cluster is used for virtual routers that belong to non dedicated account --Adding verification steps to make sure that vm and VR are being deployed on dedicated cluster Signed-off-by: sanjeev <[email protected]>
2 parents 4480d05 + 764afb4 commit 8df8094

File tree

1 file changed

+196
-3
lines changed

1 file changed

+196
-3
lines changed

test/integration/component/maint/testpath_disable_enable_zone.py

Lines changed: 196 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
from marvin.cloudstackTestCase import cloudstackTestCase
2222
from marvin.lib.utils import (cleanup_resources,
2323
validateList)
24+
from marvin.cloudstackAPI import (dedicateCluster,
25+
listDedicatedClusters,
26+
releaseDedicatedCluster,
27+
listAffinityGroups)
28+
2429
from marvin.lib.base import (Account,
2530
VirtualMachine,
2631
ServiceOffering,
@@ -40,7 +45,10 @@
4045
get_template,
4146
list_volumes,
4247
list_snapshots,
43-
get_builtin_template_info
48+
get_builtin_template_info,
49+
list_routers,
50+
list_virtual_machines,
51+
list_hosts
4452
)
4553

4654
from marvin.cloudstackAPI import (updateZone,
@@ -280,7 +288,7 @@ def test_01_disable_enable_zone(self):
280288
self.testdata["privatetemplate"]["hypervisor"] = builtin_info[1]
281289
self.testdata["privatetemplate"]["format"] = builtin_info[2]
282290
"""
283-
//commenting it for now will uncomment once expected behaviour is known
291+
//commenting it for now will uncomment once expected behaviour is known
284292
Template.register(
285293
self.apiclient,
286294
self.testdata["privatetemplate"],
@@ -295,7 +303,7 @@ def test_01_disable_enable_zone(self):
295303
diskofferingid=self.disk_offering.id
296304
)
297305
"""
298-
//commenting it for now will uncomment once expected behaviour is known
306+
//commenting it for now will uncomment once expected behaviour is known
299307
Iso.create(
300308
self.apiclient,
301309
self.testdata["iso2"],
@@ -1691,3 +1699,188 @@ def test_01_disable_enable_host(self):
16911699
)
16921700

16931701
return
1702+
1703+
1704+
class TestClusterDedication(cloudstackTestCase):
1705+
1706+
@classmethod
1707+
def setUpClass(cls):
1708+
testClient = super(TestClusterDedication, cls).getClsTestClient()
1709+
cls.apiclient = testClient.getApiClient()
1710+
cls.testdata = testClient.getParsedTestDataConfig()
1711+
cls.hypervisor = cls.testClient.getHypervisorInfo()
1712+
1713+
# Get Zone, Domain and templates
1714+
cls.domain = get_domain(cls.apiclient)
1715+
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
1716+
1717+
cls.template = get_template(
1718+
cls.apiclient,
1719+
cls.zone.id,
1720+
cls.testdata["ostype"])
1721+
1722+
cls.Skiptest = False
1723+
cls._cleanup = []
1724+
cls.clusters = Cluster.list(cls.apiclient, zoneid=cls.zone.id)
1725+
if len(cls.clusters) < 2:
1726+
cls.Skiptest = True
1727+
1728+
try:
1729+
# Create an account
1730+
cls.account_1 = Account.create(
1731+
cls.apiclient,
1732+
cls.testdata["account"],
1733+
domainid=cls.domain.id
1734+
)
1735+
1736+
cls._cleanup.append(cls.account_1)
1737+
1738+
cls.account_2 = Account.create(
1739+
cls.apiclient,
1740+
cls.testdata["account"],
1741+
domainid=cls.domain.id
1742+
)
1743+
1744+
cls._cleanup.append(cls.account_2)
1745+
# Create user api client of the account
1746+
cls.userapiclient_1 = testClient.getUserApiClient(
1747+
UserName=cls.account_1.name,
1748+
DomainName=cls.account_1.domain
1749+
)
1750+
cls.userapiclient_2 = testClient.getUserApiClient(
1751+
UserName=cls.account_2.name,
1752+
DomainName=cls.account_2.domain
1753+
)
1754+
1755+
# Create Service offering
1756+
cls.service_offering = ServiceOffering.create(
1757+
cls.apiclient,
1758+
cls.testdata["service_offering"],
1759+
)
1760+
cls._cleanup.append(cls.service_offering)
1761+
1762+
cls.disk_offering = DiskOffering.create(
1763+
cls.apiclient,
1764+
cls.testdata["disk_offering"],
1765+
)
1766+
1767+
cls._cleanup.append(cls.disk_offering)
1768+
1769+
except Exception as e:
1770+
cls.tearDownClass()
1771+
raise e
1772+
return
1773+
1774+
@classmethod
1775+
def tearDownClass(cls):
1776+
try:
1777+
cleanup_resources(cls.apiclient, cls._cleanup)
1778+
except Exception as e:
1779+
raise Exception("Warning: Exception during cleanup : %s" % e)
1780+
1781+
def setUp(self):
1782+
1783+
if self.Skiptest:
1784+
self.skipTest("Insufficient clusters to run the test")
1785+
1786+
self.apiclient = self.testClient.getApiClient()
1787+
self.dbclient = self.testClient.getDbConnection()
1788+
self.cleanup = []
1789+
1790+
def tearDown(self):
1791+
try:
1792+
listClusterscmd = listDedicatedClusters.listDedicatedClustersCmd()
1793+
listClusterscmd.clusterid = self.clusters[0].id
1794+
ret_list = self.apiclient.listDedicatedClusters(listClusterscmd)
1795+
if ret_list:
1796+
dedicateCmd = releaseDedicatedCluster.\
1797+
releaseDedicatedClusterCmd()
1798+
dedicateCmd.clusterid = self.clusters[0].id
1799+
self.apiclient.releaseDedicatedCluster(dedicateCmd)
1800+
1801+
cleanup_resources(self.apiclient, self.cleanup)
1802+
except Exception as e:
1803+
raise Exception("Warning: Exception during cleanup : %s" % e)
1804+
return
1805+
1806+
@attr(tags=["basic", "advanced"], required_hardware="false")
1807+
def test_01_dedicated_cluster_allocation(self):
1808+
""" Dedicated cluster and router allocation
1809+
1. Dedicate a cluster to one account
1810+
2. Deploy a VM on dedicated account
1811+
3. Deploy another VM on another account.
1812+
4. Verify the dedicated cluster is not used for
1813+
virtual routers that belong to non-dedicated account
1814+
"""
1815+
1816+
# Step 1
1817+
dedicateCmd = dedicateCluster.dedicateClusterCmd()
1818+
dedicateCmd.clusterid = self.clusters[0].id
1819+
dedicateCmd.domainid = self.domain.id
1820+
dedicateCmd.account = self.account_1.name
1821+
self.apiclient.dedicateCluster(dedicateCmd)
1822+
1823+
afcmd = listAffinityGroups.listAffinityGroupsCmd()
1824+
afcmd.account = self.account_1.name
1825+
afcmd.domainid = self.account_1.domainid
1826+
affinitygr_list = self.apiclient.listAffinityGroups(afcmd)
1827+
1828+
# Step 2
1829+
self.vm = VirtualMachine.create(
1830+
self.userapiclient_1,
1831+
self.testdata["small"],
1832+
templateid=self.template.id,
1833+
accountid=self.account_1.name,
1834+
domainid=self.account_1.domainid,
1835+
serviceofferingid=self.service_offering.id,
1836+
affinitygroupids=[affinitygr_list[0].id],
1837+
zoneid=self.zone.id,
1838+
mode=self.zone.networktype
1839+
)
1840+
# Steps to verify if VM is created on dedicated account
1841+
vmlist = list_virtual_machines(self.apiclient,
1842+
id=self.vm.id)
1843+
1844+
hostlist = list_hosts(self.apiclient,
1845+
id=vmlist[0].hostid)
1846+
1847+
self.assertEqual(hostlist[0].clusterid,
1848+
self.clusters[0].id,
1849+
"check if vm gets deployed on dedicated clusture"
1850+
)
1851+
# Step 3
1852+
self.vm_1 = VirtualMachine.create(
1853+
self.userapiclient_2,
1854+
self.testdata["small"],
1855+
templateid=self.template.id,
1856+
accountid=self.account_2.name,
1857+
domainid=self.account_2.domainid,
1858+
serviceofferingid=self.service_offering.id,
1859+
zoneid=self.zone.id,
1860+
mode=self.zone.networktype
1861+
)
1862+
1863+
# Steps to verify if VM is created on dedicated account
1864+
vmlist_1 = list_virtual_machines(self.apiclient,
1865+
id=self.vm_1.id)
1866+
1867+
hostlist_1 = list_hosts(self.apiclient,
1868+
id=vmlist_1[0].hostid)
1869+
1870+
self.assertNotEqual(hostlist_1[0].clusterid,
1871+
self.clusters[0].id,
1872+
"check if vm gets deployed on correct clusture"
1873+
)
1874+
1875+
# Step 4
1876+
routerList = list_routers(self.apiclient,
1877+
clusterid=self.clusters[0].id,
1878+
networkid=self.vm_1.nic[0].networkid
1879+
)
1880+
self.assertEqual(
1881+
routerList,
1882+
None,
1883+
"Check Dedicated cluster is used for virtual routers \
1884+
that belong to non-dedicated account")
1885+
1886+
return

0 commit comments

Comments
 (0)