Test the enhancements of the 'add-disk' action for ceph-osd
This PR tests that a new device is succesfully added to the OSD charm, and that it's done so via the 'bcache' mechanism. The backing storage is provided via a loopback device, whereas the caching storage is provided by Juju itself.
This commit is contained in:
@@ -22,6 +22,7 @@ from os import (
|
||||
path
|
||||
)
|
||||
import requests
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
import tenacity
|
||||
@@ -37,6 +38,33 @@ import zaza.utilities.juju as juju_utils
|
||||
import zaza.openstack.utilities.openstack as zaza_openstack
|
||||
|
||||
|
||||
def add_storage(unit, label, pool, size):
|
||||
rv = subprocess.check_output(['juju', 'add-storage', unit,
|
||||
'{}={},{}'.format(label, pool,
|
||||
str(size) + 'GB')],
|
||||
stderr=subprocess.STDOUT)
|
||||
return rv.decode('UTF-8').replace('added storage ', '').split(' ')[0]
|
||||
|
||||
|
||||
def detach_storage(storage_name):
|
||||
subprocess.check_call(['juju', 'detach-storage', storage_name])
|
||||
|
||||
|
||||
def remove_storage(storage_name, force=False):
|
||||
cmd = ['juju', 'remove-storage', storage_name]
|
||||
if force:
|
||||
cmd.append('--force')
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
def add_loop_device(unit, size=10):
|
||||
loop_name = '/home/ubuntu/loop.img'
|
||||
truncate = 'truncate --size {}GB {}'.format(size, loop_name)
|
||||
losetup = 'losetup --find {}'.format(loop_name)
|
||||
lofind = 'losetup -a | grep {} | cut -f1 -d ":"'.format(loop_name)
|
||||
cmd = "sudo sh -c '{} && {} && {}'".format(truncate, losetup, lofind)
|
||||
return zaza_model.run_on_unit(unit, cmd)
|
||||
|
||||
|
||||
class CephLowLevelTest(test_utils.OpenStackBaseTest):
|
||||
"""Ceph Low Level Test Class."""
|
||||
|
||||
@@ -463,7 +491,7 @@ class CephTest(test_utils.OpenStackBaseTest):
|
||||
|
||||
The blacklist actions execute and behave as expected.
|
||||
"""
|
||||
logging.info('Checking blacklist-add-disk and'
|
||||
logging.info('Checking blacklist-add-disk and '
|
||||
'blacklist-remove-disk actions...')
|
||||
unit_name = 'ceph-osd/0'
|
||||
|
||||
@@ -545,6 +573,20 @@ class CephTest(test_utils.OpenStackBaseTest):
|
||||
)
|
||||
logging.debug('OK')
|
||||
|
||||
def test_cache_device(self):
|
||||
logging.info('Running add-disk action with a caching device')
|
||||
osds = [x.entity_id for x in zaza_model.get_units('ceph-osd')]
|
||||
for unit in osds:
|
||||
add_storage(unit, 'cache-devices', 'cinder', 10)
|
||||
loop_dev = add_loop_device(unit, 10)
|
||||
action_obj = zaza_model.run_action(
|
||||
unit_name=unit,
|
||||
action_name='add-disk',
|
||||
action_params={'osd-devices': loop_dev.get('Stdout'),
|
||||
'partition-size': 5}
|
||||
)
|
||||
zaza_utils.assertActionRanOK(action_obj)
|
||||
|
||||
|
||||
class CephRGWTest(test_utils.OpenStackBaseTest):
|
||||
"""Ceph RADOS Gateway Daemons Test Class."""
|
||||
|
||||
Reference in New Issue
Block a user