Commit bb28c46d authored by Chandan Kumar's avatar Chandan Kumar Committed by Mehdi Abaakouk

Remove bundled intree ceileometer tempest plugin

* All the telemetry related projects intree tempest plugins
  are now moved to telemetry-tempest-plugin

Change-Id: I57738964f65495364dcc74821634d54aea1769fd
parent 9116376a
defaults:
request_headers:
x-auth-token: $ENVIRON['USER_TOKEN']
tests:
- name: list alarms none
desc: Lists alarms, none yet exist
url: $ENVIRON['AODH_SERVICE_URL']/v2/alarms
method: GET
response_strings:
- "[]"
- name: list servers none
desc: List servers, none yet exists
url: $ENVIRON['NOVA_SERVICE_URL']/servers
method: GET
response_strings:
- "[]"
- name: create stack
desc: Create an autoscaling stack
url: $ENVIRON['HEAT_SERVICE_URL']/stacks
method: POST
request_headers:
content-type: application/json
data: <@create_stack.json
status: 201
- name: control stack status
desc: Checks the stack have been created successfully
url: $ENVIRON['HEAT_SERVICE_URL']/stacks/integration_test
redirects: true
method: GET
status: 200
poll:
count: 300
delay: 1
response_json_paths:
$.stack.stack_status: "CREATE_COMPLETE"
- name: list servers grow
desc: Wait the autoscaling stack grow to two servers
url: $ENVIRON['NOVA_SERVICE_URL']/servers/detail
method: GET
poll:
count: 600
delay: 1
response_json_paths:
$.servers[0].metadata.'metering.server_group': $RESPONSE['$.stack.id']
$.servers[1].metadata.'metering.server_group': $RESPONSE['$.stack.id']
$.servers[0].status: ACTIVE
$.servers[1].status: ACTIVE
$.servers.`len`: 2
- name: check gnocchi resources
desc: Check the gnocchi resources for this two servers exists
url: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource/instance
method: GET
poll:
count: 30
delay: 1
response_strings:
- '"id": "$RESPONSE["$.servers[0].id"]"'
- '"id": "$RESPONSE["$.servers[1].id"]"'
- name: check event
desc: Check panko for new instance.create.end event
url: $ENVIRON['PANKO_SERVICE_URL']/v2/events
method: GET
request_headers:
content-type: application/json
data:
q:
- field: event_type
op: eq
type: string
value: compute.instance.create.end
- field: resource_id
op: eq
type: string
value: $HISTORY['list servers grow'].$RESPONSE['$.servers[0].id']
poll:
count: 30
delay: 1
response_json_paths:
$.`len`: 1
$[0].event_type: compute.instance.create.end
$[0].traits[?(@.name='resource_id')].value: $HISTORY['list servers grow'].$RESPONSE['$.servers[0].id']
- name: check alarm
desc: Check the aodh alarm and its state
url: $ENVIRON['AODH_SERVICE_URL']/v2/alarms
method: GET
poll:
count: 30
delay: 1
response_strings:
- "integration_test-cpu_alarm_high-"
response_json_paths:
$[0].state: alarm
- name: get stack location for update
desc: Get the stack location
url: $ENVIRON['HEAT_SERVICE_URL']/stacks/integration_test
method: GET
status: 302
- name: update stack
desc: Update an autoscaling stack
url: $LOCATION
method: PUT
request_headers:
content-type: application/json
data: <@update_stack.json
status: 202
- name: control stack status
desc: Checks the stack have been created successfully
url: $ENVIRON['HEAT_SERVICE_URL']/stacks/integration_test
redirects: true
method: GET
status: 200
poll:
count: 300
delay: 1
response_json_paths:
$.stack.stack_status: "UPDATE_COMPLETE"
- name: list servers shrink
desc: Wait the autoscaling stack shrink to one server
url: $ENVIRON['NOVA_SERVICE_URL']/servers/detail
method: GET
poll:
count: 600
delay: 1
response_json_paths:
$.servers[0].metadata.'metering.server_group': $RESPONSE['$.stack.id']
$.servers[0].status: ACTIVE
$.servers.`len`: 1
- name: get stack location
desc: Get the stack location
url: $ENVIRON['HEAT_SERVICE_URL']/stacks/integration_test
method: GET
status: 302
- name: delete stack
desc: Delete the stack
url: $LOCATION
method: DELETE
status: 204
- name: get deleted stack
desc: Check the stack have been deleted
url: $ENVIRON['HEAT_SERVICE_URL']/stacks/integration_test
redirects: true
method: GET
poll:
count: 300
delay: 1
status: 404
- name: list alarms deleted
desc: List alarms, no more exist
url: $ENVIRON['AODH_SERVICE_URL']/v2/alarms
method: GET
response_strings:
- "[]"
- name: list servers deleted
desc: List servers, no more exists
url: $ENVIRON['NOVA_SERVICE_URL']/servers
method: GET
response_strings:
- "[]"
{
"stack_name": "integration_test",
"template": {
"heat_template_version": "2013-05-23",
"description": "Integration Test AutoScaling with heat+ceilometer+gnocchi+aodh",
"resources": {
"asg": {
"type": "OS::Heat::AutoScalingGroup",
"properties": {
"min_size": 1,
"max_size": 2,
"resource": {
"type": "OS::Nova::Server",
"properties": {
"networks": [{ "network": "$ENVIRON['NEUTRON_NETWORK']" }],
"flavor": "$ENVIRON['NOVA_FLAVOR_REF']",
"image": "$ENVIRON['GLANCE_IMAGE_NAME']",
"metadata": {
"metering.server_group": { "get_param": "OS::stack_id" }
},
"user_data_format": "RAW",
"user_data": {"Fn::Join": ["", [
"#!/bin/sh\n",
"echo 'Loading CPU'\n",
"set -v\n",
"cat /dev/urandom > /dev/null\n"
]]}
}
}
}
},
"web_server_scaleup_policy": {
"type": "OS::Heat::ScalingPolicy",
"properties": {
"adjustment_type": "change_in_capacity",
"auto_scaling_group_id": { "get_resource": "asg" },
"cooldown": 2,
"scaling_adjustment": 1
}
},
"cpu_alarm_high": {
"type": "OS::Ceilometer::GnocchiAggregationByResourcesAlarm",
"properties": {
"description": "Scale-up if the mean CPU > 10% on 1 minute",
"metric": "cpu_util",
"aggregation_method": "mean",
"granularity": $ENVIRON["AODH_GRANULARITY"],
"evaluation_periods": 1,
"threshold": 10,
"comparison_operator": "gt",
"alarm_actions": [
{
"str_replace": {
"template": "trust+url",
"params": {
"url": { "get_attr": [ "web_server_scaleup_policy", "signal_url" ] }
}
}
}
],
"resource_type": "instance",
"query": {
"str_replace": {
"template": "{\"and\": [{\"=\": {\"server_group\": \"stack_id\"}}, {\"=\": {\"ended_at\": null}}]}",
"params": {
"stack_id": { "get_param": "OS::stack_id" }
}
}
}
}
}
}
}
}
{
"template": {
"heat_template_version": "2013-05-23",
"description": "Integration Test AutoScaling with heat+ceilometer+gnocchi+aodh",
"resources": {
"asg": {
"type": "OS::Heat::AutoScalingGroup",
"properties": {
"min_size": 1,
"max_size": 2,
"resource": {
"type": "OS::Nova::Server",
"properties": {
"networks": [{ "network": "$ENVIRON['NEUTRON_NETWORK']" }],
"flavor": "$ENVIRON['NOVA_FLAVOR_REF']",
"image": "$ENVIRON['GLANCE_IMAGE_NAME']",
"metadata": {
"metering.server_group": { "get_param": "OS::stack_id" }
},
"user_data_format": "RAW",
"user_data": {"Fn::Join": ["", [
"#!/bin/sh\n",
"echo 'Loading CPU'\n",
"set -v\n",
"cat /dev/urandom > /dev/null\n"
]]}
}
}
}
},
"web_server_scaledown_policy": {
"type": "OS::Heat::ScalingPolicy",
"properties": {
"adjustment_type": "change_in_capacity",
"auto_scaling_group_id": { "get_resource": "asg" },
"cooldown": 2,
"scaling_adjustment": -1
}
},
"cpu_alarm_high": {
"type": "OS::Ceilometer::GnocchiAggregationByResourcesAlarm",
"properties": {
"description": "Scale-down if the mean CPU > 10% on 1 minute",
"metric": "cpu_util",
"aggregation_method": "mean",
"granularity": $ENVIRON["AODH_GRANULARITY"],
"evaluation_periods": 1,
"threshold": 10,
"comparison_operator": "gt",
"alarm_actions": [
{
"str_replace": {
"template": "trust+url",
"params": {
"url": { "get_attr": [ "web_server_scaledown_policy", "signal_url" ] }
}
}
}
],
"resource_type": "instance",
"query": {
"str_replace": {
"template": "{\"and\": [{\"=\": {\"server_group\": \"stack_id\"}}, {\"=\": {\"ended_at\": null}}]}",
"params": {
"stack_id": { "get_param": "OS::stack_id" }
}
}
}
}
}
}
}
}
#
# Copyright 2015 Red Hat. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""A test module to exercise the Gnocchi API with gabbi."""
import os
from gabbi import driver
TESTS_DIR = 'gabbits-live'
def load_tests(loader, tests, pattern):
"""Provide a TestSuite to the discovery process."""
NEEDED_ENV = ["AODH_SERVICE_URL", "GNOCCHI_SERVICE_URL",
"HEAT_SERVICE_URL", "NOVA_SERVICE_URL", "PANKO_SERVICE_URL",
"GLANCE_IMAGE_NAME", "ADMIN_TOKEN"]
for env_variable in NEEDED_ENV:
if not os.getenv(env_variable):
if os.getenv("GABBI_LIVE_FAIL_IF_NO_TEST"):
raise RuntimeError('%s is not set' % env_variable)
else:
return
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
return driver.build_tests(test_dir, loader, host="localhost", port=8041)
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
import tempest.test
from ceilometer.tests.tempest.aodh.service import client
CONF = config.CONF
class BaseAlarmingTest(tempest.test.BaseTestCase):
"""Base test case class for all Alarming API tests."""
credentials = ['primary']
client_manager = client.Manager
@classmethod
def skip_checks(cls):
super(BaseAlarmingTest, cls).skip_checks()
if not CONF.service_available.aodh_plugin:
raise cls.skipException("Aodh support is required")
@classmethod
def setup_clients(cls):
super(BaseAlarmingTest, cls).setup_clients()
cls.alarming_client = cls.os_primary.alarming_client
@classmethod
def resource_setup(cls):
super(BaseAlarmingTest, cls).resource_setup()
cls.alarm_ids = []
@classmethod
def create_alarm(cls, **kwargs):
body = cls.alarming_client.create_alarm(
name=data_utils.rand_name('telemetry_alarm'),
type='gnocchi_aggregation_by_metrics_threshold', **kwargs)
cls.alarm_ids.append(body['alarm_id'])
return body
@staticmethod
def cleanup_resources(method, list_of_ids):
for resource_id in list_of_ids:
try:
method(resource_id)
except lib_exc.NotFound:
pass
@classmethod
def resource_cleanup(cls):
cls.cleanup_resources(cls.alarming_client.delete_alarm, cls.alarm_ids)
super(BaseAlarmingTest, cls).resource_cleanup()
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
from ceilometer.tests.tempest.aodh.api import base
class TelemetryAlarmingAPITest(base.BaseAlarmingTest):
@classmethod
def resource_setup(cls):
super(TelemetryAlarmingAPITest, cls).resource_setup()
cls.rule = {'metrics': ['c0d457b6-957e-41de-a384-d5eb0957de3b'],
'comparison_operator': 'gt',
'aggregation_method': 'mean',
'threshold': 80.0,
'granularity': 70}
for i in range(2):
cls.create_alarm(
gnocchi_aggregation_by_metrics_threshold_rule=cls.rule)
@decorators.idempotent_id('1c918e06-210b-41eb-bd45-14676dd77cd7')
def test_alarm_list(self):
# List alarms
alarm_list = self.alarming_client.list_alarms()
# Verify created alarm in the list
fetched_ids = [a['alarm_id'] for a in alarm_list]
missing_alarms = [a for a in self.alarm_ids if a not in fetched_ids]
self.assertEqual(0, len(missing_alarms),
"Failed to find the following created alarm(s)"
" in a fetched list: %s" %
', '.join(str(a) for a in missing_alarms))
@decorators.idempotent_id('1297b095-39c1-4e74-8a1f-4ae998cedd68')
def test_create_update_get_delete_alarm(self):
# Create an alarm
alarm_name = data_utils.rand_name('telemetry_alarm')
body = self.alarming_client.create_alarm(
name=alarm_name, type='gnocchi_aggregation_by_metrics_threshold',
gnocchi_aggregation_by_metrics_threshold_rule=self.rule)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(self.rule, body[
'gnocchi_aggregation_by_metrics_threshold_rule'])
# Update alarm with new rule and new name
new_rule = {'metrics': ['c0d457b6-957e-41de-a384-d5eb0957de3b'],
'comparison_operator': 'eq',
'aggregation_method': 'mean',
'threshold': 70.0,
'granularity': 60}
alarm_name_updated = data_utils.rand_name('telemetry-alarm-update')
body = self.alarming_client.update_alarm(
alarm_id,
gnocchi_aggregation_by_metrics_threshold_rule=new_rule,
name=alarm_name_updated,
type='gnocchi_aggregation_by_metrics_threshold')
self.assertEqual(alarm_name_updated, body['name'])
self.assertDictContainsSubset(
new_rule, body['gnocchi_aggregation_by_metrics_threshold_rule'])
# Get and verify details of an alarm after update
body = self.alarming_client.show_alarm(alarm_id)
self.assertEqual(alarm_name_updated, body['name'])
self.assertDictContainsSubset(
new_rule, body['gnocchi_aggregation_by_metrics_threshold_rule'])
# Get history for the alarm and verify the same
body = self.alarming_client.show_alarm_history(alarm_id)
self.assertEqual("rule change", body[0]['type'])
self.assertIn(alarm_name_updated, body[0]['detail'])
self.assertEqual("creation", body[1]['type'])
self.assertIn(alarm_name, body[1]['detail'])
# Delete alarm and verify if deleted
self.alarming_client.delete_alarm(alarm_id)
self.assertRaises(lib_exc.NotFound,
self.alarming_client.show_alarm, alarm_id)
@decorators.idempotent_id('aca49486-70bb-4016-87e0-f6131374f742')
def test_set_get_alarm_state(self):
alarm_states = ['ok', 'alarm', 'insufficient data']
alarm = self.create_alarm(
gnocchi_aggregation_by_metrics_threshold_rule=self.rule)
# Set alarm state and verify
new_state =\
[elem for elem in alarm_states if elem != alarm['state']][0]
state = self.alarming_client.alarm_set_state(alarm['alarm_id'],
new_state)
self.assertEqual(new_state, state.data)
# Get alarm state and verify
state = self.alarming_client.show_alarm_state(alarm['alarm_id'])
self.assertEqual(new_state, state.data)
# Copyright 2015 GlobalLogic. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_utils import uuidutils
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
from ceilometer.tests.tempest.aodh.api import base
class TelemetryAlarmingNegativeTest(base.BaseAlarmingTest):
"""Negative tests for show_alarm, update_alarm, show_alarm_history tests
** show non-existent alarm
** show the deleted alarm
** delete deleted alarm
** update deleted alarm
"""
@decorators.attr(type=['negative'])
@decorators.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81e7e')
def test_get_non_existent_alarm(self):
# get the non-existent alarm
non_existent_id = uuidutils.generate_uuid()
self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm,
non_existent_id)
@decorators.attr(type=['negative'])
@decorators.idempotent_id('ef45000d-0a72-4781-866d-4cb7bf2582ae')
def test_get_update_show_history_delete_deleted_alarm(self):
# get, update and delete the deleted alarm
alarm_name = data_utils.rand_name('telemetry_alarm')
rule = {'metrics': ["c0d457b6-957e-41de-a384-d5eb0957de3b"],
'aggregation_method': 'mean',
'comparison_operator': 'eq',
'threshold': 100.0,
'granularity': 90}
body = self.alarming_client.create_alarm(
name=alarm_name,
type='gnocchi_aggregation_by_metrics_threshold',
gnocchi_aggregation_by_metrics_threshold_rule=rule)
alarm_id = body['alarm_id']
self.alarming_client.delete_alarm(alarm_id)
# get the deleted alarm
self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm,
alarm_id)
# update the deleted alarm
updated_alarm_name = data_utils.rand_name('telemetry_alarm_updated')
updated_rule = {'metrics': ["c0d457b6-957e-41de-a384-d5eb0957de3b"],
'comparison_operator': 'eq',
'aggregation_method': 'mean',
'threshold': 70,
'granularity': 50}
self.assertRaises(
lib_exc.NotFound, self.alarming_client.update_alarm,
alarm_id,
gnocchi_aggregation_by_metrics_threshold_rule=updated_rule,
name=updated_alarm_name,
type='gnocchi_aggregation_by_metrics_threshold')
# delete the deleted alarm
self.assertRaises(lib_exc.NotFound, self.alarming_client.delete_alarm,
alarm_id)
# Copyright 2014 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
from six.moves.urllib import parse as urllib
from tempest import config
from tempest.lib.common import rest_client
from tempest import manager
CONF = config.CONF
class AlarmingClient(rest_client.RestClient):
version = '2'
uri_prefix = "v2"
def deserialize(self, body):
return json.loads(body.replace("\n", ""))
def serialize(self, body):
return json.dumps(body)
def list_alarms(self, query=None):
uri = '%s/alarms' % self.uri_prefix
uri_dict = {}
if query:
uri_dict = {'q.field': query[0],
'q.op': query[1],
'q.value': query[2]}
if uri_dict:
uri += "?%s" % urllib.urlencode(uri_dict)
resp, body = self.get(uri)
self.expected_success(200, resp.status)
body = self.deserialize(body)
return rest_client.ResponseBodyList(resp, body)
def show_alarm(self, alarm_id):
uri = '%s/alarms/%s' % (self.uri_prefix, alarm_id)
resp, body = self.get(uri)
self.expected_success(200, resp.status)
body = self.deserialize(body)
return rest_client.ResponseBody(resp, body)
def show_alarm_history(self, alarm_id):
uri = "%s/alarms/%s/history" % (self.uri_prefix, alarm_id)
resp, body = self.get(uri)
self.expected_success(200, resp.status)
body = self.deserialize(body)
return rest_client.ResponseBodyList(resp, body)
def delete_alarm(self, alarm_id):
uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
resp,