[Asterisk-code-review] tests/endpoints/statsd: Add a test for StatsD statistics for... (testsuite[master])

Matt Jordan asteriskteam at digium.com
Wed Nov 18 21:28:59 CST 2015


Matt Jordan has uploaded a new change for review.

  https://gerrit.asterisk.org/1660

Change subject: tests/endpoints/statsd: Add a test for StatsD statistics for Asterisk endpoints
......................................................................

tests/endpoints/statsd: Add a test for StatsD statistics for Asterisk endpoints

This patch adds a test that covers Asterisk generating StatsD statistics for
its generic endpoints. The test takes a PJSIP endpoint, generates a call to it,
and verifies that the expected StatsD statistics are sent to a StatsD server.

ASTERISK-25572

Change-Id: I21f97108774002534c0dc33c1f04f2831f3bb9ff
---
A tests/endpoints/statsd/configs/ast1/extensions.conf
A tests/endpoints/statsd/configs/ast1/pjsip.conf
A tests/endpoints/statsd/configs/ast1/statsd.conf
A tests/endpoints/statsd/test-config.yaml
A tests/endpoints/tests.yaml
M tests/tests.yaml
6 files changed, 111 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/60/1660/1

diff --git a/tests/endpoints/statsd/configs/ast1/extensions.conf b/tests/endpoints/statsd/configs/ast1/extensions.conf
new file mode 100644
index 0000000..398f3e5
--- /dev/null
+++ b/tests/endpoints/statsd/configs/ast1/extensions.conf
@@ -0,0 +1,5 @@
+[default]
+
+exten => s,1,NoOp()
+ same => n,Answer()
+ same => n,Hangup()
diff --git a/tests/endpoints/statsd/configs/ast1/pjsip.conf b/tests/endpoints/statsd/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..35c6cec
--- /dev/null
+++ b/tests/endpoints/statsd/configs/ast1/pjsip.conf
@@ -0,0 +1,14 @@
+[mytransport]
+type=transport
+protocol=udp
+bind=127.0.0.1:5060
+
+[test]
+type=endpoint
+aors=test
+from_user=test
+allow=!all,ulaw
+
+[test]
+type=aor
+contact=sip:s at 127.0.0.1:5060
diff --git a/tests/endpoints/statsd/configs/ast1/statsd.conf b/tests/endpoints/statsd/configs/ast1/statsd.conf
new file mode 100644
index 0000000..d8d5a4c
--- /dev/null
+++ b/tests/endpoints/statsd/configs/ast1/statsd.conf
@@ -0,0 +1,3 @@
+[general]
+enabled = yes
+server = 127.0.0.1
\ No newline at end of file
diff --git a/tests/endpoints/statsd/test-config.yaml b/tests/endpoints/statsd/test-config.yaml
new file mode 100644
index 0000000..4190cae
--- /dev/null
+++ b/tests/endpoints/statsd/test-config.yaml
@@ -0,0 +1,86 @@
+testinfo:
+    summary:  Test sending statistics to a StatsD server for Asterisk endpoints
+    description: |
+        This test verifies that endpoint statistics are sent to a StatsD server
+        when operations related to that endpoint occur. The test originates
+        a PJSIP channel, and verifies that the appropriate StatsD messages
+        are received.
+
+test-modules:
+    test-object:
+        config-section: 'test-object-config'
+        typename: 'test_case.TestCaseModule'
+    modules:
+        -
+            typename: 'mockd.MockDServer'
+            config-section: 'statsd-config'
+        -
+            typename: 'pluggable_modules.Originator'
+            config-section: 'originator-config'
+        -
+            typename: 'pluggable_modules.HangupMonitor'
+            config-section: 'hangup-monitor'
+
+test-object-config:
+    asterisk-instances: 1
+    connect-ami: True
+    reactor-timeout: 15
+
+hangup-monitor:
+    ids: '0'
+
+# Note: due to a bug in getting duplicate endpoint events over
+# Stasis, we'll see two statsd messages for the channel counts
+# for an Endpoint. When that is fixed, the duplicate messages
+# below should be removed.
+statsd-config:
+    regex: True
+    packets:
+        -
+            'PJSIP\.contacts\.states\.Unknown:\+1\|g'
+        -
+            'PJSIP\.contacts\.test@@sip:s at 127\.0\.0\.1:5060\.rtt:.*\|ms'
+        -
+            'endpoints\.count:\+1\|g'
+        -
+            'endpoints\.state\.online:\+1\|g'
+        -
+            'endpoints\.PJSIP\.test\.channels:1\|g'
+        -
+            'endpoints\.PJSIP\.test\.channels:1\|g'
+        -
+            'endpoints\.PJSIP\.test\.channels:2\|g'
+        -
+            'endpoints\.PJSIP\.test\.channels:2\|g'
+        -
+            'endpoints\.PJSIP\.test\.channels:1\|g'
+        -
+            'endpoints\.PJSIP\.test\.channels:1\|g'
+        -
+            'endpoints\.PJSIP\.test\.channels:0\|g'
+        -
+            'endpoints\.PJSIP\.test\.channels:0\|g'
+        -
+            'endpoints\.count:\-1\|g'
+        -
+            'endpoints\.state\.online:\-1\|g'
+
+
+originator-config:
+    channel: 'PJSIP/test'
+    application: 'Echo'
+    trigger: 'ami_connect'
+    async: True
+
+properties:
+    minversion: '13.7.0'
+    dependencies:
+        - asterisk: 'app_echo'
+        - asterisk: 'chan_pjsip'
+        - asterisk: 'res_endpoint_stats'
+        - python: 'autobahn.websocket'
+        - python: 'starpy'
+        - python: 'twisted'
+    tags:
+        - statsd
+        - apps
diff --git a/tests/endpoints/tests.yaml b/tests/endpoints/tests.yaml
new file mode 100644
index 0000000..1ace9a4
--- /dev/null
+++ b/tests/endpoints/tests.yaml
@@ -0,0 +1,2 @@
+tests:
+    - test: 'statsd'
diff --git a/tests/tests.yaml b/tests/tests.yaml
index 1a92254..bc0acd9 100644
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -6,6 +6,7 @@
     - dir: 'manager'
     - dir: 'cdr'
     - dir: 'channels'
+    - dir: 'endpoints'
     - test: 'udptl'
     - test: 'udptl_v6'
     - test: 'feature_call_pickup'

-- 
To view, visit https://gerrit.asterisk.org/1660
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21f97108774002534c0dc33c1f04f2831f3bb9ff
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>



More information about the asterisk-code-review mailing list