mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Refactoring vlan and globalsetting tests
Refactoring the vlan and global_setting tests to use the marvin libraries instead of command classes. Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
parent
9572f57648
commit
a1912d9ce2
@ -17,40 +17,25 @@
|
|||||||
""" P1 tests for updating the granular Configuration parameter with scope and resource id provided.
|
""" P1 tests for updating the granular Configuration parameter with scope and resource id provided.
|
||||||
"""
|
"""
|
||||||
#Import Local Modules
|
#Import Local Modules
|
||||||
import marvin
|
|
||||||
from marvin.cloudstackTestCase import *
|
from marvin.cloudstackTestCase import *
|
||||||
from marvin.cloudstackAPI import *
|
from marvin.cloudstackAPI import *
|
||||||
from marvin.remoteSSHClient import remoteSSHClient
|
|
||||||
from marvin.integration.lib.utils import *
|
from marvin.integration.lib.utils import *
|
||||||
from marvin.integration.lib.base import *
|
from marvin.integration.lib.base import *
|
||||||
from marvin.integration.lib.common import *
|
from marvin.integration.lib.common import *
|
||||||
from nose.plugins.attrib import attr
|
|
||||||
#Import System modules
|
#Import System modules
|
||||||
import unittest
|
|
||||||
import hashlib
|
|
||||||
import random
|
|
||||||
|
|
||||||
class TestUpdateConfigWithScope(cloudstackTestCase):
|
class TestUpdateConfigWithScope(cloudstackTestCase):
|
||||||
"""
|
"""
|
||||||
This test updates the value of a configuration parameter
|
Test to update a configuration (global setting) at various scopes
|
||||||
which is at zone level(scope)
|
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""
|
self.apiClient = self.testClient.getApiClient()
|
||||||
CloudStack internally saves its passwords in md5 form and that is how we
|
|
||||||
specify it in the API. Python's hashlib library helps us to quickly hash
|
|
||||||
strings as follows
|
|
||||||
"""
|
|
||||||
mdf = hashlib.md5()
|
|
||||||
mdf.update('password')
|
|
||||||
mdf_pass = mdf.hexdigest()
|
|
||||||
|
|
||||||
self.apiClient = self.testClient.getApiClient() #Get ourselves an API client
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_UpdateConfigParamWithScope(self):
|
def test_UpdateConfigParamWithScope(self):
|
||||||
|
"""
|
||||||
|
test update configuration setting at zone level scope
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
|
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
|
||||||
updateConfigurationCmd.name = "use.external.dns"
|
updateConfigurationCmd.name = "use.external.dns"
|
||||||
updateConfigurationCmd.value = "true"
|
updateConfigurationCmd.value = "true"
|
||||||
@ -70,13 +55,15 @@ class TestUpdateConfigWithScope(cloudstackTestCase):
|
|||||||
returns a non-empty response")
|
returns a non-empty response")
|
||||||
|
|
||||||
configParam = listConfigurationsResponse[0]
|
configParam = listConfigurationsResponse[0]
|
||||||
|
|
||||||
self.assertEqual(configParam.value, updateConfigurationResponse.value, "Check if the update API returned \
|
self.assertEqual(configParam.value, updateConfigurationResponse.value, "Check if the update API returned \
|
||||||
is the same as the one we got in the list API")
|
is the same as the one we got in the list API")
|
||||||
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
"""
|
||||||
|
Reset the configuration back to false
|
||||||
|
@return:
|
||||||
|
"""
|
||||||
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
|
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
|
||||||
updateConfigurationCmd.name = "use.external.dns"
|
updateConfigurationCmd.name = "use.external.dns"
|
||||||
updateConfigurationCmd.value = "false"
|
updateConfigurationCmd.value = "false"
|
||||||
|
|||||||
@ -14,112 +14,73 @@
|
|||||||
# KIND, either express or implied. See the License for the
|
# KIND, either express or implied. See the License for the
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
""" BVT tests for Primary Storage
|
|
||||||
"""
|
|
||||||
import marvin
|
|
||||||
from marvin import cloudstackTestCase
|
from marvin import cloudstackTestCase
|
||||||
from marvin.cloudstackTestCase import *
|
from marvin.cloudstackAPI import *
|
||||||
|
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||||
|
from marvin.integration.lib.base import Account
|
||||||
|
from marvin.integration.lib.base import PhysicalNetwork
|
||||||
|
from nose.plugins.attrib import attr
|
||||||
|
|
||||||
import unittest
|
class Services():
|
||||||
import hashlib
|
def __init__(self):
|
||||||
import random
|
self.services = {
|
||||||
|
"vlan": {
|
||||||
|
"part": ["4090-4091", "4092-4096"],
|
||||||
|
"full": "4090-4096",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@attr(tags = ["simulator", "advanced"])
|
||||||
class TestUpdatePhysicalNetwork(cloudstackTestCase):
|
class TestUpdatePhysicalNetwork(cloudstackTestCase):
|
||||||
"""
|
"""
|
||||||
This test updates the existing physicalnetwork with a new vlan range.
|
Test to extend physical network vlan range
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
self.vlan = Services().services["vlan"]
|
||||||
|
self.apiClient = self.testClient.getApiClient()
|
||||||
|
|
||||||
|
|
||||||
|
def test_extendPhysicalNetworkVlan(self):
|
||||||
"""
|
"""
|
||||||
CloudStack internally saves its passwords in md5 form and that is how we
|
Test to update a physical network and extend its vlan
|
||||||
specify it in the API. Python's hashlib library helps us to quickly hash
|
|
||||||
strings as follows
|
|
||||||
"""
|
"""
|
||||||
mdf = hashlib.md5()
|
phy_networks = PhysicalNetwork.list(self.apiClient)
|
||||||
mdf.update('password')
|
self.assertNotEqual(len(phy_networks), 0,
|
||||||
mdf_pass = mdf.hexdigest()
|
msg="There are no physical networks in the zone")
|
||||||
|
|
||||||
self.apiClient = self.testClient.getApiClient() #Get ourselves an API client
|
self.network = phy_networks[0]
|
||||||
|
self.networkid = phy_networks[0].id
|
||||||
|
vlan1 = self.vlan["part"][0]
|
||||||
|
updatePhysicalNetworkResponse = self.network.update(self.apiClient, id = self.networkid, vlan = vlan1)
|
||||||
|
self.assert_(updatePhysicalNetworkResponse is not None,
|
||||||
|
msg="couldn't extend the physical network with vlan %s"%vlan1)
|
||||||
|
self.assert_(isinstance(self.network, PhysicalNetwork))
|
||||||
|
|
||||||
self.acct = createAccount.createAccountCmd() #The createAccount command
|
vlan2 = self.vlan["part"][1]
|
||||||
self.acct.accounttype = 0 #We need a regular user. admins have accounttype=1
|
updatePhysicalNetworkResponse2 = self.network.update(self.apiClient, id = self.networkid, vlan = vlan2)
|
||||||
self.acct.firstname = 'bharat'
|
self.assert_(updatePhysicalNetworkResponse2 is not None,
|
||||||
self.acct.lastname = 'kumar' #What's up doc?
|
msg="couldn't extend the physical network with vlan %s"%vlan2)
|
||||||
self.acct.password = mdf_pass #The md5 hashed password string
|
self.assert_(isinstance(self.network, PhysicalNetwork))
|
||||||
self.acct.username = 'bharat'
|
|
||||||
self.acct.email = 'bharat@kumar.com'
|
|
||||||
self.acct.account = 'bharat'
|
|
||||||
self.acct.domainid = 1 #The default ROOT domain
|
|
||||||
self.acctResponse = self.apiClient.createAccount(self.acct)
|
|
||||||
# using the default debug logger of the test framework
|
|
||||||
self.debug("successfully created account: %s, user: %s, id: \
|
|
||||||
%s"%(self.acctResponse.account.account, \
|
|
||||||
self.acctResponse.account.username, \
|
|
||||||
self.acctResponse.account.id))
|
|
||||||
|
|
||||||
def test_UpdatePhysicalNetwork(self):
|
vlanranges= updatePhysicalNetworkResponse2.vlan
|
||||||
|
self.assert_(vlanranges is not None,
|
||||||
|
"No VLAN ranges found on the deployment")
|
||||||
|
self.assert_(vlanranges.find(self.vlan["full"]) > 0, "vlan ranges are not extended")
|
||||||
|
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
Let's start by defining the attributes of our VM that we will be
|
Teardown to update a physical network and shrink its vlan
|
||||||
deploying on CloudStack. We will be assuming a single zone is available
|
@return:
|
||||||
and is configured and all templates are Ready
|
|
||||||
|
|
||||||
The hardcoded values are used only for brevity.
|
|
||||||
"""
|
"""
|
||||||
listPhysicalNetworksCmd = listPhysicalNetworks.listPhysicalNetworksCmd()
|
phy_networks = PhysicalNetwork.list(self.apiClient)
|
||||||
listPhysicalNetworksResponse = self.apiClient.listPhysicalNetworks(listPhysicalNetworksCmd)
|
self.assertNotEqual(len(phy_networks), 0,
|
||||||
|
msg="There are no physical networks in the zone")
|
||||||
self.assertNotEqual(len(listPhysicalNetworksResponse), 0, "Check if the list API \
|
self.network = phy_networks[0]
|
||||||
returns a non-empty response")
|
self.networkid = phy_networks[0].id
|
||||||
|
updateResponse = self.network.update(self.apiClient, id = self.networkid, removevlan = self.vlan["full"])
|
||||||
networkid = listPhysicalNetworksResponse[0].id
|
self.assert_(updateResponse.vlan.find(self.vlan["full"]) > 0,
|
||||||
updatePhysicalNetworkCmd = updatePhysicalNetwork.updatePhysicalNetworkCmd()
|
"VLAN was not removed successfully")
|
||||||
updatePhysicalNetworkCmd.id = networkid
|
|
||||||
updatePhysicalNetworkCmd.vlan = "4090-4091"
|
|
||||||
updatePhysicalNetworkResponse = self.apiClient.updatePhysicalNetwork(updatePhysicalNetworkCmd)
|
|
||||||
self.assertNotEqual((updatePhysicalNetworkResponse.len), 0, "Check if the list API \
|
|
||||||
returns a non-empty response")
|
|
||||||
|
|
||||||
updatePhysicalNetworkCmd = updatePhysicalNetwork.updatePhysicalNetworkCmd()
|
|
||||||
updatePhysicalNetworkCmd.id = networkid
|
|
||||||
updatePhysicalNetworkCmd.vlan = "4092-4096"
|
|
||||||
updatePhysicalNetworkResponse = self.apiClient.updatePhysicalNetwork(updatePhysicalNetworkCmd)
|
|
||||||
self.assertNotEqual((updatePhysicalNetworkResponse.len), 0, "Check if the list API \
|
|
||||||
returns a non-empty response")
|
|
||||||
|
|
||||||
vlanranges= updatePhysicalNetworkResponse.vlan
|
|
||||||
range = ""
|
|
||||||
vlanranges = vlanranges.split(";")
|
|
||||||
for vlan in vlanranges:
|
|
||||||
if (vlan == "4090-4096"):
|
|
||||||
range = vlan
|
|
||||||
|
|
||||||
self.assertEqual(range, "4090-4096", "check if adding the range is successful")
|
|
||||||
|
|
||||||
updatePhysicalNetworkCmd = updatePhysicalNetwork.updatePhysicalNetworkCmd()
|
|
||||||
updatePhysicalNetworkCmd.id = networkid
|
|
||||||
updatePhysicalNetworkCmd.removevlan = "4090-4096"
|
|
||||||
updatePhysicalNetworkResponse = self.apiClient.updatePhysicalNetwork(updatePhysicalNetworkCmd)
|
|
||||||
self.assertNotEqual((updatePhysicalNetworkResponse.len), 0, "Check if the list API \
|
|
||||||
returns a non-empty response")
|
|
||||||
|
|
||||||
vlanranges= updatePhysicalNetworkResponse.vlan
|
|
||||||
range = ""
|
|
||||||
vlanranges = vlanranges.split(";")
|
|
||||||
|
|
||||||
for vlan in vlanranges:
|
|
||||||
if (vlan == "4090-4096"):
|
|
||||||
range = vlan
|
|
||||||
|
|
||||||
|
|
||||||
self.assertEqual(range, "", "check if removing the range is successful")
|
|
||||||
|
|
||||||
|
|
||||||
def tearDown(self): # Teardown will delete the Account as well as the VM once the VM reaches "Running" state
|
|
||||||
"""
|
|
||||||
And finally let us cleanup the resources we created by deleting the
|
|
||||||
account. All good unittests are atomic and rerunnable this way
|
|
||||||
"""
|
|
||||||
deleteAcct = deleteAccount.deleteAccountCmd()
|
|
||||||
deleteAcct.id = self.acctResponse.account.id
|
|
||||||
self.apiClient.deleteAccount(deleteAcct)
|
|
||||||
|
|
||||||
|
|||||||
@ -1994,7 +1994,7 @@ class PhysicalNetwork:
|
|||||||
|
|
||||||
cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
|
cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
|
||||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||||
return(apiclient.listPhysicalNetworks(cmd))
|
return map(lambda pn : PhysicalNetwork(pn.__dict__), apiclient.listPhysicalNetworks(cmd))
|
||||||
|
|
||||||
class SecurityGroup:
|
class SecurityGroup:
|
||||||
"""Manage Security Groups"""
|
"""Manage Security Groups"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user