Skip to content
Snippets Groups Projects
Commit 35880b56 authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Updates alerts integration test

parent 69f50c74
No related branches found
No related tags found
No related merge requests found
......@@ -124,9 +124,11 @@ class AlertsConfigurationAPI(object):
if len(alert_tasks_errors) > 0:
return_msg["triggers_specification_errors"] = alert_tasks_errors
self.request.response.status = 400
if len(alert_handlers_errors) > 0:
return_msg["triggers_action_errors"] = alert_handlers_errors
self.request.response.status = 400
return return_msg
......
......@@ -60,7 +60,7 @@ topology_template:
action:
implementation:
- http://172.40.231.200:9999/
- deadman_policies:
- deadman_policy:
type: eu.ict-flame.policies.StateChange
triggers:
no_measurements:
......
......@@ -91,19 +91,17 @@ def set_up_tear_down_fixture(rspec_config):
rmtree(LOG_TEST_FOLDER_PATH)
print("Deleting Kapacitor tasks, topics and handlers that were created for this test...")
test_sfc_instance_scope = "CLMCMetrics.MS_I1"
# get all tasks from kapacitor (that were created in this test) and delete them
kapacitor_tasks = get("{0}/kapacitor/v1/tasks".format(kapacitor_url)).json()["tasks"]
kapacitor_task_links = [task["link"]["href"] for task in kapacitor_tasks if task["id"].startswith(test_sfc_instance_scope)]
kapacitor_task_links = [task["link"]["href"] for task in kapacitor_tasks]
for task_link in kapacitor_task_links:
delete("{0}{1}".format(kapacitor_url, task_link))
# get all topics and handlers from kapacitor (that were created in this test) and delete them
kapacitor_topics = get("{0}/kapacitor/v1/alerts/topics".format(kapacitor_url)).json()["topics"]
for topic in kapacitor_topics:
if topic["id"].startswith(test_sfc_instance_scope):
topic_handlers = get("{0}{1}".format(kapacitor_url, topic["handlers-link"]["href"])).json()["handlers"]
for handler in topic_handlers:
delete("{0}{1}".format(kapacitor_url, handler["link"]["href"]))
topic_handlers = get("{0}{1}".format(kapacitor_url, topic["handlers-link"]["href"])).json()["handlers"]
for handler in topic_handlers:
delete("{0}{1}".format(kapacitor_url, handler["link"]["href"]))
delete("{0}{1}".format(kapacitor_url, topic["link"]["href"]))
delete("{0}{1}".format(kapacitor_url, topic["link"]["href"]))
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
metadata:
template_name: Flame CLMC Alerts Integration Test
sfc: CLMCMetrics
sfci: MS_I1
# Import own definitions of nodes, capabilities and policy syntax.
imports:
- flame_definitions-0.1.7.yaml
# Starting the template
## Topology
topology_template:
node_templates:
database:
type: eu.ict-flame.nodes.ServiceFunction
capabilities:
host:
properties:
num_cpus: 2
mem_size: 4096 MB
disk_size: 10 GB
properties:
hypervisor: kvm
image_url: http://cdimage.debian.org/cdimage/openstack/current-9/debian-9-openstack-amd64.qcow2
fqdn:
- db.app.ict-flame.eu
frontend:
type: eu.ict-flame.nodes.ServiceFunction
capabilities:
host:
properties:
num_cpus: 2
disk_size: 10 GB
mem_size: 4096 MB
properties:
hypervisor: kvm
image_url: http://cdimage.debian.org/cdimage/openstack/current-9/debian-9-openstack-amd64.qcow2
fqdn:
- frontend.app.ict-flame.eu
- www.app.ict-flame.eu
policies:
- init:
type: eu.ict-flame.policies.InitialPolicy
description: Start the nodes initially
properties:
parent: service_paid
triggers:
inital_trigger:
condition:
constraint: initialise
action:
frontend:
-
fqdn: frontend.app.ict-flame.eu
lifecycle_actions:
London: eu.ict-flame.sfe.state.lifecycle.connected
Bristol: eu.ict-flame.sfe.state.lifecycle.booted
Manchester: eu.ict-flame.sfe.state.lifecycle.connected
database:
-
fqdn: db.app.ict-flame.eu
lifecycle_actions:
London: eu.ict-flame.sfe.state.lifecycle.connected
- scale_nginx_policy:
type: eu.ict-flame.policies.StateChange
properties:
parent: service_paid
triggers:
tigger_a:
condition:
constraint: clmc::high_requests
action:
frontend:
-
fqdn: frontend.app.ict-flame.eu
lifecycle_actions:
Bristol: eu.ict-flame.sfe.state.lifecycle.connected
tigger_b:
condition:
constraint: clmc::high_cpu_usage
period: 600 # integer required, unit: seconds
action:
frontend:
- fqdn: frontend.app.ict-flame.eu
lifecycle_actions:
Bristol: eu.ict-flame.sfe.state.lifecycle.connected
tigger_c:
condition:
constraint: clmc::increase_in_active_requests
period: 600 # integer required, unit: seconds
action:
frontend:
- fqdn: frontend.app.ict-flame.eu
lifecycle_actions:
Bristol: eu.ict-flame.sfe.state.lifecycle.connected
- deadman_policy:
type: eu.ict-flame.policies.StateChange
properties:
parent: service_paid
triggers:
tigger_a:
condition:
constraint: clmc::no_measurements
action:
frontend:
-
fqdn: frontend.app.ict-flame.eu
lifecycle_actions:
Bristol: eu.ict-flame.sfe.state.lifecycle.connected
- service_paid:
type: eu.ict-flame.policies.StateChange
description: Check outstanding payments. If there are outstanding payments, we shutdown the deployed service.
triggers:
not_paid_trigger:
description: Check if the payment is late
condition:
constraint: clmc-user-db::serviceIsNotPaid # this will be ignored, source must be clmc
period: 3600 # integer required, unit: seconds
action:
frontend:
-
fqdn: frontend.app.ict-flame.eu
lifecycle_actions:
London: eu.ict-flame.sfe.state.lifecycle.shutdown
Bristol: eu.ict-flame.sfe.state.lifecycle.shutdown
Manchester: eu.ict-flame.sfe.state.lifecycle.shutdown
database:
-
fqdn: db.app.ict-flame.eu
lifecycle_action:
London: eu.ict-flame.sfe.state.lifecycle.shutdown
......@@ -61,11 +61,16 @@ class TestAlerts(object):
print("Sending alerts specification to clmc service...")
alerts_spec = join(dirname(__file__), "alerts_test_config.yaml")
with open(alerts_spec, 'rb') as fh:
files = {'alert-spec': fh}
response = post("http://{0}:{1}/alerts".format(clmc_service_host, CLMC_SERVICE_PORT), files=files)
assert response.status_code == 200
resources_spec = join(dirname(__file__), "resources_test_config.yaml")
with open(alerts_spec, 'rb') as alerts:
with open(resources_spec, 'rb') as resources:
files = {'alert-spec': alerts, 'resource-spec': resources}
response = post("http://{0}:{1}/alerts".format(clmc_service_host, CLMC_SERVICE_PORT), files=files)
assert response.status_code == 200
clmc_service_response = response.json()
assert "triggers_specification_errors" not in clmc_service_response, "Unexpected error was returned for triggers specification"
assert "triggers_action_errors" not in clmc_service_response, "Unexpected error was returned for handlers specification"
print("Alert spec sent successfully")
print("Wait 10 seconds for Kapacitor stream/batch tasks to start working...")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment