include test for volumes created in non-root domains

Test verifies that volumes in non-root domains are visible to the user
that created them.

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Prasanna Santhanam 2013-08-08 22:19:08 +05:30
parent b2ed632396
commit ed70eaf2ce

View File

@ -17,14 +17,12 @@
""" P1 tests for Volumes
"""
#Import Local Modules
import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.integration.lib.utils import *
from marvin.integration.lib.base import *
from marvin.integration.lib.common import *
from marvin.remoteSSHClient import remoteSSHClient
#Import System modules
import time
@ -136,7 +134,6 @@ class TestAttachVolume(cloudstackTestCase):
domainid=cls.domain.id
)
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"]
@ -188,7 +185,7 @@ class TestAttachVolume(cloudstackTestCase):
# 5. Start The VM. Start VM should be successful
# Create 5 volumes and attach to VM
for i in range(self.services["volume"]["max"]):
for i in range(self.services["volume"]["max"] - 1):
volume = Volume.create(
self.apiclient,
self.services["volume"],
@ -428,7 +425,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
domainid=cls.domain.id
)
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"]
@ -480,7 +477,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
volumes = []
# Create 5 volumes and attach to VM
for i in range(self.services["volume"]["max"]):
for i in range(self.services["volume"]["max"] - 1):
volume = Volume.create(
self.apiclient,
self.services["volume"],
@ -693,7 +690,7 @@ class TestAttachVolumeISO(cloudstackTestCase):
cls.services["account"],
domainid=cls.domain.id
)
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"]
@ -743,7 +740,7 @@ class TestAttachVolumeISO(cloudstackTestCase):
# 3. Verify that attach ISO is successful
# Create 5 volumes and attach to VM
for i in range(self.services["volume"]["max"]):
for i in range(self.services["volume"]["max"] - 1):
volume = Volume.create(
self.apiclient,
self.services["volume"],
@ -885,7 +882,7 @@ class TestVolumes(cloudstackTestCase):
domainid=cls.domain.id
)
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"]
@ -1089,6 +1086,54 @@ class TestVolumes(cloudstackTestCase):
)
return
@attr(tags=["advanced", "advancedns", "simulator", "basic", "eip", "sg"])
def test_create_volume_under_domain(self):
"""Create a volume under a non-root domain as non-root-domain user
1. Create a domain under ROOT
2. Create a user within this domain
3. As user in step 2. create a volume with standard disk offering
4. Ensure the volume is created in the domain and available to the user in his listVolumes call
"""
dom = Domain.create(
self.apiclient,
services={},
name="NROOT",
parentdomainid=self.domain.id
)
self.assertTrue(dom is not None, msg="Domain creation failed")
domuser = Account.create(
apiclient=self.apiclient,
services=self.services["account"],
admin=False,
domainid=dom.id
)
self.assertTrue(domuser is not None)
domapiclient = self.testClient.getUserApiClient(account=domuser.name, domain=dom.name)
diskoffering = DiskOffering.list(self.apiclient)
self.assertTrue(isinstance(diskoffering, list), msg="DiskOffering list is not a list?")
self.assertTrue(len(diskoffering) > 0, "no disk offerings in the deployment")
vol = Volume.create(
domapiclient,
services=self.services["volume"],
zoneid=self.zone.id,
account=domuser.name,
domainid=dom.id,
diskofferingid=diskoffering[0].id
)
self.assertTrue(vol is not None, "volume creation fails in domain %s as user %s" % (dom.name, domuser.name))
listed_vol = Volume.list(domapiclient, id=vol.id)
self.assertTrue(listed_vol is not None and isinstance(listed_vol, list),
"invalid response from listVolumes for volume %s" % vol.id)
self.assertTrue(listed_vol[0].id == vol.id,
"Volume returned by list volumes %s not matching with queried volume %s in domain %s" % (
listed_vol[0].id, vol.id, dom.name))
class TestDeployVmWithCustomDisk(cloudstackTestCase):
@ -1125,7 +1170,7 @@ class TestDeployVmWithCustomDisk(cloudstackTestCase):
domainid=cls.domain.id
)
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"]