[asterisk-commits] StatsD: Write Testsuite tests (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 18 22:31:09 CST 2015


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: StatsD: Write Testsuite tests
......................................................................


StatsD: Write Testsuite tests

Wrote the nominal and off-nominal tests that will use the StatsD
mock server to test the StatsD Dialplan application.

ASTERISK-25419
Reported By: Ashley Sanders

Change-Id: Id93dbeea53cf978461151e9002af2afe1029ce8b
---
A tests/apps/statsd/mockd.py
A tests/apps/statsd/nominal/configs/ast1/extensions.conf
A tests/apps/statsd/nominal/configs/ast1/statsd.conf
D tests/apps/statsd/nominal/mockd.py
M tests/apps/statsd/nominal/test-config.yaml
A tests/apps/statsd/off-nominal/empty_params/configs/ast1/extensions.conf
A tests/apps/statsd/off-nominal/empty_params/configs/ast1/statsd.conf
A tests/apps/statsd/off-nominal/empty_params/test-config.yaml
A tests/apps/statsd/off-nominal/invalid_metric/configs/ast1/extensions.conf
A tests/apps/statsd/off-nominal/invalid_metric/configs/ast1/statsd.conf
A tests/apps/statsd/off-nominal/invalid_metric/test-config.yaml
A tests/apps/statsd/off-nominal/invalid_sample_rate/configs/ast1/extensions.conf
A tests/apps/statsd/off-nominal/invalid_sample_rate/configs/ast1/statsd.conf
A tests/apps/statsd/off-nominal/invalid_sample_rate/test-config.yaml
A tests/apps/statsd/off-nominal/invalid_value/configs/ast1/extensions.conf
A tests/apps/statsd/off-nominal/invalid_value/configs/ast1/statsd.conf
A tests/apps/statsd/off-nominal/invalid_value/test-config.yaml
A tests/apps/statsd/off-nominal/invalid_variable/configs/ast1/extensions.conf
A tests/apps/statsd/off-nominal/invalid_variable/configs/ast1/statsd.conf
A tests/apps/statsd/off-nominal/invalid_variable/test-config.yaml
A tests/apps/statsd/off-nominal/no_metric/configs/ast1/extensions.conf
A tests/apps/statsd/off-nominal/no_metric/configs/ast1/statsd.conf
A tests/apps/statsd/off-nominal/no_metric/test-config.yaml
A tests/apps/statsd/off-nominal/no_value/configs/ast1/extensions.conf
A tests/apps/statsd/off-nominal/no_value/configs/ast1/statsd.conf
A tests/apps/statsd/off-nominal/no_value/test-config.yaml
A tests/apps/statsd/off-nominal/no_variable/configs/ast1/extensions.conf
A tests/apps/statsd/off-nominal/no_variable/configs/ast1/statsd.conf
A tests/apps/statsd/off-nominal/no_variable/test-config.yaml
A tests/apps/statsd/off-nominal/tests.yaml
M tests/apps/statsd/tests.yaml
31 files changed, 610 insertions(+), 102 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Ashley Sanders: Looks good to me, approved
  Matt Jordan: Looks good to me, but someone else must approve



diff --git a/tests/apps/statsd/mockd.py b/tests/apps/statsd/mockd.py
new file mode 100644
index 0000000..a58cccb
--- /dev/null
+++ b/tests/apps/statsd/mockd.py
@@ -0,0 +1,131 @@
+'''
+Copyright (C) 2015, Digium, Inc.
+Tyler Cambron <tcambron at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+from twisted.internet.protocol import DatagramProtocol
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+sys.path.append("tests/apps/statsd")
+
+LOGGER = logging.getLogger(__name__)
+
+
+class MockDProtocol(DatagramProtocol):
+    '''Protocol for the Mock Server to use for receiving messages.'''
+
+    def __init__(self, mockd_server):
+        '''Constructor.
+
+        Keyword Arguments:
+        mockd_server -- An instance of the mock StatsD server
+        '''
+        self.mockd_server = mockd_server
+
+    def datagramReceived(self, datagram, address):
+        '''An override function to handle incoming datagrams.
+
+        Keyword Arguments:
+        datagram -- The datagram that was received by the server
+        address -- The address that the datagram came from
+
+        Accept the datagram and send it to be checked against the config
+        '''
+        skip = ['stasis.message', 'channels.']
+        LOGGER.debug('Server received %s from %s', datagram, address)
+
+        if not (skip[0] in datagram or skip[1] in datagram):
+            self.mockd_server.message_handler(datagram)
+
+
+class MockDServer(object):
+    '''Pluggable Module that acts as a mock StatsD server'''
+
+    def __init__(self, config, test_object):
+        '''Constructor
+
+        Keyword Arguments:
+        config -- This object's YAML derived configuration
+        test_object -- The test object it plugs onto
+        '''
+        self.config = config
+        self.test_object = test_object
+        self.packets = []
+        self.test_object.register_stop_observer(self._stop_handler)
+        reactor.listenUDP(8125, MockDProtocol(self))
+
+    def check_message(self, message):
+        '''Checks a received message.
+
+        Keyword Arguments:
+        message -- The message to check.
+        '''
+        if message in self.config:
+            LOGGER.debug('%s found in config', message)
+        else:
+            LOGGER.error('%s not specified in configuration', message)
+            self.test_object.set_passed(False)
+            self.test_object.stop_reactor()
+
+    def message_handler(self, message):
+        '''Datagram message handler
+
+        Keyword Arguments:
+        message -- The datagram that was received by the server
+
+        Check the message against the config and pass the test if they match
+        '''
+        if self.config[0] == 'ReceiveNothing':
+            LOGGER.error('%s not specified in configuration', message)
+            self.test_object.set_passed(False)
+            self.test_object.stop_reactor()
+            return
+
+        self.packets.append(message)
+
+        self.check_message(message)
+
+    def _stop_handler(self, result):
+        '''A deferred callback called as a result of the test stopping
+
+        Keyword Arguments:
+        result -- The deferred parameter passed from callback to callback
+        '''
+        LOGGER.info('Checking packets received')
+
+        if (self.config[0] == 'ReceiveNothing') and (len(self.packets) == 0):
+            LOGGER.info('Server correctly received nothing')
+            self.test_object.set_passed(True)
+            LOGGER.info('Test is stopping')
+            return result
+
+        if len(self.packets) != len(self.config):
+            LOGGER.error('Number of received packets {0} is not equal to '
+                'the number of configured packets '
+                '{1}'.format(len(self.packets),
+                len(self.config)))
+            self.test_object.set_passed(False)
+            LOGGER.info('Test is stopping')
+            return result
+
+        failed_matches = [(actual, expected) for actual, expected in
+            zip(self.packets, self.config) if actual != expected]
+
+        if len(failed_matches) != 0:
+            LOGGER.error('The following packets failed to match: {0}'
+                .format(failed_matches))
+            self.test_object.set_passed(False)
+            LOGGER.info('Test is stopping')
+            return result
+
+        self.test_object.set_passed(True)
+        LOGGER.info('Test is stopping')
+        LOGGER.info('All packets matched')
+        return result
diff --git a/tests/apps/statsd/nominal/configs/ast1/extensions.conf b/tests/apps/statsd/nominal/configs/ast1/extensions.conf
new file mode 100644
index 0000000..ceebb56
--- /dev/null
+++ b/tests/apps/statsd/nominal/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[default]
+
+exten => start,1,NoOp()
+	same => n,StatsD(g,foo,1,1)
+	same => n,StatsD(s,bar,2)
+	same => n,StatsD(ms,baz,3,1)
+	same => n,StatsD(c,last,4)
\ No newline at end of file
diff --git a/tests/apps/statsd/nominal/configs/ast1/statsd.conf b/tests/apps/statsd/nominal/configs/ast1/statsd.conf
new file mode 100644
index 0000000..9c200b7
--- /dev/null
+++ b/tests/apps/statsd/nominal/configs/ast1/statsd.conf
@@ -0,0 +1,4 @@
+[general]
+enabled = yes			; When set to yes, statsd support is enabled
+server = 127.0.0.1		; server[:port] of statsd server to use.
+						; If not specified, the port is 8125
\ No newline at end of file
diff --git a/tests/apps/statsd/nominal/mockd.py b/tests/apps/statsd/nominal/mockd.py
deleted file mode 100644
index 354fae8..0000000
--- a/tests/apps/statsd/nominal/mockd.py
+++ /dev/null
@@ -1,97 +0,0 @@
-'''
-Copyright (C) 2015, Digium, Inc.
-Tyler Cambron <tcambron at digium.com>
-
-This program is free software, distributed under the terms of
-the GNU General Public License Version 2.
-'''
-
-import logging
-
-from twisted.internet.protocol import DatagramProtocol
-from twisted.internet import reactor
-
-LOGGER = logging.getLogger(__name__)
-
-
-class MockDProtocol(DatagramProtocol):
-    ''' Protocol for the Mock Server to use for receiving messages.
-    '''
-
-    def __init__(self, mockd_server):
-        ''' Constructor.
-
-        Keyword Arguments:
-        mockd_server -- An instance of the mock StatsD server
-        '''
-        self.mockd_server = mockd_server
-
-    def datagramReceived(self, datagram, address):
-        ''' AMI Newexten event handler
-
-        Keyword Arguments:
-        datagram -- The datagram that was received by the server
-        address -- The address that the datagram came from
-
-        Accept the datagram and send it to be checked against the config
-        '''
-        LOGGER.debug('Server received %s from %s' % (datagram, address))
-        self.mockd_server.message_received(datagram)
-
-
-class MockDServer(object):
-    ''' Pluggable Module that acts as a mock StatsD server
-    '''
-
-    def __init__(self, config, test_object):
-        ''' Constructor
-
-        Keyword Arguments:
-        config -- This object's YAML derived configuration
-        test_object -- The test object it plugs onto
-        '''
-        self.config = config
-        self.test_object = test_object
-        self.packets = []
-        self.test_object.register_stop_observer(self._stop_handler)
-        reactor.listenUDP(8080, MockDProtocol(self))
-
-    def message_received(self, message):
-        ''' Datagram message handler
-
-        Keyword Arguments:
-        message -- The datagram that was received by the server
-
-        Check the message against the config and pass the test if they match
-        '''
-        self.packets.append(message)
-
-        if len(self.packets) == len(self.config):
-            self.test_object.stop_reactor()
-
-    def _stop_handler(self, result):
-        ''' A deferred callback called as a result of the test stopping
-
-        Keyword Arguments:
-        result -- The deferred parameter passed from callback to callback
-        '''
-        LOGGER.info('Checking packets received')
-        if len(self.packets) != len(self.config):
-            LOGGER.error('Number of received packets {0} is not equal to the '
-                'number of configured packets {1}'.format(len(self.packets),
-                len(self.config)))
-            self.test_object.set_passed(False)
-            return
-
-        failed_matches = [(actual, expected) for actual, expected in
-            zip(self.packets, self.config) if actual != expected]
-
-        if len(failed_matches) != 0:
-            LOGGER.error('The following packets failed to match: {0}'
-                .format(failed_matches))
-            self.test_object.set_passed(False)
-            return
-
-        LOGGER.info('All packets matched')
-        self.test_object.set_passed(True)
-        LOGGER.debug('Test is stopping')
diff --git a/tests/apps/statsd/nominal/test-config.yaml b/tests/apps/statsd/nominal/test-config.yaml
index e4a851c..1103d9f 100644
--- a/tests/apps/statsd/nominal/test-config.yaml
+++ b/tests/apps/statsd/nominal/test-config.yaml
@@ -16,6 +16,9 @@
         -
             typename: 'mockd.MockDServer'
             config-section: 'statsd-config'
+        -
+            typename: 'pluggable_modules.Originator'
+            config-section: 'originator-config'
 
 test-object-config:
     asterisk-instances: 1
@@ -24,18 +27,28 @@
 
 statsd-config:
     -
-        'foo|val:2'
+        'foo:1|g'
     -
-        'bar|val:1'
+        'bar:2|s'
     -
-        'last|val:3'
+        'baz:3|ms'
+    -
+        'last:4|c'
+
+originator-config:
+    channel: 'Local/start at default'
+    context: default
+    exten: start
+    priority: 1
+    trigger: 'ami_connect'
+    async: True
 
 properties:
-    minversion: '13.5.0'
+    minversion: '13.7.0'
     dependencies:
         - python: 'autobahn.websocket'
         - python: 'starpy'
         - python: 'twisted'
     tags:
         - statsd
-        - apps
\ No newline at end of file
+        - apps
diff --git a/tests/apps/statsd/off-nominal/empty_params/configs/ast1/extensions.conf b/tests/apps/statsd/off-nominal/empty_params/configs/ast1/extensions.conf
new file mode 100644
index 0000000..de161a4
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/empty_params/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+
+exten => start,1,NoOp()
+	same => n,StatsD()
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/empty_params/configs/ast1/statsd.conf b/tests/apps/statsd/off-nominal/empty_params/configs/ast1/statsd.conf
new file mode 100644
index 0000000..47f9386
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/empty_params/configs/ast1/statsd.conf
@@ -0,0 +1,4 @@
+[general]
+enabled = yes			; When set to yes, statsd support is enabled
+server = 127.0.0.1:8080		; server[:port] of statsd server to use.
+						; If not specified, the port is 8125
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/empty_params/test-config.yaml b/tests/apps/statsd/off-nominal/empty_params/test-config.yaml
new file mode 100644
index 0000000..5ce4f54
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/empty_params/test-config.yaml
@@ -0,0 +1,47 @@
+testinfo:
+    summary:  |
+        Test sending empty statistics to the StatsD Dialplan Application
+    description: |
+        This test verifies that the StatsD Dialplan Application will fail
+        appropriately when no parameters are given.
+
+test-modules:
+    add-test-to-search-path: 'True'
+    add-relative-to-search-path: ['../..']
+    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'
+
+test-object-config:
+    asterisk-instances: 1
+    connect-ami: True
+    reactor-timeout: 15
+
+statsd-config:
+    -
+        'ReceiveNothing'
+
+originator-config:
+    channel: 'Local/start at default'
+    context: default
+    exten: start
+    priority: 1
+    trigger: 'ami_connect'
+    async: True
+
+properties:
+    minversion: '13.7.0'
+    dependencies:
+        - python: 'autobahn.websocket'
+        - python: 'starpy'
+        - python: 'twisted'
+    tags:
+        - statsd
+        - apps
diff --git a/tests/apps/statsd/off-nominal/invalid_metric/configs/ast1/extensions.conf b/tests/apps/statsd/off-nominal/invalid_metric/configs/ast1/extensions.conf
new file mode 100644
index 0000000..0c24103
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_metric/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+
+exten => start,1,NoOp()
+	same => n,StatsD(b,foo,2)
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/invalid_metric/configs/ast1/statsd.conf b/tests/apps/statsd/off-nominal/invalid_metric/configs/ast1/statsd.conf
new file mode 100644
index 0000000..47f9386
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_metric/configs/ast1/statsd.conf
@@ -0,0 +1,4 @@
+[general]
+enabled = yes			; When set to yes, statsd support is enabled
+server = 127.0.0.1:8080		; server[:port] of statsd server to use.
+						; If not specified, the port is 8125
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/invalid_metric/test-config.yaml b/tests/apps/statsd/off-nominal/invalid_metric/test-config.yaml
new file mode 100644
index 0000000..748b5f4
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_metric/test-config.yaml
@@ -0,0 +1,47 @@
+testinfo:
+    summary:  |
+        Test sending an invalid metric to the StatsD Dialplan Application
+    description: |
+        This test verifies that the StatsD Dialplan Application will fail
+        appropriately when an invalid metric type is given.
+
+test-modules:
+    add-test-to-search-path: 'True'
+    add-relative-to-search-path: ['../..']
+    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'
+
+test-object-config:
+    asterisk-instances: 1
+    connect-ami: True
+    reactor-timeout: 15
+
+statsd-config:
+    -
+        'ReceiveNothing'
+
+originator-config:
+    channel: 'Local/start at default'
+    context: default
+    exten: start
+    priority: 1
+    trigger: 'ami_connect'
+    async: True
+
+properties:
+    minversion: '13.7.0'
+    dependencies:
+        - python: 'autobahn.websocket'
+        - python: 'starpy'
+        - python: 'twisted'
+    tags:
+        - statsd
+        - apps
diff --git a/tests/apps/statsd/off-nominal/invalid_sample_rate/configs/ast1/extensions.conf b/tests/apps/statsd/off-nominal/invalid_sample_rate/configs/ast1/extensions.conf
new file mode 100644
index 0000000..ebbc213
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_sample_rate/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+
+exten => start,1,NoOp()
+	same => n,StatsD(g,foo,2,a)
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/invalid_sample_rate/configs/ast1/statsd.conf b/tests/apps/statsd/off-nominal/invalid_sample_rate/configs/ast1/statsd.conf
new file mode 100644
index 0000000..47f9386
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_sample_rate/configs/ast1/statsd.conf
@@ -0,0 +1,4 @@
+[general]
+enabled = yes			; When set to yes, statsd support is enabled
+server = 127.0.0.1:8080		; server[:port] of statsd server to use.
+						; If not specified, the port is 8125
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/invalid_sample_rate/test-config.yaml b/tests/apps/statsd/off-nominal/invalid_sample_rate/test-config.yaml
new file mode 100644
index 0000000..43d274f
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_sample_rate/test-config.yaml
@@ -0,0 +1,47 @@
+testinfo:
+    summary:  |
+        Test sending an empty variable name to the StatsD Dialplan Application
+    description: |
+        This test verifies that the StatsD Dialplan Application will fail
+        appropriately when a variable name is not given.
+
+test-modules:
+    add-test-to-search-path: 'True'
+    add-relative-to-search-path: ['../..']
+    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'
+
+test-object-config:
+    asterisk-instances: 1
+    connect-ami: True
+    reactor-timeout: 15
+
+statsd-config:
+    -
+        'ReceiveNothing'
+
+originator-config:
+    channel: 'Local/start at default'
+    context: default
+    exten: start
+    priority: 1
+    trigger: 'ami_connect'
+    async: True
+
+properties:
+    minversion: '13.7.0'
+    dependencies:
+        - python: 'autobahn.websocket'
+        - python: 'starpy'
+        - python: 'twisted'
+    tags:
+        - statsd
+        - apps
diff --git a/tests/apps/statsd/off-nominal/invalid_value/configs/ast1/extensions.conf b/tests/apps/statsd/off-nominal/invalid_value/configs/ast1/extensions.conf
new file mode 100644
index 0000000..e54847d
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_value/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+
+exten => start,1,NoOp()
+	same => n,StatsD(g,foo,*)
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/invalid_value/configs/ast1/statsd.conf b/tests/apps/statsd/off-nominal/invalid_value/configs/ast1/statsd.conf
new file mode 100644
index 0000000..47f9386
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_value/configs/ast1/statsd.conf
@@ -0,0 +1,4 @@
+[general]
+enabled = yes			; When set to yes, statsd support is enabled
+server = 127.0.0.1:8080		; server[:port] of statsd server to use.
+						; If not specified, the port is 8125
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/invalid_value/test-config.yaml b/tests/apps/statsd/off-nominal/invalid_value/test-config.yaml
new file mode 100644
index 0000000..cc7109e
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_value/test-config.yaml
@@ -0,0 +1,47 @@
+testinfo:
+    summary:  |
+        Test sending an invalid value to the StatsD Dialplan Application
+    description: |
+        This test verifies that the StatsD Dialplan Application will fail
+        appropriately when an invalid value is given.
+
+test-modules:
+    add-test-to-search-path: 'True'
+    add-relative-to-search-path: ['../..']
+    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'
+
+test-object-config:
+    asterisk-instances: 1
+    connect-ami: True
+    reactor-timeout: 15
+
+statsd-config:
+    -
+        'ReceiveNothing'
+
+originator-config:
+    channel: 'Local/start at default'
+    context: default
+    exten: start
+    priority: 1
+    trigger: 'ami_connect'
+    async: True
+
+properties:
+    minversion: '13.7.0'
+    dependencies:
+        - python: 'autobahn.websocket'
+        - python: 'starpy'
+        - python: 'twisted'
+    tags:
+        - statsd
+        - apps
diff --git a/tests/apps/statsd/off-nominal/invalid_variable/configs/ast1/extensions.conf b/tests/apps/statsd/off-nominal/invalid_variable/configs/ast1/extensions.conf
new file mode 100644
index 0000000..22572a3
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_variable/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+
+exten => start,1,NoOp()
+	same => n,StatsD(g,foo|,2)
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/invalid_variable/configs/ast1/statsd.conf b/tests/apps/statsd/off-nominal/invalid_variable/configs/ast1/statsd.conf
new file mode 100644
index 0000000..47f9386
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_variable/configs/ast1/statsd.conf
@@ -0,0 +1,4 @@
+[general]
+enabled = yes			; When set to yes, statsd support is enabled
+server = 127.0.0.1:8080		; server[:port] of statsd server to use.
+						; If not specified, the port is 8125
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/invalid_variable/test-config.yaml b/tests/apps/statsd/off-nominal/invalid_variable/test-config.yaml
new file mode 100644
index 0000000..d9da725
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/invalid_variable/test-config.yaml
@@ -0,0 +1,47 @@
+testinfo:
+    summary:  |
+        Test sending an invalid variable name to the StatsD Dialplan Application
+    description: |
+        This test verifies that the StatsD Dialplan Application will fail
+        appropriately when an invalid variable name is given.
+
+test-modules:
+    add-test-to-search-path: 'True'
+    add-relative-to-search-path: ['../..']
+    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'
+
+test-object-config:
+    asterisk-instances: 1
+    connect-ami: True
+    reactor-timeout: 15
+
+statsd-config:
+    -
+        'ReceiveNothing'
+
+originator-config:
+    channel: 'Local/start at default'
+    context: default
+    exten: start
+    priority: 1
+    trigger: 'ami_connect'
+    async: True
+
+properties:
+    minversion: '13.7.0'
+    dependencies:
+        - python: 'autobahn.websocket'
+        - python: 'starpy'
+        - python: 'twisted'
+    tags:
+        - statsd
+        - apps
diff --git a/tests/apps/statsd/off-nominal/no_metric/configs/ast1/extensions.conf b/tests/apps/statsd/off-nominal/no_metric/configs/ast1/extensions.conf
new file mode 100644
index 0000000..7439eb5
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/no_metric/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+
+exten => start,1,NoOp()
+	same => n,StatsD(,foo,2)
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/no_metric/configs/ast1/statsd.conf b/tests/apps/statsd/off-nominal/no_metric/configs/ast1/statsd.conf
new file mode 100644
index 0000000..47f9386
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/no_metric/configs/ast1/statsd.conf
@@ -0,0 +1,4 @@
+[general]
+enabled = yes			; When set to yes, statsd support is enabled
+server = 127.0.0.1:8080		; server[:port] of statsd server to use.
+						; If not specified, the port is 8125
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/no_metric/test-config.yaml b/tests/apps/statsd/off-nominal/no_metric/test-config.yaml
new file mode 100644
index 0000000..e9dc0c4
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/no_metric/test-config.yaml
@@ -0,0 +1,47 @@
+testinfo:
+    summary:  |
+        Test sending an empty metric type to the StatsD Dialplan Application
+    description: |
+        This test verifies that the StatsD Dialplan Application will fail
+        appropriately when a metric type is not given.
+
+test-modules:
+    add-test-to-search-path: 'True'
+    add-relative-to-search-path: ['../..']
+    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'
+
+test-object-config:
+    asterisk-instances: 1
+    connect-ami: True
+    reactor-timeout: 15
+
+statsd-config:
+    -
+        'ReceiveNothing'
+
+originator-config:
+    channel: 'Local/start at default'
+    context: default
+    exten: start
+    priority: 1
+    trigger: 'ami_connect'
+    async: True
+
+properties:
+    minversion: '13.7.0'
+    dependencies:
+        - python: 'autobahn.websocket'
+        - python: 'starpy'
+        - python: 'twisted'
+    tags:
+        - statsd
+        - apps
diff --git a/tests/apps/statsd/off-nominal/no_value/configs/ast1/extensions.conf b/tests/apps/statsd/off-nominal/no_value/configs/ast1/extensions.conf
new file mode 100644
index 0000000..a0c7b69
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/no_value/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+
+exten => start,1,NoOp()
+	same => n,StatsD(g,foo,)
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/no_value/configs/ast1/statsd.conf b/tests/apps/statsd/off-nominal/no_value/configs/ast1/statsd.conf
new file mode 100644
index 0000000..47f9386
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/no_value/configs/ast1/statsd.conf
@@ -0,0 +1,4 @@
+[general]
+enabled = yes			; When set to yes, statsd support is enabled
+server = 127.0.0.1:8080		; server[:port] of statsd server to use.
+						; If not specified, the port is 8125
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/no_value/test-config.yaml b/tests/apps/statsd/off-nominal/no_value/test-config.yaml
new file mode 100644
index 0000000..2960358
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/no_value/test-config.yaml
@@ -0,0 +1,47 @@
+testinfo:
+    summary:  |
+        Test sending an empty value to the StatsD Dialplan Application
+    description: |
+        This test verifies that the StatsD Dialplan Application will fail
+        appropriately when a value is not given.
+
+test-modules:
+    add-test-to-search-path: 'True'
+    add-relative-to-search-path: ['../..']
+    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'
+
+test-object-config:
+    asterisk-instances: 1
+    connect-ami: True
+    reactor-timeout: 15
+
+statsd-config:
+    -
+        'ReceiveNothing'
+
+originator-config:
+    channel: 'Local/start at default'
+    context: default
+    exten: start
+    priority: 1
+    trigger: 'ami_connect'
+    async: True
+
+properties:
+    minversion: '13.7.0'
+    dependencies:
+        - python: 'autobahn.websocket'
+        - python: 'starpy'
+        - python: 'twisted'
+    tags:
+        - statsd
+        - apps
diff --git a/tests/apps/statsd/off-nominal/no_variable/configs/ast1/extensions.conf b/tests/apps/statsd/off-nominal/no_variable/configs/ast1/extensions.conf
new file mode 100644
index 0000000..e7eadb0
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/no_variable/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+
+exten => start,1,NoOp()
+	same => n,StatsD(g,,2)
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/no_variable/configs/ast1/statsd.conf b/tests/apps/statsd/off-nominal/no_variable/configs/ast1/statsd.conf
new file mode 100644
index 0000000..47f9386
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/no_variable/configs/ast1/statsd.conf
@@ -0,0 +1,4 @@
+[general]
+enabled = yes			; When set to yes, statsd support is enabled
+server = 127.0.0.1:8080		; server[:port] of statsd server to use.
+						; If not specified, the port is 8125
\ No newline at end of file
diff --git a/tests/apps/statsd/off-nominal/no_variable/test-config.yaml b/tests/apps/statsd/off-nominal/no_variable/test-config.yaml
new file mode 100644
index 0000000..43d274f
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/no_variable/test-config.yaml
@@ -0,0 +1,47 @@
+testinfo:
+    summary:  |
+        Test sending an empty variable name to the StatsD Dialplan Application
+    description: |
+        This test verifies that the StatsD Dialplan Application will fail
+        appropriately when a variable name is not given.
+
+test-modules:
+    add-test-to-search-path: 'True'
+    add-relative-to-search-path: ['../..']
+    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'
+
+test-object-config:
+    asterisk-instances: 1
+    connect-ami: True
+    reactor-timeout: 15
+
+statsd-config:
+    -
+        'ReceiveNothing'
+
+originator-config:
+    channel: 'Local/start at default'
+    context: default
+    exten: start
+    priority: 1
+    trigger: 'ami_connect'
+    async: True
+
+properties:
+    minversion: '13.7.0'
+    dependencies:
+        - python: 'autobahn.websocket'
+        - python: 'starpy'
+        - python: 'twisted'
+    tags:
+        - statsd
+        - apps
diff --git a/tests/apps/statsd/off-nominal/tests.yaml b/tests/apps/statsd/off-nominal/tests.yaml
new file mode 100644
index 0000000..42b9fbe
--- /dev/null
+++ b/tests/apps/statsd/off-nominal/tests.yaml
@@ -0,0 +1,9 @@
+tests:
+    - test: 'empty_params'
+    - test: 'invalid_metric'
+    - test: 'invalid_sample_rate'
+    - test: 'invalid_value'
+    - test: 'invalid_variable'
+    - test: 'no_metric'
+    - test: 'no_value'
+    - test: 'no_variable'
diff --git a/tests/apps/statsd/tests.yaml b/tests/apps/statsd/tests.yaml
index d39f00d..abdef6c 100644
--- a/tests/apps/statsd/tests.yaml
+++ b/tests/apps/statsd/tests.yaml
@@ -1,3 +1,4 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
     - test: 'nominal'
+    - dir: 'off-nominal'

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id93dbeea53cf978461151e9002af2afe1029ce8b
Gerrit-PatchSet: 9
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Tyler Cambron <tcambron at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Ashley Sanders <asanders at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Tyler Cambron <tcambron at digium.com>



More information about the asterisk-commits mailing list