cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gir...@apache.org
Subject git commit: updated refs/heads/4.3 to 43806aa
Date Tue, 24 Dec 2013 05:40:20 GMT
Updated Branches:
  refs/heads/4.3 632346d6a -> 43806aafe


CLOUDSTACK-5497: Fix test_guest_vlan_range.py to get free vlan range


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

Branch: refs/heads/4.3
Commit: 43806aafe13b0f0049afb69df137239f8d055223
Parents: 632346d
Author: Girish Shilamkar <girish@clogeny.com>
Authored: Tue Dec 24 11:09:34 2013 +0530
Committer: Girish Shilamkar <girish@clogeny.com>
Committed: Tue Dec 24 11:09:34 2013 +0530

----------------------------------------------------------------------
 .../component/test_non_contiguous_vlan.py       | 83 +++-----------------
 test/integration/smoke/test_guest_vlan_range.py | 53 +++++--------
 tools/marvin/marvin/integration/lib/common.py   | 66 ++++++++++++++++
 3 files changed, 96 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43806aaf/test/integration/component/test_non_contiguous_vlan.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_non_contiguous_vlan.py b/test/integration/component/test_non_contiguous_vlan.py
index 35afeaa..3ebaf3a 100644
--- a/test/integration/component/test_non_contiguous_vlan.py
+++ b/test/integration/component/test_non_contiguous_vlan.py
@@ -36,7 +36,8 @@ from marvin.integration.lib.base import (Account,
 from marvin.integration.lib.common import (get_zone,
                                            get_pod,
                                            get_domain,
-                                           get_template)
+                                           get_template,
+                                           setNonContiguousVlanIds)
 from marvin.integration.lib.utils import (cleanup_resources,
                                           xsplit)
 
@@ -125,8 +126,14 @@ class TestNonContiguousVLANRanges(cloudstackTestCase):
         self.vlan = self.services["vlan"]
         self.apiClient = self.testClient.getApiClient()
 
-        self.setNonContiguousVlanIds(self.apiclient, self.zone.id)
+        self.physicalnetwork, self.vlan = setNonContiguousVlanIds(self.apiclient, self.zone.id)
 
+        self.physicalnetworkid = self.physicalnetwork.id
+        self.existingvlan = self.physicalnetwork.vlan
+        
+        if self.vlan == None:
+            self.fail("Failed to set non contiguous vlan ids to test. Free some ids from
\
+                        from existing physical networks at extreme ends")
         self.cleanup = []
 
     def tearDown(self):
@@ -141,78 +148,6 @@ class TestNonContiguousVLANRanges(cloudstackTestCase):
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
 
-    def setNonContiguousVlanIds(self, apiclient, zoneid):
-        """
-        Form the non contiguous ranges based on currently assigned range in physical network
-        """
-
-        NonContigVlanIdsAcquired = False
-
-        list_physical_networks_response = PhysicalNetwork.list(
-            apiclient,
-            zoneid=zoneid
-        )
-        assert isinstance(list_physical_networks_response, list)
-        assert len(list_physical_networks_response) > 0, "No physical networks found in
zone %s" % zoneid
-
-        for physical_network in list_physical_networks_response:
-
-            self.physicalnetwork = physical_network
-            self.physicalnetworkid = physical_network.id
-            self.existingvlan = physical_network.vlan
-
-            vlans = xsplit(self.existingvlan, ['-', ','])
-
-            assert len(vlans) > 0
-            assert int(vlans[0]) < int(vlans[-1]), "VLAN range  %s was improperly split"
% self.existingvlan
-
-            # Keep some gap between existing vlan and the new vlans which we are going to
add
-            # So that they are non contiguous
-
-            non_contig_end_vlan_id = int(vlans[-1]) + 6
-            non_contig_start_vlan_id = int(vlans[0]) - 6
-
-            # Form ranges which are consecutive to existing ranges but not immediately contiguous
-            # There should be gap in between existing range and new non contiguous ranage
-
-            # If you can't add range after existing range, because it's crossing 4095, then
-            # select VLAN ids before the existing range such that they are greater than 0,
and
-            # then add this non contiguoud range
-
-            if non_contig_end_vlan_id < 4095:
-
-                self.vlan["partial_range"][0] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id
- 3)
-                self.vlan["partial_range"][1] = str(non_contig_end_vlan_id - 1) + '-' + str(non_contig_end_vlan_id)
-                self.vlan["full_range"] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id)
-                NonContigVlanIdsAcquired = True
-
-            elif non_contig_start_vlan_id > 0:
-
-                self.vlan["partial_range"][0] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id
+ 1)
-                self.vlan["partial_range"][1] = str(non_contig_start_vlan_id + 3) + '-' +
str(non_contig_start_vlan_id + 4)
-                self.vlan["full_range"] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id
+ 4)
-                NonContigVlanIdsAcquired = True
-
-            else:
-               NonContigVlanIdsAcquired = False
-
-            # If failed to get relevant vlan ids, continue to next physical network
-            # else break from loop as we have hot the non contiguous vlan ids for the test
purpose
-
-            if not NonContigVlanIdsAcquired:
-                continue
-            else:
-                break
-
-        # If even through looping from all existing physical networks, failed to get relevant
non
-        # contiguous vlan ids, then fail the test case
-
-        if not NonContigVlanIdsAcquired:
-            self.fail("Failed to set non contiguous vlan ids to test. Free some ids from
\
-                        from existing physical networks at extreme ends")
-
-        return
-
     def validatePhysicalNetworkVlan(self, physicalNetworkId, vlan):
         """Validate whether the physical network has the updated vlan
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43806aaf/test/integration/smoke/test_guest_vlan_range.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_guest_vlan_range.py b/test/integration/smoke/test_guest_vlan_range.py
index 8ea4719..07e141d 100644
--- a/test/integration/smoke/test_guest_vlan_range.py
+++ b/test/integration/smoke/test_guest_vlan_range.py
@@ -53,15 +53,15 @@ class TestDedicateGuestVlanRange(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestDedicateGuestVlanRange, cls).getClsTestClient().getApiClient()
+        cls.apiclient = super(TestDedicateGuestVlanRange, cls).getClsTestClient().getApiClient()
         cls.services = Services().services
         # Get Zone, Domain
-        cls.domain = get_domain(cls.api_client, cls.services)
-        cls.zone = get_zone(cls.api_client, cls.services)
+        cls.domain = get_domain(cls.apiclient, cls.services)
+        cls.zone = get_zone(cls.apiclient, cls.services)
 
         # Create Account
         cls.account = Account.create(
-                            cls.api_client,
+                            cls.apiclient,
                             cls.services["account"],
                             domainid=cls.domain.id
                             )
@@ -69,24 +69,18 @@ class TestDedicateGuestVlanRange(cloudstackTestCase):
                         cls.account,
                         ]
 
-        phy_networks = PhysicalNetwork.list(
-                             cls.api_client
-                             )
-        cls.existed_vlan = phy_networks[0].vlan
+        cls.physical_network, cls.free_vlan = setNonContiguousVlanIds(cls.apiclient, cls.zone.id)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
             # Cleanup resources used
-            list_physical_network_response = PhysicalNetwork.list(cls.api_client)
-            if list_physical_network_response is not None and len(list_physical_network_response)
> 0:
-                physical_network = list_physical_network_response[0]
-                removeGuestVlanRangeResponse = \
-                physical_network.update(cls.api_client,
-                        id=physical_network.id,
-                        vlan=cls.existed_vlan)
-            cleanup_resources(cls.api_client, cls._cleanup)
+            removeGuestVlanRangeResponse = \
+                cls.physical_network.update(cls.apiclient,
+                        id=cls.physical_network.id,
+                        vlan=cls.physical_network.vlan)
+            cleanup_resources(cls.apiclient, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
@@ -121,28 +115,23 @@ class TestDedicateGuestVlanRange(cloudstackTestCase):
         # 6. Verify guest vlan range has been released, verify with listDedicatedGuestVlanRanges
         # 7. Remove the added guest vlan range using UpdatePhysicalNetwork
 
-        self.debug("Listing available physical network")
-        list_physical_network_response = PhysicalNetwork.list(
-                             self.apiclient
-                             )
-        self.assertEqual(
-                         isinstance(list_physical_network_response, list),
-                         True,
-                         "Check for list guest vlan range response"
-                         )
-        physical_network_response = list_physical_network_response[0]
-
         self.debug("Adding guest vlan range")
 
-        new_vlan = self.existed_vlan + "," + self.services["vlan"]
-        addGuestVlanRangeResponse = physical_network_response.update(self.apiclient,
-                id=physical_network_response.id, vlan=new_vlan)
+
+        print "existing vlna = %s" %self.physical_network.vlan
+        print "free vlan = %s" %self.free_vlan
+        new_vlan = self.physical_network.vlan + "," + self.free_vlan["partial_range"][0]
+        print "new vlan = %s" % new_vlan
+        #new_vlan = self.free_vlan["partial_range"][0]
+        addGuestVlanRangeResponse = self.physical_network.update(self.apiclient,
+                id=self.physical_network.id, vlan=new_vlan)
+                #id=self.physical_network.id, vlan=self.free_vlan["partial_range"][0])
 
         self.debug("Dedicating guest vlan range");
         dedicate_guest_vlan_range_response = PhysicalNetwork.dedicate(
                                                 self.apiclient,
-                                                self.services["vlan"],
-                                                physicalnetworkid=physical_network_response.id,
+                                                self.free_vlan["partial_range"][0],
+                                                physicalnetworkid=self.physical_network.id,
                                                 account=self.account.name,
                                                 domainid=self.account.domainid
                                             )

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43806aaf/tools/marvin/marvin/integration/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py
index d23d745..c1ae31b 100644
--- a/tools/marvin/marvin/integration/lib/common.py
+++ b/tools/marvin/marvin/integration/lib/common.py
@@ -830,3 +830,69 @@ def get_free_vlan(apiclient, zoneid):
             break
 
     return physical_network, shared_ntwk_vlan
+
+def setNonContiguousVlanIds(apiclient, zoneid):
+    """
+    Form the non contiguous ranges based on currently assigned range in physical network
+    """
+
+    NonContigVlanIdsAcquired = False
+
+    list_physical_networks_response = PhysicalNetwork.list(
+        apiclient,
+        zoneid=zoneid
+    )
+    assert isinstance(list_physical_networks_response, list)
+    assert len(list_physical_networks_response) > 0, "No physical networks found in zone
%s" % zoneid
+
+    for physical_network in list_physical_networks_response:
+
+        vlans = xsplit(physical_network.vlan, ['-', ','])
+
+        assert len(vlans) > 0
+        assert int(vlans[0]) < int(vlans[-1]), "VLAN range  %s was improperly split" %
physical_network.vlan
+
+        # Keep some gap between existing vlan and the new vlans which we are going to add
+        # So that they are non contiguous
+
+        non_contig_end_vlan_id = int(vlans[-1]) + 6
+        non_contig_start_vlan_id = int(vlans[0]) - 6
+
+        # Form ranges which are consecutive to existing ranges but not immediately contiguous
+        # There should be gap in between existing range and new non contiguous ranage
+
+        # If you can't add range after existing range, because it's crossing 4095, then
+        # select VLAN ids before the existing range such that they are greater than 0, and
+        # then add this non contiguoud range
+        vlan = { "partial_range": ["",""], "full_range": ""}
+
+        if non_contig_end_vlan_id < 4095:
+            vlan["partial_range"][0] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id
- 3)
+            vlan["partial_range"][1] = str(non_contig_end_vlan_id - 1) + '-' + str(non_contig_end_vlan_id)
+            vlan["full_range"] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id)
+            NonContigVlanIdsAcquired = True
+
+        elif non_contig_start_vlan_id > 0:
+            vlan["partial_range"][0] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id
+ 1)
+            vlan["partial_range"][1] = str(non_contig_start_vlan_id + 3) + '-' + str(non_contig_start_vlan_id
+ 4)
+            vlan["full_range"] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id
+ 4)
+            NonContigVlanIdsAcquired = True
+
+        else:
+            NonContigVlanIdsAcquired = False
+
+        # If failed to get relevant vlan ids, continue to next physical network
+        # else break from loop as we have hot the non contiguous vlan ids for the test purpose
+
+        if not NonContigVlanIdsAcquired:
+            continue
+        else:
+            break
+
+    # If even through looping from all existing physical networks, failed to get relevant
non
+    # contiguous vlan ids, then fail the test case
+
+    if not NonContigVlanIdsAcquired:
+        return None, None
+
+    return physical_network, vlan


Mime
View raw message