add tests iscsi-connector
This commit is contained in:
@@ -26,12 +26,15 @@
|
||||
# - configure ubuntu initiator with init dict, target, port
|
||||
# """
|
||||
|
||||
import logging
|
||||
|
||||
import zaza.model
|
||||
import zaza.openstack.utilities.openstack as openstack_utils
|
||||
|
||||
|
||||
def basic_target_setup():
|
||||
"""Run basic setup for iscsi guest."""
|
||||
logging.info('Installing package tgt on ubuntu-target')
|
||||
unit = zaza.model.get_units('ubuntu-target')[0]
|
||||
setup_cmds = [
|
||||
"apt install --yes tgt",
|
||||
@@ -50,6 +53,7 @@ def configure_iscsi_target():
|
||||
"""echo -e '<target {}>\n\tbacking-store {}\n\tinitiator-address {}\n</target>' | """
|
||||
"""sudo tee /etc/tgt/conf.d/iscsi.conf""".format(lun, backing_store,initiator_address)
|
||||
)
|
||||
logging.info('Writing target iscsi.conf')
|
||||
zaza.model.run_on_unit('ubuntu-target/0', write_file)
|
||||
# Restart tgt to load new config
|
||||
restart_tgt = "systemctl restart tgt"
|
||||
|
||||
@@ -12,4 +12,37 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Encapsulate iscsi-connector testing."""
|
||||
"""Encapsulate iscsi-connector testing."""
|
||||
|
||||
import logging
|
||||
import tempfile
|
||||
|
||||
import zaza.model
|
||||
import zaza.openstack.charm_tests.test_utils as test_utils
|
||||
import zaza.openstack.utilities.generic as generic_utils
|
||||
|
||||
|
||||
class ISCSIConnectorTest(test_utils.BaseCharmTest):
|
||||
"""Class for iscsi-connector tests."""
|
||||
|
||||
IQN = 'iqn.2020-07.canonical.com:lun1'
|
||||
|
||||
def configure_iscsi_connector(self):
|
||||
unit_fqdn = self.get_unit_full_hostname('ubuntu/0')
|
||||
target_ip = zaza.model.get_app_ips('ubuntu-target')[0]
|
||||
conf = {
|
||||
'initiator-dictionary': '{"{unit_fqdn}":"{IQN}"}',
|
||||
'target': target_ip,
|
||||
'port': '3260',
|
||||
}
|
||||
zaza.model.set_application_config('iscsi-connector', conf)
|
||||
|
||||
def get_unit_full_hostname(self, unit_name):
|
||||
"""Retrieve the full hostname of a unit."""
|
||||
for unit in zaza.model.get_units(unit_name):
|
||||
result = zaza.model.run_on_unit(unit.entity_id, 'hostname -f')
|
||||
hostname = result['Stdout'].rstrip()
|
||||
return hostname
|
||||
|
||||
def test_iscsi_connector(self):
|
||||
self.configure_iscsi_connector()
|
||||
Reference in New Issue
Block a user