Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pure codeview-recompose test_reset_connection #290

Merged
merged 4 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions delfin/drivers/pure/pure/pure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ def list_volumes(self, context):
pools = self.rest_handler.get_pools()
for volume in volumes:
volume_name = volume.get('name')
total_capacity = int(int(volume.get('size')) / units.Ki)
used_capacity = int(int(volume.get('volumes')) / units.Ki)
total_capacity = int(int(volume.get('size',
consts.DEFAULT_CAPACITY)) /
units.Ki)
used_capacity = int(int(volume.get('volumes',
consts.DEFAULT_CAPACITY)) /
units.Ki)
native_storage_pool_id = None
if pools:
for pool in pools:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys
from unittest import TestCase, mock

import six
from oslo_log import log

sys.modules['delfin.cryptor'] = mock.Mock()
Expand Down Expand Up @@ -264,7 +266,7 @@
]
reset_connection_info = {
"username": "username",
"status_code": 200
"status": 200
}


Expand All @@ -274,7 +276,7 @@ def create_driver():
return PureStorageDriver(**ACCESS_INFO)


class test_StorageDriver(TestCase):
class test_PureStorageDriver(TestCase):
driver = create_driver()

def test_init(self):
Expand Down Expand Up @@ -326,8 +328,18 @@ def test_list_ports(self):
self.assertEqual(list_ports[0].get('wwn'), port_info[0].get('wwn'))

def test_list_storage_pools(self):
RestHandler.get_info = mock.Mock(
side_effect=[pools_info])
RestHandler.get_info = mock.Mock(side_effect=[pools_info])
list_storage_pools = self.driver.list_storage_pools(context)
self.assertEqual(list_storage_pools[0].get('native_storage_pool_id'),
pools_info[0].get('name'))

def test_reset_connection(self):
RestHandler.logout = mock.Mock(side_effect=None)
RestHandler.login = mock.Mock(side_effect=None)
username = None
try:
self.driver.reset_connection(context)
except Exception as e:
LOG.error("test_reset_connection error: %s", six.text_type(e))
username = reset_connection_info.get('username')
self.assertEqual(username, None)