You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2013/04/24 18:23:46 UTC

[22/50] [abbrv] git commit: updated refs/heads/internallb to ca2fc30

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 <ts...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a1912d9c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a1912d9c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a1912d9c

Branch: refs/heads/internallb
Commit: a1912d9ce21c0798c04d3e38142ff5a89b576328
Parents: 9572f57
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Mon Apr 22 19:34:35 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Mon Apr 22 19:35:22 2013 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_global_settings.py    |   33 +---
 test/integration/smoke/test_non_contigiousvlan.py |  139 ++++++----------
 tools/marvin/marvin/integration/lib/base.py       |    2 +-
 3 files changed, 61 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a1912d9c/test/integration/smoke/test_global_settings.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_global_settings.py b/test/integration/smoke/test_global_settings.py
index be501b9..12b35d7 100644
--- a/test/integration/smoke/test_global_settings.py
+++ b/test/integration/smoke/test_global_settings.py
@@ -17,40 +17,25 @@
 """ P1 tests for updating the granular Configuration parameter with scope and resource id provided.
 """
 #Import Local Modules
-import marvin
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
-from marvin.remoteSSHClient import remoteSSHClient
 from marvin.integration.lib.utils import *
 from marvin.integration.lib.base import *
 from marvin.integration.lib.common import *
-from nose.plugins.attrib import attr
 #Import System modules
-import unittest
-import hashlib
-import random
 
 class TestUpdateConfigWithScope(cloudstackTestCase):
     """
-    This test updates the value of a configuration parameter
-    which is at zone level(scope)
+    Test to update a configuration (global setting) at various scopes
     """
     def setUp(self):
-        """
-        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
-
-
+        self.apiClient = self.testClient.getApiClient()
 
     def test_UpdateConfigParamWithScope(self):
-
+        """
+        test update configuration setting at zone level scope
+        @return:
+        """
         updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
         updateConfigurationCmd.name = "use.external.dns"
         updateConfigurationCmd.value = "true"
@@ -70,13 +55,15 @@ class TestUpdateConfigWithScope(cloudstackTestCase):
                             returns a non-empty response")
 
         configParam = listConfigurationsResponse[0]
-
         self.assertEqual(configParam.value, updateConfigurationResponse.value, "Check if the update API returned \
                          is the same as the one we got in the list API")
 
 
     def tearDown(self):
-
+        """
+        Reset the configuration back to false
+        @return:
+        """
         updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
         updateConfigurationCmd.name = "use.external.dns"
         updateConfigurationCmd.value = "false"

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a1912d9c/test/integration/smoke/test_non_contigiousvlan.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_non_contigiousvlan.py b/test/integration/smoke/test_non_contigiousvlan.py
index fe70f87..91b6325 100644
--- a/test/integration/smoke/test_non_contigiousvlan.py
+++ b/test/integration/smoke/test_non_contigiousvlan.py
@@ -14,112 +14,73 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-""" BVT tests for Primary Storage
-"""
-import marvin
+
 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
-import hashlib
-import random
+class Services():
+    def __init__(self):
+        self.services = {
+            "vlan": {
+                "part": ["4090-4091", "4092-4096"],
+                "full": "4090-4096",
+            }
+        }
 
 
+@attr(tags = ["simulator", "advanced"])
 class TestUpdatePhysicalNetwork(cloudstackTestCase):
     """
-    This test updates the existing physicalnetwork with a new vlan range.
+    Test to extend physical network vlan range
     """
     def setUp(self):
-        """
-        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.vlan = Services().services["vlan"]
+        self.apiClient = self.testClient.getApiClient()
 
-        self.apiClient = self.testClient.getApiClient() #Get ourselves an API client
 
-        self.acct = createAccount.createAccountCmd() #The createAccount command
-        self.acct.accounttype = 0                    #We need a regular user. admins have accounttype=1
-        self.acct.firstname = 'bharat'
-        self.acct.lastname = 'kumar'                 #What's up doc?
-        self.acct.password = mdf_pass                #The md5 hashed password string
-        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):
+    def test_extendPhysicalNetworkVlan(self):
         """
-        Let's start by defining the attributes of our VM that we will be
-        deploying on CloudStack. We will be assuming a single zone is available
-        and is configured and all templates are Ready
-
-        The hardcoded values are used only for brevity.
+        Test to update a physical network and extend its vlan
         """
-        listPhysicalNetworksCmd = listPhysicalNetworks.listPhysicalNetworksCmd()
-        listPhysicalNetworksResponse = self.apiClient.listPhysicalNetworks(listPhysicalNetworksCmd)
-        
-        self.assertNotEqual(len(listPhysicalNetworksResponse), 0, "Check if the list API \
-                           returns a non-empty response")
-        
-        networkid = listPhysicalNetworksResponse[0].id
-        updatePhysicalNetworkCmd = updatePhysicalNetwork.updatePhysicalNetworkCmd()
-        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")
+        phy_networks = PhysicalNetwork.list(self.apiClient)
+        self.assertNotEqual(len(phy_networks), 0,
+            msg="There are no physical networks in the zone")
 
-        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")
+        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))
 
-        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")
+        vlan2 = self.vlan["part"][1]
+        updatePhysicalNetworkResponse2 = self.network.update(self.apiClient, id = self.networkid, vlan = vlan2)
+        self.assert_(updatePhysicalNetworkResponse2 is not None,
+            msg="couldn't extend the physical network with vlan %s"%vlan2)
+        self.assert_(isinstance(self.network, PhysicalNetwork))
 
-        vlanranges= updatePhysicalNetworkResponse.vlan
-        range = ""
-        vlanranges = vlanranges.split(";")
+        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")
 
-        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
+    def tearDown(self):
         """
-        And finally let us cleanup the resources we created by deleting the
-        account. All good unittests are atomic and rerunnable this way
+        Teardown to update a physical network and shrink its vlan
+        @return:
         """
-        deleteAcct = deleteAccount.deleteAccountCmd()
-        deleteAcct.id = self.acctResponse.account.id
-        self.apiClient.deleteAccount(deleteAcct)
+        phy_networks = PhysicalNetwork.list(self.apiClient)
+        self.assertNotEqual(len(phy_networks), 0,
+            msg="There are no physical networks in the zone")
+        self.network = phy_networks[0]
+        self.networkid = phy_networks[0].id
+        updateResponse = self.network.update(self.apiClient, id = self.networkid, removevlan = self.vlan["full"])
+        self.assert_(updateResponse.vlan.find(self.vlan["full"]) > 0,
+            "VLAN was not removed successfully")
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a1912d9c/tools/marvin/marvin/integration/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py
index 915d478..92cdf81 100755
--- a/tools/marvin/marvin/integration/lib/base.py
+++ b/tools/marvin/marvin/integration/lib/base.py
@@ -1994,7 +1994,7 @@ class PhysicalNetwork:
 
         cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
         [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:
     """Manage Security Groups"""