Skip to content
Open
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
3 changes: 2 additions & 1 deletion hpe3parclient/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ def _http_log_req(self, args, kwargs):
string_parts.append(header)

HTTPJSONRESTClient._logger.debug("\nREQ: %s\n" % "".join(string_parts))

if 'body' in kwargs:
if 'password' in kwargs['body']:
kwargs['body']['password'] = "********"
HTTPJSONRESTClient._logger.debug("REQ BODY: %s\n" %
(kwargs['body']))

def _http_log_resp(self, resp, body):
if not self.http_log_debug:
return
Expand Down
10 changes: 6 additions & 4 deletions test/test_HPE3ParClient_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Test class of 3PAR Client handling Host."""

from test import HPE3ParClient_base as hpe3parbase

import mock
from hpe3parclient import exceptions

# Insert colons into time string to match WWN format.
Expand Down Expand Up @@ -615,7 +615,6 @@ def test_5_query_host_wwn(self):
optional = {'domain': DOMAIN}
fc = [WWN1]
self.cl.createHost(HOST_NAME1, None, fc, optional)

hosts = self.cl.queryHost(wwns=[fc.pop().replace(':', '')])
self.assertIsNotNone(hosts)
self.assertEqual(1, hosts['total'])
Expand Down Expand Up @@ -645,9 +644,12 @@ def test_5_query_host_iqn_and_wwn(self):
self.assertIn(HOST_NAME2, [host['name'] for host in hosts['members']])
self.printFooter('query_host_iqn_and_wwn')

def test_6_find_host(self):
@mock.patch('hpe3parclient.client.HPE3ParClient._run')
@mock.patch('hpe3parclient.client.HPE3ParClient.deleteHost')
def test_6_find_host(self, mock_deletehost, mock_run):
self.printHeader('find_host_wwn')

mock_run.return_value = 'host name'
mock_deletehost.return_value = None
hosts = self.cl.findHost(wwn=WWN1)

if hosts is not None:
Expand Down
6 changes: 4 additions & 2 deletions test/test_HPE3ParClient_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from testconfig import config
import unittest
import mock
from test import HPE3ParClient_base as hpe3parbase

from hpe3parclient import exceptions
Expand All @@ -30,7 +31,8 @@ def tearDown(self):
# very last, tear down base class
super(HPE3ParClientSystemTestCase, self).tearDown()

def test_get_patch(self):
@mock.patch('hpe3parclient.client.HPE3ParClient._run')
def test_get_patch(self, mockrun):
"""This can work with or without a patch, but you need to manually
enter a valid one or use the bogus one.

Expand All @@ -43,7 +45,7 @@ def test_get_patch(self):
#
# bogus patch name that should consistently be not recognized:
patch_id = 'P16-BOGUS'

mockrun.return_value = ["Patch P16-BOGUS not recognized"]
result = self.cl.getPatch(patch_id)
self.assertIsNotNone(result)
if len(result) > 1:
Expand Down
21 changes: 15 additions & 6 deletions test/test_HPE3ParClient_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import time
import unittest
from testconfig import config

import mock
from test import HPE3ParClient_base as hpe3parbase

from hpe3parclient import exceptions
Expand Down Expand Up @@ -2019,17 +2019,20 @@ def test_22_failover_remote_copy_group(self):

self.printFooter('failover_remote_copy_group')

def test_23_get_volume_snapshots(self):
@mock.patch('hpe3parclient.client.HPE3ParClient._run')
def test_23_get_volume_snapshots(self, mock_run):
# Create volume and snaphot it
optional = {'snapCPG': CPG_NAME1}
self.cl.createVolume(VOLUME_NAME1, CPG_NAME1, SIZE, optional)

self.cl.createSnapshot(SNAP_NAME1, VOLUME_NAME1)
self.cl.createSnapshot(SNAP_NAME2, VOLUME_NAME1)

mock_run.return_value = ["MiB)- Id Name Prov Compr Dedup Type CopyOf BsId Rd -Detailed_State-Snp Usr VSize",
"1, .srdata ,full ,NA, NA, base ,--- 1, RW ,normal ,0,882",
"2 ,SNAP_UNIT_TEST1,full,NA,NA,base, --- 1,RW,normal,0,882",
"3,SNAP_UNIT_TEST2,full,NA,NA,base,--- 1,RW,normal,0,882"]
# Get the volumes snapshots
snapshots = self.cl.getVolumeSnapshots(VOLUME_NAME1)

# Set snapshot names. If the test is not against a live array, we
# need to add the snapshot suffix.
if not is_live_test():
Expand All @@ -2041,22 +2044,28 @@ def test_23_get_volume_snapshots(self):
self.assertEqual([SNAP_NAME1, SNAP_NAME2], snapshots)

# Test where volume does not exist
mock_run.return_value = ["MiB)- Id Name Prov Compr Dedup Type CopyOf BsId Rd -Detailed_State-Snp Usr VSize",
"",
"",
""]
snapshots = self.cl.getVolumeSnapshots("BAD_VOL")
# An empty list is returned if the volume does not exist
self.assertEqual([], snapshots)

def test_24_set_qos(self):
@mock.patch('hpe3parclient.client.HPE3ParClient._run')
def test_24_set_qos(self, mock_run):
self.printHeader('set_qos')
self.cl.createVolumeSet(VOLUME_SET_NAME4,
comment="Unit test volume set 4")

mock_run.return_value="QOS Exception"
self.assertRaises(
exceptions.SetQOSRuleException,
self.cl.setQOSRule,
VOLUME_SET_NAME4)

max_io = 300
max_bw = 1024
mock_run.return_value = None
self.cl.setQOSRule(VOLUME_SET_NAME4, max_io, max_bw)
self.cl.setQOSRule(VOLUME_SET_NAME4, max_io)
self.cl.setQOSRule(VOLUME_SET_NAME4, max_bw)
Expand Down