cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [45/50] [abbrv] git commit: updated refs/heads/4.9-bountycastle-daan to b9ee34f
Date Wed, 28 Sep 2016 09:46:36 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4ae1ab6/test/integration/plugins/solidfire/TestVolumes.py
----------------------------------------------------------------------
diff --git a/test/integration/plugins/solidfire/TestVolumes.py b/test/integration/plugins/solidfire/TestVolumes.py
index 63b9be1..b70ac91 100644
--- a/test/integration/plugins/solidfire/TestVolumes.py
+++ b/test/integration/plugins/solidfire/TestVolumes.py
@@ -20,6 +20,8 @@ import random
 import SignedAPICall
 import XenAPI
 
+from solidfire.factory import ElementFactory
+
 from util import sf_util
 
 # All tests inherit from cloudstackTestCase
@@ -39,8 +41,6 @@ from marvin.lib.common import get_domain, get_template, get_zone, list_clusters,
 # utils - utility classes for common cleanup, external library wrappers, etc.
 from marvin.lib.utils import cleanup_resources
 
-from solidfire import solidfire_element_api as sf_api
-
 # Prerequisites:
 #  Only one zone
 #  Only one pod
@@ -71,7 +71,6 @@ class TestData():
     storageTag = "SolidFire_SAN_1"
     tags = "tags"
     templateCacheName = "centos56-x86-64-xen"
-    templateName = "templatename"
     testAccount = "testaccount"
     url = "url"
     user = "user"
@@ -87,7 +86,7 @@ class TestData():
         self.testdata = {
             TestData.solidFire: {
                 TestData.mvip: "192.168.139.112",
-                TestData.login: "admin",
+                TestData.username: "admin",
                 TestData.password: "admin",
                 TestData.port: 443,
                 TestData.url: "https://192.168.139.112:443"
@@ -168,7 +167,6 @@ class TestData():
             TestData.volume_2: {
                 TestData.diskName: "test-volume-2",
             },
-            TestData.templateName: "CentOS 5.6(64-bit) no GUI (XenServer)",
             TestData.zoneId: 1,
             TestData.clusterId: 1,
             TestData.domainId: 1,
@@ -192,6 +190,7 @@ class TestVolumes(cloudstackTestCase):
         # Set up API client
         testclient = super(TestVolumes, cls).getClsTestClient()
         cls.apiClient = testclient.getApiClient()
+        cls.configData = testclient.getParsedTestDataConfig()
         cls.dbConnection = testclient.getDbConnection()
 
         cls.testdata = TestData().testdata
@@ -212,12 +211,14 @@ class TestVolumes(cloudstackTestCase):
         cls.xen_session.xenapi.login_with_password(xenserver[TestData.username], xenserver[TestData.password])
 
         # Set up SolidFire connection
-        cls.sf_client = sf_api.SolidFireAPI(endpoint_dict=cls.testdata[TestData.solidFire])
+        solidfire = cls.testdata[TestData.solidFire]
+
+        cls.sfe = ElementFactory.create(solidfire[TestData.mvip], solidfire[TestData.username],
solidfire[TestData.password])
 
         # Get Resources from Cloud Infrastructure
         cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId])
         cls.cluster = list_clusters(cls.apiClient)[0]
-        cls.template = get_template(cls.apiClient, cls.zone.id, template_name=cls.testdata[TestData.templateName])
+        cls.template = get_template(cls.apiClient, cls.zone.id, cls.configData["ostype"])
         cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId])
 
         # Create test account
@@ -304,7 +305,7 @@ class TestVolumes(cloudstackTestCase):
 
             cls.primary_storage.delete(cls.apiClient)
 
-            sf_util.purge_solidfire_volumes(cls.sf_client)
+            sf_util.purge_solidfire_volumes(cls.sfe)
         except Exception as e:
             logging.debug("Exception in tearDownClass(cls): %s" % e)
 
@@ -328,16 +329,16 @@ class TestVolumes(cloudstackTestCase):
         sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, TestData.templateCacheName,
self)
 
         self.assertEqual(
-            len(sf_volume['volumeAccessGroups']),
+            len(sf_volume.volume_access_groups),
             0,
             "The volume should not be in a VAG."
         )
 
-        sf_account_id = sf_volume["accountID"]
+        sf_account_id = sf_volume.account_id
 
-        sf_account = self.sf_client.get_account_by_id(sf_account_id)["account"]
+        sf_account = self.sfe.get_account_by_id(sf_account_id).account
 
-        sf_account_name = sf_account["username"]
+        sf_account_name = sf_account.username
 
         self.assertEqual(
             sf_account_name.endswith("_1"),
@@ -504,7 +505,7 @@ class TestVolumes(cloudstackTestCase):
         sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, vol.name, self)
 
         self.assertEqual(
-            len(sf_volume['volumeAccessGroups']),
+            len(sf_volume.volume_access_groups),
             0,
             "The volume should not be in a VAG."
         )
@@ -723,7 +724,7 @@ class TestVolumes(cloudstackTestCase):
         sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, vol.name, self)
 
         self.assertEqual(
-            len(sf_volume['volumeAccessGroups']),
+            len(sf_volume.volume_access_groups),
             0,
             TestVolumes._volume_should_not_be_in_a_vag
         )
@@ -747,7 +748,7 @@ class TestVolumes(cloudstackTestCase):
         sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, vol.name, self)
 
         self.assertEqual(
-            len(sf_volume['volumeAccessGroups']),
+            len(sf_volume.volume_access_groups),
             0,
             TestVolumes._volume_should_not_be_in_a_vag
         )
@@ -847,7 +848,7 @@ class TestVolumes(cloudstackTestCase):
         sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, vol.name, self)
 
         self.assertEqual(
-            len(sf_volume['volumeAccessGroups']),
+            len(sf_volume.volume_access_groups),
             0,
             TestVolumes._volume_should_not_be_in_a_vag
         )
@@ -871,7 +872,7 @@ class TestVolumes(cloudstackTestCase):
         sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, vol.name, self)
 
         self.assertEqual(
-            len(sf_volume['volumeAccessGroups']),
+            len(sf_volume.volume_access_groups),
             0,
             TestVolumes._volume_should_not_be_in_a_vag
         )
@@ -1075,7 +1076,7 @@ class TestVolumes(cloudstackTestCase):
         sf_util.check_size_and_iops(sf_volume, vol, sf_volume_size, self)
 
         self.assertEqual(
-            len(sf_volume['volumeAccessGroups']),
+            len(sf_volume.volume_access_groups),
             0,
             TestVolumes._volume_should_not_be_in_a_vag
         )
@@ -1182,7 +1183,7 @@ class TestVolumes(cloudstackTestCase):
         sf_util.check_size_and_iops(sf_volume, vol, sf_volume_size, self)
 
         self.assertEqual(
-            len(sf_volume['volumeAccessGroups']),
+            len(sf_volume.volume_access_groups),
             0,
             TestVolumes._volume_should_not_be_in_a_vag
         )
@@ -1489,7 +1490,7 @@ class TestVolumes(cloudstackTestCase):
         sf_util.check_xen_sr(xen_sr_name, self.xen_session, self, should_exist)
 
     def _get_active_sf_volumes(self, sf_account_id=None):
-        sf_volumes = sf_util.get_active_sf_volumes(self.sf_client, sf_account_id)
+        sf_volumes = sf_util.get_active_sf_volumes(self.sfe, sf_account_id)
 
         self.assertNotEqual(
             len(sf_volumes),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d4ae1ab6/test/integration/plugins/solidfire/util/sf_util.py
----------------------------------------------------------------------
diff --git a/test/integration/plugins/solidfire/util/sf_util.py b/test/integration/plugins/solidfire/util/sf_util.py
index 6629571..1b451d5 100644
--- a/test/integration/plugins/solidfire/util/sf_util.py
+++ b/test/integration/plugins/solidfire/util/sf_util.py
@@ -68,20 +68,20 @@ def _set_supports_resign_for_table(supports_resign, db_connection, table):
     # make sure you can connect to MySQL: https://teamtreehouse.com/community/cant-connect-remotely-to-mysql-server-with-mysql-workbench
     db_connection.execute(sql_query)
 
-def purge_solidfire_volumes(sf_client):
-    deleted_volumes = sf_client.list_deleted_volumes()
+def purge_solidfire_volumes(sfe):
+    deleted_volumes = sfe.list_deleted_volumes()
 
-    for deleted_volume in deleted_volumes:
-        sf_client.purge_deleted_volume(deleted_volume['volumeID'])
+    for deleted_volume in deleted_volumes.volumes:
+        sfe.purge_deleted_volume(deleted_volume.volume_id)
 
-def get_not_active_sf_volumes(sf_client, sf_account_id=None):
+def get_not_active_sf_volumes(sfe, sf_account_id=None):
     if sf_account_id is not None:
-        sf_volumes = sf_client.list_volumes_for_account(sf_account_id)
+        sf_volumes = sfe.list_volumes_for_account(sf_account_id).volumes
 
         if sf_volumes is not None and len(sf_volumes) > 0:
             sf_volumes = _get_not_active_sf_volumes_only(sf_volumes)
     else:
-        sf_volumes = sf_client.list_deleted_volumes()
+        sf_volumes = sfe.list_deleted_volumes().volumes
 
     return sf_volumes
 
@@ -89,19 +89,19 @@ def _get_not_active_sf_volumes_only(sf_volumes):
     not_active_sf_volumes_only = []
 
     for sf_volume in sf_volumes:
-        if sf_volume["status"] != "active":
+        if sf_volume.status != "active":
             not_active_sf_volumes_only.append(sf_volume)
 
     return not_active_sf_volumes_only
 
-def get_active_sf_volumes(sf_client, sf_account_id=None):
+def get_active_sf_volumes(sfe, sf_account_id=None):
     if sf_account_id is not None:
-        sf_volumes = sf_client.list_volumes_for_account(sf_account_id)
+        sf_volumes = sfe.list_volumes_for_account(sf_account_id).volumes
 
         if sf_volumes is not None and len(sf_volumes) > 0:
             sf_volumes = _get_active_sf_volumes_only(sf_volumes)
     else:
-        sf_volumes = sf_client.list_active_volumes()
+        sf_volumes = sfe.list_active_volumes().volumes
 
     return sf_volumes
 
@@ -109,7 +109,7 @@ def _get_active_sf_volumes_only(sf_volumes):
     active_sf_volumes_only = []
 
     for sf_volume in sf_volumes:
-        if sf_volume["status"] == "active":
+        if sf_volume.status == "active":
             active_sf_volumes_only.append(sf_volume)
 
     return active_sf_volumes_only
@@ -118,7 +118,7 @@ def check_and_get_sf_volume(sf_volumes, sf_volume_name, obj_assert, should_exist
     sf_volume = None
 
     for volume in sf_volumes:
-        if volume['name'] == sf_volume_name:
+        if volume.name == sf_volume_name:
             sf_volume = volume
             break
 
@@ -155,13 +155,13 @@ def check_xen_sr(xen_sr_name, xen_session, obj_assert, should_exist=True):
 
 def check_vag(sf_volume, sf_vag_id, obj_assert):
     obj_assert.assertEqual(
-        len(sf_volume['volumeAccessGroups']),
+        len(sf_volume.volume_access_groups),
         1,
         "The volume should only be in one VAG."
     )
 
     obj_assert.assertEqual(
-        sf_volume['volumeAccessGroups'][0],
+        sf_volume.volume_access_groups[0],
         sf_vag_id,
         "The volume is not in the VAG with the following ID: " + str(sf_vag_id) + "."
     )
@@ -185,21 +185,21 @@ def format_iqn(iqn):
 
 def check_size_and_iops(sf_volume, cs_volume, size, obj_assert):
     obj_assert.assertEqual(
-        sf_volume['qos']['minIOPS'],
+        sf_volume.qos.min_iops,
         cs_volume.miniops,
-        "Check QoS - Min IOPS: " + str(sf_volume['qos']['minIOPS'])
+        "Check QoS - Min IOPS: " + str(sf_volume.qos.min_iops)
     )
 
     obj_assert.assertEqual(
-        sf_volume['qos']['maxIOPS'],
+        sf_volume.qos.max_iops,
         cs_volume.maxiops,
-        "Check QoS - Max IOPS: " + str(sf_volume['qos']['maxIOPS'])
+        "Check QoS - Max IOPS: " + str(sf_volume.qos.max_iops)
     )
 
     obj_assert.assertEqual(
-        sf_volume['totalSize'],
+        sf_volume.total_size,
         size,
-        "Check SolidFire volume size: " + str(sf_volume['totalSize'])
+        "Check SolidFire volume size: " + str(sf_volume.total_size)
     )
 
 def get_volume_size_with_hsr(cs_api, cs_volume, obj_assert):


Mime
View raw message