diff --git a/zaza/openstack/charm_tests/ceph/iscsi/setup.py b/zaza/openstack/charm_tests/ceph/iscsi/setup.py index 8662f8b..abd6a73 100644 --- a/zaza/openstack/charm_tests/ceph/iscsi/setup.py +++ b/zaza/openstack/charm_tests/ceph/iscsi/setup.py @@ -19,12 +19,12 @@ import zaza.model def basic_guest_setup(): """Run basic setup for iscsi guest.""" - unit = zaza.model.get_units('ubuntu')[0] - setup_cmds = [ - "apt install --yes open-iscsi multipath-tools", - "systemctl start iscsi", - "systemctl start iscsid"] - for cmd in setup_cmds: - zaza.model.run_on_unit( - unit.entity_id, - cmd) + for unit in zaza.model.get_units('ubuntu'): + setup_cmds = [ + "apt install --yes open-iscsi multipath-tools", + "systemctl start iscsi", + "systemctl start iscsid"] + for cmd in setup_cmds: + zaza.model.run_on_unit( + unit.entity_id, + cmd) diff --git a/zaza/openstack/charm_tests/ceph/iscsi/tests.py b/zaza/openstack/charm_tests/ceph/iscsi/tests.py index 3c904a6..08a7607 100644 --- a/zaza/openstack/charm_tests/ceph/iscsi/tests.py +++ b/zaza/openstack/charm_tests/ceph/iscsi/tests.py @@ -26,7 +26,10 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): """Class for `ceph-iscsi` tests.""" GW_IQN = "iqn.2003-03.com.canonical.iscsi-gw:iscsi-igw" - DATA_POOL_NAME = 'superssd' + DATA_POOL_NAME = 'zaza_rep_pool' + EC_PROFILE_NAME = 'zaza_iscsi' + EC_DATA_POOL = 'zaza_ec_data_pool' + EC_METADATA_POOL = 'zaza_ec_metadata_pool' def get_client_initiatorname(self, unit): """Return the initiatorname for the given unit.""" @@ -48,18 +51,16 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): initiatorname = line.split('=')[1].rstrip() return initiatorname - def get_ctxt(self): + def get_base_ctxt(self): """Generate a context for running gwcli commands to create a target.""" gw_units = zaza.model.get_units('ceph-iscsi') - client_units = zaza.model.get_units('ubuntu') - client = client_units[0] - self.get_client_initiatorname(client.entity_id) primary_gw = gw_units[0] secondary_gw = gw_units[1] host_names = generic_utils.get_unit_hostnames(gw_units, fqdn=True) + client_entity_ids = [ + u.entity_id for u in zaza.model.get_units('ubuntu')] ctxt = { - 'pool_name': self.DATA_POOL_NAME, - 'client_entity_id': client.entity_id, + 'client_entity_ids': sorted(client_entity_ids), 'gw_iqn': self.GW_IQN, 'gw1_ip': primary_gw.public_address, 'gw1_hostname': host_names[primary_gw.entity_id], @@ -67,13 +68,7 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): 'gw2_ip': secondary_gw.public_address, 'gw2_hostname': host_names[secondary_gw.entity_id], 'gw2_entity_id': secondary_gw.entity_id, - 'img_size': '1G', - 'img_name': 'disk_1', - 'chap_username': 'myiscsiusername', - 'chap_password': 'myiscsipassword', 'chap_creds': 'username={chap_username} password={chap_password}', - 'client_initiatorname': self.get_client_initiatorname( - client.entity_id), 'gwcli_gw_dir': '/iscsi-targets/{gw_iqn}/gateways', 'gwcli_hosts_dir': '/iscsi-targets/{gw_iqn}/hosts', 'gwcli_disk_dir': '/disks', @@ -103,7 +98,8 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): ctxt['gw1_entity_id'], ctxt['gw2_entity_id']), 'iqn': self.GW_IQN, - 'pool-name': self.DATA_POOL_NAME, + 'rbd-pool-name': ctxt['pool_name'], + 'ec-rbd-metadata-pool': ctxt.get('ec_meta_pool_name', ''), 'image-size': ctxt['img_size'], 'image-name': ctxt['img_name'], 'client-initiatorname': ctxt['client_initiatorname'], @@ -140,10 +136,63 @@ class CephISCSIGatewayTest(test_utils.BaseCharmTest): action_params={ 'name': self.DATA_POOL_NAME})) + def create_ec_data_pool(self): + """Create data pool to back iscsi targets.""" + generic_utils.assertActionRanOK(zaza.model.run_action_on_leader( + 'ceph-mon', + 'create-erasure-profile', + action_params={ + 'name': self.EC_PROFILE_NAME, + 'coding-chunks': 2, + 'data-chunks': 4, + 'plugin': 'jerasure'})) + generic_utils.assertActionRanOK(zaza.model.run_action_on_leader( + 'ceph-mon', + 'create-pool', + action_params={ + 'name': self.EC_DATA_POOL, + 'pool-type': 'erasure-coded', + 'allow-ec-overwrites': True, + 'erasure-profile-name': self.EC_PROFILE_NAME})) + generic_utils.assertActionRanOK(zaza.model.run_action_on_leader( + 'ceph-mon', + 'create-pool', + action_params={ + 'name': self.EC_METADATA_POOL})) + def test_create_and_mount_volume(self): """Test creating a target and mounting it on a client.""" self.create_data_pool() - ctxt = self.get_ctxt() + ctxt = self.get_base_ctxt() + client_entity_id = ctxt['client_entity_ids'][0] + ctxt.update({ + 'client_entity_id': client_entity_id, + 'client_initiatorname': self.get_client_initiatorname( + client_entity_id), + 'pool_name': self.DATA_POOL_NAME, + 'chap_username': 'myiscsiusername1', + 'chap_password': 'myiscsipassword1', + 'img_size': '1G', + 'img_name': 'disk_rep_1'}) + self.create_iscsi_target(ctxt) + self.mount_iscsi_target(ctxt) + self.check_client_device(ctxt) + + def test_create_and_mount_ec_backed_volume(self): + """Test creating an EC backed target and mounting it on a client.""" + self.create_ec_data_pool() + ctxt = self.get_base_ctxt() + client_entity_id = ctxt['client_entity_ids'][1] + ctxt.update({ + 'client_entity_id': client_entity_id, + 'client_initiatorname': self.get_client_initiatorname( + client_entity_id), + 'pool_name': self.EC_DATA_POOL, + 'ec_meta_pool_name': self.EC_METADATA_POOL, + 'chap_username': 'myiscsiusername2', + 'chap_password': 'myiscsipassword2', + 'img_size': '2G', + 'img_name': 'disk_ec_1'}) self.create_iscsi_target(ctxt) self.mount_iscsi_target(ctxt) self.check_client_device(ctxt)