Simple test setup from api->thresh->notification->persister
This commit is contained in:
parent
4eeaace70f
commit
e1552a88ca
8
tests/README.md
Normal file
8
tests/README.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Test notifications
|
||||||
|
- The api is currently rejecting alarms with no action specified, so expect an error defining that alarm.
|
||||||
|
- Setup alarms and Notifications
|
||||||
|
- run ./alarm_notification_setup.py -e me@hp.com
|
||||||
|
- Run the jmeter tests
|
||||||
|
- `jmeter -t notification-jmeter.jmx &`
|
||||||
|
- The config is saved for a basic test that should create a notification on alarm and a hundred non-notification alarms. Change the thread
|
||||||
|
loop counts to try different combinations.
|
6
tests/alarms-no-notification/cpu.json
Normal file
6
tests/alarms-no-notification/cpu.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"description": "mini-mon cpu alarm",
|
||||||
|
"name": "compute.cpu",
|
||||||
|
"expression": "compute.cpu{hostname=vertica} >= 90",
|
||||||
|
"alarm_actions": [ ]
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"description": "mini-mon cpu alarm",
|
"description": "mini-mon cpu alarm",
|
||||||
"name": "compute.cpu",
|
"name": "compute.cpu",
|
||||||
"expression": "compute.cpu{hostname=kafka} >= 90",
|
"expression": "compute.cpu{hostname=kafka} >= 90",
|
||||||
"alarm_actions": [
|
"alarm_actions": [
|
||||||
"%s"
|
"%s"
|
||||||
],
|
],
|
||||||
"ok_actions": [
|
"ok_actions": [
|
||||||
"%s"
|
"%s"
|
||||||
],
|
],
|
||||||
"undetermined_actions": [
|
"undetermined_actions": [
|
||||||
"%s"
|
"%s"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ def post(conn, url, body):
|
|||||||
conn.request("POST", url, body, HEADERS)
|
conn.request("POST", url, body, HEADERS)
|
||||||
http_response = conn.getresponse()
|
http_response = conn.getresponse()
|
||||||
response = http_response.read()
|
response = http_response.read()
|
||||||
if http_response.status < 200 or http_response > 300:
|
if http_response.status < 200 or http_response.status > 300:
|
||||||
print("\tError %d response: %s" % (http_response.status, response))
|
print("\tError %d response: %s" % (http_response.status, response))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@ -41,11 +41,18 @@ def main():
|
|||||||
|
|
||||||
notification_method_id = response_json['id']
|
notification_method_id = response_json['id']
|
||||||
|
|
||||||
|
# Alarms with notification
|
||||||
for path in glob('alarms/*.json'):
|
for path in glob('alarms/*.json'):
|
||||||
with open(path, 'r') as alarm_file:
|
with open(path, 'r') as alarm_file:
|
||||||
alarm_json = alarm_file.read() % (notification_method_id, notification_method_id, notification_method_id)
|
alarm_json = alarm_file.read() % (notification_method_id, notification_method_id, notification_method_id)
|
||||||
print('Adding Alarm %s' % path)
|
print('Adding Alarm %s' % path)
|
||||||
post(conn, '/v2.0/alarms', alarm_json)
|
post(conn, '/v2.0/alarms', alarm_json)
|
||||||
|
|
||||||
|
# Alarms without notification
|
||||||
|
for path in glob('alarms-no-notification/*.json'):
|
||||||
|
print('Adding Alarm %s' % path)
|
||||||
|
with open(path, 'r') as alarm_file:
|
||||||
|
post(conn, '/v2.0/alarms', alarm_file.read())
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
249
tests/notification-jmeter.jmx
Normal file
249
tests/notification-jmeter.jmx
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<jmeterTestPlan version="1.2" properties="2.5" jmeter="2.10 r1533061">
|
||||||
|
<hashTree>
|
||||||
|
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Mini-mon notification test" enabled="true">
|
||||||
|
<stringProp name="TestPlan.comments"></stringProp>
|
||||||
|
<boolProp name="TestPlan.functional_mode">false</boolProp>
|
||||||
|
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
|
||||||
|
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
|
||||||
|
<collectionProp name="Arguments.arguments"/>
|
||||||
|
</elementProp>
|
||||||
|
<stringProp name="TestPlan.user_define_classpath"></stringProp>
|
||||||
|
</TestPlan>
|
||||||
|
<hashTree>
|
||||||
|
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
|
||||||
|
<collectionProp name="HeaderManager.headers">
|
||||||
|
<elementProp name="" elementType="Header">
|
||||||
|
<stringProp name="Header.name">Content-type</stringProp>
|
||||||
|
<stringProp name="Header.value">application/json</stringProp>
|
||||||
|
</elementProp>
|
||||||
|
<elementProp name="" elementType="Header">
|
||||||
|
<stringProp name="Header.name">Accept</stringProp>
|
||||||
|
<stringProp name="Header.value">application/json</stringProp>
|
||||||
|
</elementProp>
|
||||||
|
<elementProp name="" elementType="Header">
|
||||||
|
<stringProp name="Header.name">X-Tenant-Id</stringProp>
|
||||||
|
<stringProp name="Header.value">1</stringProp>
|
||||||
|
</elementProp>
|
||||||
|
</collectionProp>
|
||||||
|
</HeaderManager>
|
||||||
|
<hashTree/>
|
||||||
|
<ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="HTTP Request Defaults" enabled="true">
|
||||||
|
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
|
||||||
|
<collectionProp name="Arguments.arguments"/>
|
||||||
|
</elementProp>
|
||||||
|
<stringProp name="HTTPSampler.domain">192.168.10.4</stringProp>
|
||||||
|
<stringProp name="HTTPSampler.port">8080</stringProp>
|
||||||
|
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.path"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.concurrentPool">4</stringProp>
|
||||||
|
</ConfigTestElement>
|
||||||
|
<hashTree/>
|
||||||
|
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
|
||||||
|
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
|
||||||
|
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
|
||||||
|
<boolProp name="LoopController.continue_forever">false</boolProp>
|
||||||
|
<stringProp name="LoopController.loops">1</stringProp>
|
||||||
|
</elementProp>
|
||||||
|
<stringProp name="ThreadGroup.num_threads">1</stringProp>
|
||||||
|
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
|
||||||
|
<longProp name="ThreadGroup.start_time">1395693961000</longProp>
|
||||||
|
<longProp name="ThreadGroup.end_time">1395693961000</longProp>
|
||||||
|
<boolProp name="ThreadGroup.scheduler">false</boolProp>
|
||||||
|
<stringProp name="ThreadGroup.duration"></stringProp>
|
||||||
|
<stringProp name="ThreadGroup.delay"></stringProp>
|
||||||
|
</ThreadGroup>
|
||||||
|
<hashTree>
|
||||||
|
<LoopController guiclass="LoopControlPanel" testclass="LoopController" testname="Notification Loop" enabled="true">
|
||||||
|
<boolProp name="LoopController.continue_forever">true</boolProp>
|
||||||
|
<stringProp name="LoopController.loops">1</stringProp>
|
||||||
|
</LoopController>
|
||||||
|
<hashTree>
|
||||||
|
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="CPU Alarm metric" enabled="true">
|
||||||
|
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
|
||||||
|
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
|
||||||
|
<collectionProp name="Arguments.arguments">
|
||||||
|
<elementProp name="" elementType="HTTPArgument">
|
||||||
|
<boolProp name="HTTPArgument.always_encode">false</boolProp>
|
||||||
|
<stringProp name="Argument.value">{
|
||||||
|
"name": "compute.cpu",
|
||||||
|
"dimensions": {
|
||||||
|
"hostname": "kafka"
|
||||||
|
},
|
||||||
|
"timestamp": "${__javaScript(int(new Date().getTime()/1000);)}",
|
||||||
|
"value": "95.0"
|
||||||
|
}
|
||||||
|
</stringProp>
|
||||||
|
<stringProp name="Argument.metadata">=</stringProp>
|
||||||
|
</elementProp>
|
||||||
|
</collectionProp>
|
||||||
|
</elementProp>
|
||||||
|
<stringProp name="HTTPSampler.domain"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.port"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.path">/v2.0/metrics</stringProp>
|
||||||
|
<stringProp name="HTTPSampler.method">POST</stringProp>
|
||||||
|
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.monitor">false</boolProp>
|
||||||
|
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
|
||||||
|
</HTTPSamplerProxy>
|
||||||
|
<hashTree/>
|
||||||
|
<ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer" enabled="true">
|
||||||
|
<stringProp name="ConstantTimer.delay">1000</stringProp>
|
||||||
|
</ConstantTimer>
|
||||||
|
<hashTree/>
|
||||||
|
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="CPU Ok metric" enabled="true">
|
||||||
|
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
|
||||||
|
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
|
||||||
|
<collectionProp name="Arguments.arguments">
|
||||||
|
<elementProp name="" elementType="HTTPArgument">
|
||||||
|
<boolProp name="HTTPArgument.always_encode">false</boolProp>
|
||||||
|
<stringProp name="Argument.value">{
|
||||||
|
"name": "compute.cpu",
|
||||||
|
"dimensions": {
|
||||||
|
"hostname": "kafka"
|
||||||
|
},
|
||||||
|
"timestamp": "${__javaScript(int(new Date().getTime()/1000);)}",
|
||||||
|
"value": "50.0"
|
||||||
|
}</stringProp>
|
||||||
|
<stringProp name="Argument.metadata">=</stringProp>
|
||||||
|
</elementProp>
|
||||||
|
</collectionProp>
|
||||||
|
</elementProp>
|
||||||
|
<stringProp name="HTTPSampler.domain"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.port"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.path">/v2.0/metrics</stringProp>
|
||||||
|
<stringProp name="HTTPSampler.method">POST</stringProp>
|
||||||
|
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.monitor">false</boolProp>
|
||||||
|
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
|
||||||
|
</HTTPSamplerProxy>
|
||||||
|
<hashTree/>
|
||||||
|
</hashTree>
|
||||||
|
<LoopController guiclass="LoopControlPanel" testclass="LoopController" testname="No Notification Loop" enabled="false">
|
||||||
|
<boolProp name="LoopController.continue_forever">true</boolProp>
|
||||||
|
<stringProp name="LoopController.loops">100</stringProp>
|
||||||
|
</LoopController>
|
||||||
|
<hashTree>
|
||||||
|
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="CPU Alarm metric" enabled="true">
|
||||||
|
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
|
||||||
|
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
|
||||||
|
<collectionProp name="Arguments.arguments">
|
||||||
|
<elementProp name="" elementType="HTTPArgument">
|
||||||
|
<boolProp name="HTTPArgument.always_encode">false</boolProp>
|
||||||
|
<stringProp name="Argument.value">{
|
||||||
|
"name": "compute.cpu",
|
||||||
|
"dimensions": {
|
||||||
|
"hostname": "vertica"
|
||||||
|
},
|
||||||
|
"timestamp": "${__javaScript(int(new Date().getTime()/1000);)}",
|
||||||
|
"value": "95.0"
|
||||||
|
}
|
||||||
|
</stringProp>
|
||||||
|
<stringProp name="Argument.metadata">=</stringProp>
|
||||||
|
</elementProp>
|
||||||
|
</collectionProp>
|
||||||
|
</elementProp>
|
||||||
|
<stringProp name="HTTPSampler.domain"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.port"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.path">/v2.0/metrics</stringProp>
|
||||||
|
<stringProp name="HTTPSampler.method">POST</stringProp>
|
||||||
|
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.monitor">false</boolProp>
|
||||||
|
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
|
||||||
|
</HTTPSamplerProxy>
|
||||||
|
<hashTree/>
|
||||||
|
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="CPU Ok metric" enabled="true">
|
||||||
|
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
|
||||||
|
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
|
||||||
|
<collectionProp name="Arguments.arguments">
|
||||||
|
<elementProp name="" elementType="HTTPArgument">
|
||||||
|
<boolProp name="HTTPArgument.always_encode">false</boolProp>
|
||||||
|
<stringProp name="Argument.value">{
|
||||||
|
"name": "compute.cpu",
|
||||||
|
"dimensions": {
|
||||||
|
"hostname": "vertica"
|
||||||
|
},
|
||||||
|
"timestamp": "${__javaScript(int(new Date().getTime()/1000);)}",
|
||||||
|
"value": "50.0"
|
||||||
|
}</stringProp>
|
||||||
|
<stringProp name="Argument.metadata">=</stringProp>
|
||||||
|
</elementProp>
|
||||||
|
</collectionProp>
|
||||||
|
</elementProp>
|
||||||
|
<stringProp name="HTTPSampler.domain"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.port"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
||||||
|
<stringProp name="HTTPSampler.path">/v2.0/metrics</stringProp>
|
||||||
|
<stringProp name="HTTPSampler.method">POST</stringProp>
|
||||||
|
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
|
||||||
|
<boolProp name="HTTPSampler.monitor">false</boolProp>
|
||||||
|
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
|
||||||
|
</HTTPSamplerProxy>
|
||||||
|
<hashTree/>
|
||||||
|
</hashTree>
|
||||||
|
</hashTree>
|
||||||
|
<ResultCollector guiclass="StatVisualizer" testclass="ResultCollector" testname="Aggregate Report" enabled="true">
|
||||||
|
<boolProp name="ResultCollector.error_logging">false</boolProp>
|
||||||
|
<objProp>
|
||||||
|
<name>saveConfig</name>
|
||||||
|
<value class="SampleSaveConfiguration">
|
||||||
|
<time>true</time>
|
||||||
|
<latency>true</latency>
|
||||||
|
<timestamp>true</timestamp>
|
||||||
|
<success>true</success>
|
||||||
|
<label>true</label>
|
||||||
|
<code>true</code>
|
||||||
|
<message>true</message>
|
||||||
|
<threadName>true</threadName>
|
||||||
|
<dataType>true</dataType>
|
||||||
|
<encoding>false</encoding>
|
||||||
|
<assertions>true</assertions>
|
||||||
|
<subresults>true</subresults>
|
||||||
|
<responseData>false</responseData>
|
||||||
|
<samplerData>false</samplerData>
|
||||||
|
<xml>false</xml>
|
||||||
|
<fieldNames>false</fieldNames>
|
||||||
|
<responseHeaders>false</responseHeaders>
|
||||||
|
<requestHeaders>false</requestHeaders>
|
||||||
|
<responseDataOnError>false</responseDataOnError>
|
||||||
|
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
|
||||||
|
<assertionsResultsToSave>0</assertionsResultsToSave>
|
||||||
|
<bytes>true</bytes>
|
||||||
|
</value>
|
||||||
|
</objProp>
|
||||||
|
<stringProp name="filename"></stringProp>
|
||||||
|
</ResultCollector>
|
||||||
|
<hashTree/>
|
||||||
|
</hashTree>
|
||||||
|
</hashTree>
|
||||||
|
</jmeterTestPlan>
|
Loading…
Reference in New Issue
Block a user