Skip to content

Commit

Permalink
Add ceph pg tuning test
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMacNaughton committed Sep 5, 2019
1 parent a03ecb4 commit 2888e62
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
21 changes: 18 additions & 3 deletions zaza/openstack/charm_tests/ceph/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Ceph Testing."""

import unittest
import json
import logging
from os import (
listdir,
Expand Down Expand Up @@ -56,7 +57,7 @@ def test_processes(self):
}

ceph_osd_processes = {
'ceph-osd': [2, 3]
'ceph-osd': [1, 2, 3]
}

# Units with process names and PID quantities expected
Expand Down Expand Up @@ -95,6 +96,16 @@ def test_services(self):
target_status='running'
)

@test_utils.skipUntilVersion('ceph-mon', 'ceph', '14.2.0')
def test_pg_tuning(self):
"""Verify that auto PG tuning is enabled for Nautilus+."""
unit_name = 'ceph-mon/0'
cmd = "ceph osd pool autoscale-status --format=json"
result = zaza_model.run_on_unit(unit_name, cmd)
self.assertEqual(result['Code'], '0')
for pool in json.loads(result['Stdout']):
self.assertEqual(pool['pg_autoscale_mode'], 'on')


class CephRelationTest(test_utils.OpenStackBaseTest):
"""Ceph's relations test class."""
Expand Down Expand Up @@ -138,7 +149,6 @@ def _ceph_to_ceph_osd_relation(self, remote_unit_name):
fsid = result.get('Stdout').strip()
expected = {
'private-address': remote_ip,
'auth': 'none',
'ceph-public-address': remote_ip,
'fsid': fsid,
}
Expand Down Expand Up @@ -408,9 +418,14 @@ def test_blocked_when_non_pristine_disk_appears(self):

set_default = {
'ephemeral-unmount': '',
'osd-devices': '/dev/vdb /srv/ceph',
'osd-devices': '/dev/vdb',
}

current_release = zaza_openstack.get_os_release()
bionic_train = zaza_openstack.get_os_release('bionic_train')
if current_release < bionic_train:
set_default['osd-devices'] = '/dev/vdb /srv/ceph'

logging.info('Restoring to default configuration...')
zaza_model.set_application_config(juju_service, set_default)

Expand Down
21 changes: 21 additions & 0 deletions zaza/openstack/charm_tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
"""Module containg base class for implementing charm tests."""
import contextlib
import logging
import subprocess
import unittest
import zaza.model

import zaza.model as model
import zaza.charm_lifecycle.utils as lifecycle_utils
import zaza.openstack.utilities.openstack as openstack_utils
import zaza.openstack.utilities.generic as generic_utils


def skipIfNotHA(service_name):
Expand All @@ -38,6 +40,25 @@ def _skipIfNotHA_inner_2(*args, **kwargs):
return _skipIfNotHA_inner_1


def skipUntilVersion(service, package, release):
"""Run decorator to skip this test if application version is too low."""
def _skipUntilVersion_inner_1(f):
def _skipUntilVersion_inner_2(*args, **kwargs):
package_version = generic_utils.get_pkg_version(service, package)
try:
subprocess.check_call(['dpkg', '--compare-versions',
package_version, 'ge', release],
stderr=subprocess.STDOUT,
universal_newlines=True)
return f(*args, **kwargs)
except subprocess.CalledProcessError as cp:
logging.warn("Skipping test for older ({})"
"service {}, requested {}".format(
package_version, service, release))
return _skipUntilVersion_inner_2
return _skipUntilVersion_inner_1


def audit_assertions(action,
expected_passes,
expected_failures=None,
Expand Down

0 comments on commit 2888e62

Please sign in to comment.