summaryrefslogtreecommitdiffstats
path: root/tests/test_snmptrapd.py
diff options
context:
space:
mode:
authorLadue, David (dl3158) <dl3158@att.com>2018-08-22 17:01:59 -0400
committerLadue, David (dl3158) <dl3158@att.com>2018-08-22 17:02:15 -0400
commit701ab640f1d99f955ba0b14ae5bde49a3b7887f4 (patch)
treec6e3c8363b884a3043c70405b345dff73aebdd48 /tests/test_snmptrapd.py
parent5f37a3be8fad7a2e795f508f7c216d679cebd28e (diff)
added test coverage
Change-Id: Ie8310bab09ce329e499263f07b3ab2d3a8969727 Issue-ID: DCAEGEN2-630 Signed-off-by: Ladue, David (dl3158) <dl3158@att.com>
Diffstat (limited to 'tests/test_snmptrapd.py')
-rw-r--r--tests/test_snmptrapd.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_snmptrapd.py b/tests/test_snmptrapd.py
index 941c0ae..85681ea 100644
--- a/tests/test_snmptrapd.py
+++ b/tests/test_snmptrapd.py
@@ -10,6 +10,9 @@ import trapd_runtime_pid
import trapd_io
import trapd_get_cbs_config
+from pysnmp.hlapi import *
+from pysnmp import debug
+
class test_snmptrapd(unittest.TestCase):
"""
Test the save_pid mod
@@ -123,5 +126,29 @@ class test_snmptrapd(unittest.TestCase):
# open eelf logs
trapd_io.open_eelf_logs()
+ def test_v1_trap_receipt(self):
+ """
+ Test receiving traps
+ """
+
+ # init vars
+ tds.init()
+
+ # request load of CBS data
+ os.environ.update(CBS_SIM_JSON='/tmp/opt/app/snmptrap/etc/snmptrapd.json')
+ trapd_get_cbs_config.get_cbs_config()
+
+ errorIndication, errorStatus, errorIndex, varbinds = next(sendNotification(SnmpEngine(),
+ CommunityData('not_public'),
+ UdpTransportTarget(('localhost', 6162)),
+ ContextData(),
+ 'trap',
+ [ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.1'), OctetString('test trap - ignore')),
+ ObjectType(ObjectIdentity('.1.3.6.1.4.1.999.2'), OctetString('ONAP pytest trap'))])
+ )
+
+ result = errorIndication
+ self.assertEqual(result, None)
+
if __name__ == '__main__':
unittest.main()