From c3105657d4623c8b5f1314daff8ae59aac1d2fab Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 23 Sep 2020 11:09:31 +0000 Subject: [PATCH] Fix doc strings --- .../openstack/charm_tests/ceph/iscsi/tests.py | 70 +++++++++++++++---- 1 file changed, 55 insertions(+), 15 deletions(-) diff --git a/zaza/openstack/charm_tests/ceph/iscsi/tests.py b/zaza/openstack/charm_tests/ceph/iscsi/tests.py index 2665c10..17775b7 100644 --- a/zaza/openstack/charm_tests/ceph/iscsi/tests.py +++ b/zaza/openstack/charm_tests/ceph/iscsi/tests.py @@ -32,7 +32,13 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): EC_METADATA_POOL = 'zaza_ec_metadata_pool' def get_client_initiatorname(self, unit): - """Return the initiatorname for the given unit.""" + """Return the initiatorname for the given unit. + + :param unit_name: Name of unit to match + :type unit: str + :returns: Initiator name + :rtype: str + """ generic_utils.assertRemoteRunOK(zaza.model.run_on_unit( unit, ('cp /etc/iscsi/initiatorname.iscsi /tmp; ' @@ -52,7 +58,11 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): return initiatorname def get_base_ctxt(self): - """Generate a context for running gwcli commands to create a target.""" + """Generate a context for running gwcli commands to create a target. + + :returns: Base gateway context + :rtype: Dict + """ gw_units = zaza.model.get_units('ceph-iscsi') primary_gw = gw_units[0] secondary_gw = gw_units[1] @@ -79,8 +89,16 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): def run_commands(self, unit_name, commands, ctxt): """Run commands on unit. - Apply context to commands until all variables have been replaced, then - run the command on the given unit. + Iterate over each command and apply the context to the command, then + run the command on the suppliend unit. + + :param unit_name: Name of unit to match + :type unit: str + :param commands: List of commands to run. + :type commands: List[str] + :param ctxt: Context to apply to each command. + :type ctxt: Dict + :raises: AssertionError """ for _cmd in commands: cmd = _cmd.format(**ctxt) @@ -89,7 +107,11 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): cmd)) def create_iscsi_target(self, ctxt): - """Create target on gateway.""" + """Create target on gateway. + + :param ctxt: Base gateway context + :type ctxt: Dict + """ generic_utils.assertActionRanOK(zaza.model.run_action_on_leader( 'ceph-iscsi', 'create-target', @@ -108,7 +130,11 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): })) def login_iscsi_target(self, ctxt): - """Mount iscsi target on client.""" + """Login to the iscsi target on client. + + :param ctxt: Base gateway context + :type ctxt: Dict + """ logging.info("Logging in to iscsi target") base_op_cmd = ('iscsiadm --mode node --targetname {gw_iqn} ' '--op=update ').format(**ctxt) @@ -121,14 +147,25 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): self.run_commands(ctxt['client_entity_id'], setup_cmds, ctxt) def logout_iscsi_targets(self, ctxt): - """Logout of iscsi target on client.""" + """Logout of iscsi target on client. + + :param ctxt: Base gateway context + :type ctxt: Dict + """ logging.info("Logging out of iscsi target") logout_cmds = [ 'iscsiadm --mode node --logoutall=all'] self.run_commands(ctxt['client_entity_id'], logout_cmds, ctxt) def check_client_device(self, ctxt, init_client=True): - """Wait for multipath device to appear on client and test access.""" + """Wait for multipath device to appear on client and test access. + + :param ctxt: Base gateway context + :type ctxt: Dict + :param init_client: Initialise client if this is the first time it has + been used. + :type init_client: bool + """ logging.info("Checking multipath device is present.") device_ctxt = { 'bdevice': '/dev/dm-0', @@ -203,19 +240,22 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): action_params={ 'name': self.EC_METADATA_POOL})) - def run_client_checks(self, ctxt): + def run_client_checks(self, test_ctxt): """Check access to mulipath device. Write a filesystem to device, mount it and write data. Then unmount and logout the iscsi target, finally reconnect and remount checking data is still present. + + :param test_ctxt: Test context. + :type test_ctxt: Dict """ - self.create_iscsi_target(ctxt) - self.login_iscsi_target(ctxt) - self.check_client_device(ctxt, init_client=True) - self.logout_iscsi_targets(ctxt) - self.login_iscsi_target(ctxt) - self.check_client_device(ctxt, init_client=False) + self.create_iscsi_target(test_ctxt) + self.login_iscsi_target(test_ctxt) + self.check_client_device(test_ctxt, init_client=True) + self.logout_iscsi_targets(test_ctxt) + self.login_iscsi_target(test_ctxt) + self.check_client_device(test_ctxt, init_client=False) def test_create_and_mount_volume(self): """Test creating a target and mounting it on a client."""