Merge "Add functional tests for Redis plugin"
This commit is contained in:
commit
a914841794
@ -12,7 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
import ceilometerclient.v2.client
|
import ceilometerclient.v2.client
|
||||||
|
from proboscis import asserts
|
||||||
|
from six.moves import configparser
|
||||||
|
|
||||||
from stacklight_tests import base_test
|
from stacklight_tests import base_test
|
||||||
from stacklight_tests.ceilometer_redis import plugin_settings
|
from stacklight_tests.ceilometer_redis import plugin_settings
|
||||||
@ -90,3 +95,32 @@ class CeilometerRedisPluginApi(base_test.PluginApi):
|
|||||||
def check_uninstall_failure(self):
|
def check_uninstall_failure(self):
|
||||||
return self.helpers.check_plugin_cannot_be_uninstalled(
|
return self.helpers.check_plugin_cannot_be_uninstalled(
|
||||||
self.settings.name, self.settings.version)
|
self.settings.name, self.settings.version)
|
||||||
|
|
||||||
|
def disable_coordination(self):
|
||||||
|
ceilometer_conf = '/etc/ceilometer/ceilometer.conf'
|
||||||
|
controllers = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
|
||||||
|
self.helpers.cluster_id, ['controller'])
|
||||||
|
for controller in controllers:
|
||||||
|
with self.fuel_web.get_ssh_for_nailgun_node(controller) as remote:
|
||||||
|
with remote.open(ceilometer_conf) as f:
|
||||||
|
parser = configparser.RawConfigParser()
|
||||||
|
parser.readfp(f)
|
||||||
|
parser.remove_option('coordination', 'backend_url')
|
||||||
|
with remote.open(ceilometer_conf, 'w') as f:
|
||||||
|
parser.write(f)
|
||||||
|
with self.fuel_web.get_ssh_for_nailgun_node(controllers[0]) as remote:
|
||||||
|
self.remote_ops.manage_pacemaker_service(
|
||||||
|
remote, 'p_ceilometer-agent-central', operation='restart')
|
||||||
|
|
||||||
|
def check_sample_count(self, expected_count):
|
||||||
|
image = self.helpers.create_image()
|
||||||
|
time.sleep(2 * self.settings.polling_interval)
|
||||||
|
f = datetime.datetime.now() - datetime.timedelta(seconds=600)
|
||||||
|
query = [{'field': 'timestamp', 'op': 'ge', 'value': f.isoformat()},
|
||||||
|
{'field': 'resource_id', 'op': 'eq', 'value': image.id}]
|
||||||
|
actual_count = self.ceilometer.statistics.list(
|
||||||
|
q=query, meter_name='image')[0].count
|
||||||
|
msg = ("Expected {0} image sample for one "
|
||||||
|
"polling period , got : {1} .").format(expected_count,
|
||||||
|
actual_count)
|
||||||
|
asserts.assert_true(expected_count == actual_count, msg)
|
||||||
|
@ -12,10 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import datetime
|
|
||||||
import tempfile
|
|
||||||
import time
|
|
||||||
|
|
||||||
from proboscis import asserts
|
from proboscis import asserts
|
||||||
from proboscis import test
|
from proboscis import test
|
||||||
|
|
||||||
@ -35,7 +31,7 @@ class TestFunctionalCeilometerRedisPlugin(api.CeilometerRedisPluginApi):
|
|||||||
"""Verify that all measurements are collected
|
"""Verify that all measurements are collected
|
||||||
after stopping one of central agents.
|
after stopping one of central agents.
|
||||||
"""
|
"""
|
||||||
|
self.env.revert_snapshot("deploy_ceilometer_redis")
|
||||||
controller = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
|
controller = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
|
||||||
self.helpers.cluster_id, ['controller'])[0]
|
self.helpers.cluster_id, ['controller'])[0]
|
||||||
with self.fuel_web.get_ssh_for_nailgun_node(controller) as remote:
|
with self.fuel_web.get_ssh_for_nailgun_node(controller) as remote:
|
||||||
@ -55,7 +51,7 @@ class TestFunctionalCeilometerRedisPlugin(api.CeilometerRedisPluginApi):
|
|||||||
"""Check 'Joined partitioning group agent-central'
|
"""Check 'Joined partitioning group agent-central'
|
||||||
in the aodh-evaluator logs.
|
in the aodh-evaluator logs.
|
||||||
"""
|
"""
|
||||||
|
self.env.revert_snapshot("deploy_ceilometer_redis")
|
||||||
controllers = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
|
controllers = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
|
||||||
self.helpers.cluster_id, ['controller'])
|
self.helpers.cluster_id, ['controller'])
|
||||||
for controller in controllers:
|
for controller in controllers:
|
||||||
@ -76,7 +72,7 @@ class TestFunctionalCeilometerRedisPlugin(api.CeilometerRedisPluginApi):
|
|||||||
"""Check 'Joined partitioning group alarm_evaluator'
|
"""Check 'Joined partitioning group alarm_evaluator'
|
||||||
in the ceilometer-polling logs.
|
in the ceilometer-polling logs.
|
||||||
"""
|
"""
|
||||||
|
self.env.revert_snapshot("deploy_ceilometer_redis")
|
||||||
controllers = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
|
controllers = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
|
||||||
self.helpers.cluster_id, ['controller'])
|
self.helpers.cluster_id, ['controller'])
|
||||||
for controller in controllers:
|
for controller in controllers:
|
||||||
@ -95,20 +91,39 @@ class TestFunctionalCeilometerRedisPlugin(api.CeilometerRedisPluginApi):
|
|||||||
def check_samples_ceilometer_redis(self):
|
def check_samples_ceilometer_redis(self):
|
||||||
"""Check that for one polling interval only one 'image' sample exists.
|
"""Check that for one polling interval only one 'image' sample exists.
|
||||||
"""
|
"""
|
||||||
|
self.env.revert_snapshot("deploy_ceilometer_redis")
|
||||||
|
self.check_sample_count(expected_count=1)
|
||||||
|
|
||||||
with tempfile.TemporaryFile() as fp:
|
@test(depends_on_groups=["deploy_ceilometer_redis"],
|
||||||
fp.write('Test')
|
groups=["check_samples_with_one_agent_ceilometer_redis",
|
||||||
fp.seek(0)
|
"ceilometer_redis",
|
||||||
image = self.helpers.os_conn.create_image(name='Redis',
|
"functional"])
|
||||||
container_format='bare',
|
@log_snapshot_after_test
|
||||||
disk_format='qcow2',
|
def check_samples_with_one_agent_ceilometer_redis(self):
|
||||||
data=fp)
|
"""Check samples after ban two of three ceilometer-agent-central.
|
||||||
time.sleep(2 * self.settings.polling_interval)
|
"""
|
||||||
f = datetime.datetime.now() - datetime.timedelta(seconds=600)
|
self.env.revert_snapshot("deploy_ceilometer_redis")
|
||||||
query = [{'field': 'timestamp', 'op': 'ge', 'value': f.isoformat()},
|
controllers = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
|
||||||
{'field': 'resource_id', 'op': 'eq', 'value': image.id}]
|
self.helpers.cluster_id, ['controller'])
|
||||||
sample_count = self.ceilometer.statistics.list(
|
for controller in controllers[:2]:
|
||||||
q=query, meter_name='image')[0].count
|
with self.fuel_web.get_ssh_for_nailgun_node(controller) as remote:
|
||||||
msg = ("Expected 1 image sample for one "
|
remote.execute('pcs resource ban p_ceilometer-agent-central '
|
||||||
"polling period , got : {0} .").format(sample_count)
|
'$(hostname) --wait=100')
|
||||||
asserts.assert_true(sample_count == 1, msg)
|
result = remote.execute(' ps aux | grep -v grep | grep'
|
||||||
|
' -c ceilometer-polling')['stdout'][0]
|
||||||
|
msg = "Agent central wasn't stopped"
|
||||||
|
asserts.assert_true(int(result) == 0, msg)
|
||||||
|
self.check_sample_count(expected_count=1)
|
||||||
|
|
||||||
|
@test(depends_on_groups=["deploy_ceilometer_redis"],
|
||||||
|
groups=["check_central_disabled_coordination_ceilometer_redis",
|
||||||
|
"ceilometer_redis",
|
||||||
|
"functional"])
|
||||||
|
@log_snapshot_after_test
|
||||||
|
def check_central_disabled_coordination_ceilometer_redis(self):
|
||||||
|
"""Check that after disable coordination we have 3
|
||||||
|
image sample for the one polling period.
|
||||||
|
"""
|
||||||
|
self.env.revert_snapshot("deploy_ceilometer_redis")
|
||||||
|
self.disable_coordination()
|
||||||
|
self.check_sample_count(expected_count=3)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
@ -660,3 +661,14 @@ class PluginHelper(object):
|
|||||||
nac_subdict[option]['value'] = value
|
nac_subdict[option]['value'] = value
|
||||||
self.nailgun_client.update_cluster_attributes(
|
self.nailgun_client.update_cluster_attributes(
|
||||||
self.cluster_id, attributes)
|
self.cluster_id, attributes)
|
||||||
|
|
||||||
|
def create_image(self):
|
||||||
|
|
||||||
|
with tempfile.TemporaryFile() as fp:
|
||||||
|
fp.write('Test')
|
||||||
|
fp.seek(0)
|
||||||
|
image = self.os_conn.create_image(name='Redis',
|
||||||
|
container_format='bare',
|
||||||
|
disk_format='qcow2',
|
||||||
|
data=fp)
|
||||||
|
return image
|
||||||
|
Loading…
x
Reference in New Issue
Block a user