test_connection.py (manila-8.1.3) | : | test_connection.py (manila-8.1.4) | ||
---|---|---|---|---|
skipping to change at line 19 | skipping to change at line 19 | |||
# | # | |||
# Unless required by applicable law or agreed to in writing, software | # Unless required by applicable law or agreed to in writing, software | |||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
# License for the specific language governing permissions and limitations | # License for the specific language governing permissions and limitations | |||
# under the License. | # under the License. | |||
import copy | import copy | |||
import ddt | import ddt | |||
import mock | import mock | |||
from oslo_utils import units | ||||
import six | import six | |||
from manila import exception | from manila import exception | |||
from manila.share.drivers.dell_emc.common.enas import utils as enas_utils | ||||
from manila import test | from manila import test | |||
from manila.tests.share.drivers.dell_emc.plugins.unity import fake_exceptions | from manila.tests.share.drivers.dell_emc.plugins.unity import fake_exceptions | |||
from manila.tests.share.drivers.dell_emc.plugins.unity import res_mock | from manila.tests.share.drivers.dell_emc.plugins.unity import res_mock | |||
from manila.tests.share.drivers.dell_emc.plugins.unity import utils | from manila.tests.share.drivers.dell_emc.plugins.unity import utils | |||
from oslo_utils import units | ||||
@ddt.ddt | @ddt.ddt | |||
class TestConnection(test.TestCase): | class TestConnection(test.TestCase): | |||
client = None | client = None | |||
@classmethod | @classmethod | |||
def setUpClass(cls): | def setUpClass(cls): | |||
cls.emc_share_driver = res_mock.FakeEMCShareDriver() | cls.emc_share_driver = res_mock.FakeEMCShareDriver() | |||
@res_mock.patch_connection_init | @res_mock.patch_connection_init | |||
skipping to change at line 291 | skipping to change at line 292 | |||
share, | share, | |||
None) | None) | |||
@res_mock.patch_connection | @res_mock.patch_connection | |||
def test_update_share_stats(self, connection): | def test_update_share_stats(self, connection): | |||
stat_dict = copy.deepcopy(res_mock.STATS) | stat_dict = copy.deepcopy(res_mock.STATS) | |||
connection.update_share_stats(stat_dict) | connection.update_share_stats(stat_dict) | |||
self.assertEqual(5, len(stat_dict)) | self.assertEqual(5, len(stat_dict)) | |||
pool = stat_dict['pools'][0] | pool = stat_dict['pools'][0] | |||
self.assertEqual('pool_1', pool['pool_name']) | self.assertEqual('pool_1', pool['pool_name']) | |||
self.assertEqual(500000.0, pool['total_capacity_gb']) | self.assertEqual( | |||
enas_utils.bytes_to_gb(500000.0), pool['total_capacity_gb']) | ||||
self.assertEqual(False, pool['qos']) | self.assertEqual(False, pool['qos']) | |||
self.assertEqual(30000.0, pool['provisioned_capacity_gb']) | self.assertEqual( | |||
enas_utils.bytes_to_gb(30000.0), pool['provisioned_capacity_gb']) | ||||
self.assertEqual(20, pool['max_over_subscription_ratio']) | self.assertEqual(20, pool['max_over_subscription_ratio']) | |||
self.assertEqual(10000.0, pool['allocated_capacity_gb']) | self.assertEqual( | |||
enas_utils.bytes_to_gb(10000.0), pool['allocated_capacity_gb']) | ||||
self.assertEqual(0, pool['reserved_percentage']) | self.assertEqual(0, pool['reserved_percentage']) | |||
self.assertTrue(pool['thin_provisioning']) | self.assertTrue(pool['thin_provisioning']) | |||
self.assertEqual(490000.0, pool['free_capacity_gb']) | self.assertEqual( | |||
enas_utils.bytes_to_gb(490000.0), pool['free_capacity_gb']) | ||||
@res_mock.patch_connection | @res_mock.patch_connection | |||
def test_update_share_stats__nonexistent_pools(self, connection): | def test_update_share_stats__nonexistent_pools(self, connection): | |||
stat_dict = copy.deepcopy(res_mock.STATS) | stat_dict = copy.deepcopy(res_mock.STATS) | |||
self.assertRaises(exception.EMCUnityError, | self.assertRaises(exception.EMCUnityError, | |||
connection.update_share_stats, | connection.update_share_stats, | |||
stat_dict) | stat_dict) | |||
@res_mock.mock_manila_input | @res_mock.mock_manila_input | |||
End of changes. 7 change blocks. | ||||
5 lines changed or deleted | 10 lines changed or added |