diff options
-rw-r--r-- | test/test_nat.py | 20 | ||||
-rw-r--r-- | test/test_qos.py | 81 | ||||
-rw-r--r-- | test/test_syslog.py | 12 | ||||
-rw-r--r-- | test/vpp_papi_provider.py | 18 |
4 files changed, 69 insertions, 62 deletions
diff --git a/test/test_nat.py b/test/test_nat.py index cbc48d4e776..848d7225296 100644 --- a/test/test_nat.py +++ b/test/test_nat.py @@ -23,7 +23,6 @@ from util import ip4_range from vpp_papi import mac_pton from syslog_rfc5424_parser import SyslogMessage, ParseError from syslog_rfc5424_parser.constants import SyslogFacility, SyslogSeverity -from vpp_papi_provider import SYSLOG_SEVERITY from io import BytesIO from vpp_papi import VppEnum from scapy.all import bind_layers, Packet, ByteEnumField, ShortField, \ @@ -75,6 +74,10 @@ class MethodHolder(VppTestCase): def config_flags(self): return VppEnum.vl_api_nat_config_flags_t + @property + def SYSLOG_SEVERITY(self): + return VppEnum.vl_api_syslog_severity_t + def clear_nat44(self): """ Clear NAT44 configuration. @@ -121,7 +124,8 @@ class MethodHolder(VppTestCase): self.ipfix_src_port = 4739 self.ipfix_domain_id = 1 - self.vapi.syslog_set_filter(SYSLOG_SEVERITY.EMERG) + self.vapi.syslog_set_filter( + self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_EMERG) self.vapi.nat_ha_set_listener(ip_address='0.0.0.0', port=0, path_mtu=512) @@ -2964,7 +2968,8 @@ class TestNAT44(MethodHolder): def test_syslog_apmap(self): """ Test syslog address and port mapping creation and deletion """ - self.vapi.syslog_set_filter(SYSLOG_SEVERITY.INFO) + self.vapi.syslog_set_filter( + self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_INFO) self.vapi.syslog_set_sender(self.pg3.local_ip4n, self.pg3.remote_ip4n) self.nat44_add_address(self.nat_addr) flags = self.config_flags.NAT_IS_INSIDE @@ -6848,7 +6853,8 @@ class TestNAT44EndpointDependent(MethodHolder): def test_syslog_sess(self): """ Test syslog session creation and deletion """ - self.vapi.syslog_set_filter(SYSLOG_SEVERITY.INFO) + self.vapi.syslog_set_filter( + self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_INFO) self.vapi.syslog_set_sender(self.pg2.local_ip4n, self.pg2.remote_ip4n) self.nat44_add_address(self.nat_addr) flags = self.config_flags.NAT_IS_INSIDE @@ -9034,7 +9040,8 @@ class TestNAT64(MethodHolder): sw_if_index=self.pg0.sw_if_index) self.vapi.nat64_add_del_interface(is_add=1, flags=0, sw_if_index=self.pg1.sw_if_index) - self.vapi.syslog_set_filter(SYSLOG_SEVERITY.INFO) + self.vapi.syslog_set_filter( + self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_INFO) self.vapi.syslog_set_sender(self.pg3.local_ip4n, self.pg3.remote_ip4n) p = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) / @@ -9074,7 +9081,8 @@ class TestNAT64(MethodHolder): self.ipfix_src_port = 4739 self.ipfix_domain_id = 1 - self.vapi.syslog_set_filter(SYSLOG_SEVERITY.EMERG) + self.vapi.syslog_set_filter( + self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_EMERG) self.vapi.nat_set_timeouts(udp=300, tcp_established=7440, tcp_transitory=240, icmp=60) diff --git a/test/test_qos.py b/test/test_qos.py index 8025bdcd40c..d4bd0872243 100644 --- a/test/test_qos.py +++ b/test/test_qos.py @@ -3,7 +3,6 @@ import unittest from framework import VppTestCase, VppTestRunner -from vpp_papi_provider import QOS_SOURCE from vpp_sub_interface import VppDot1QSubint from vpp_ip import DpoProto from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsRoute, \ @@ -15,6 +14,7 @@ from scapy.layers.l2 import Ether, Dot1Q from scapy.layers.inet import IP, UDP from scapy.layers.inet6 import IPv6 from scapy.contrib.mpls import MPLS +from vpp_papi import VppEnum NUM_PKTS = 67 @@ -22,6 +22,13 @@ NUM_PKTS = 67 class TestQOS(VppTestCase): """ QOS Test Case """ + # Note: Since the enums aren't created dynamically until after + # the papi client attaches to VPP, we put it in a property to + # ensure it is the value at runtime, not at module load time. + @property + def QOS_SOURCE(self): + return VppEnum.vl_api_qos_source_t + @classmethod def setUpClass(cls): super(TestQOS, cls).setUpClass() @@ -110,19 +117,19 @@ class TestQOS(VppTestCase): # Bind interface pgN to table n # self.vapi.qos_mark_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 1, 1) self.vapi.qos_mark_enable_disable(self.pg2.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 2, 1) self.vapi.qos_mark_enable_disable(self.pg3.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 3, 1) self.vapi.qos_mark_enable_disable(self.pg4.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 4, 1) @@ -154,7 +161,7 @@ class TestQOS(VppTestCase): # Enable QoS recording on IP input for pg0 # self.vapi.qos_record_enable_disable(self.pg0.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 1) # @@ -212,11 +219,11 @@ class TestQOS(VppTestCase): # remove the map on pg2 and pg3, now expect an unchanged IP tos # self.vapi.qos_mark_enable_disable(self.pg2.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 2, 0) self.vapi.qos_mark_enable_disable(self.pg3.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 3, 0) self.logger.info(self.vapi.cli("sh int feat pg2")) @@ -243,7 +250,7 @@ class TestQOS(VppTestCase): # disable the input recording on pg0 # self.vapi.qos_record_enable_disable(self.pg0.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 0) # @@ -257,11 +264,11 @@ class TestQOS(VppTestCase): # disable the egress map on pg1 and pg4 # self.vapi.qos_mark_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 1, 0) self.vapi.qos_mark_enable_disable(self.pg4.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 4, 0) @@ -331,10 +338,10 @@ class TestQOS(VppTestCase): # on Pg1 # self.vapi.qos_record_enable_disable(self.pg0.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 1) self.vapi.qos_mark_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.MPLS, + self.QOS_SOURCE.QOS_API_SOURCE_MPLS, 1, 1) @@ -378,11 +385,12 @@ class TestQOS(VppTestCase): # enable MPLS QoS recording on the input Pg0 and IP egress marking # on Pg1 # - self.vapi.qos_record_enable_disable(self.pg0.sw_if_index, - QOS_SOURCE.MPLS, - 1) + self.vapi.qos_record_enable_disable( + self.pg0.sw_if_index, + self.QOS_SOURCE.QOS_API_SOURCE_MPLS, + 1) self.vapi.qos_mark_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 1, 1) @@ -436,17 +444,18 @@ class TestQOS(VppTestCase): # cleanup # self.vapi.qos_record_enable_disable(self.pg0.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 0) self.vapi.qos_mark_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.MPLS, + self.QOS_SOURCE.QOS_API_SOURCE_MPLS, 1, 0) - self.vapi.qos_record_enable_disable(self.pg0.sw_if_index, - QOS_SOURCE.MPLS, - 0) + self.vapi.qos_record_enable_disable( + self.pg0.sw_if_index, + self.QOS_SOURCE.QOS_API_SOURCE_MPLS, + 0) self.vapi.qos_mark_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 1, 0) self.vapi.qos_egress_map_delete(1) @@ -479,11 +488,12 @@ class TestQOS(VppTestCase): # # enable VLAN QoS recording/marking on the input Pg0 subinterface and # - self.vapi.qos_record_enable_disable(sub_if.sw_if_index, - QOS_SOURCE.VLAN, - 1) + self.vapi.qos_record_enable_disable( + sub_if.sw_if_index, + self.QOS_SOURCE.QOS_API_SOURCE_VLAN, + 1) self.vapi.qos_mark_enable_disable(sub_if.sw_if_index, - QOS_SOURCE.VLAN, + self.QOS_SOURCE.QOS_API_SOURCE_VLAN, 1, 1) @@ -491,10 +501,10 @@ class TestQOS(VppTestCase): # IP marking/recording on pg1 # self.vapi.qos_record_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 1) self.vapi.qos_mark_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 1, 1) @@ -570,18 +580,19 @@ class TestQOS(VppTestCase): sub_if.unconfig_ip4() sub_if.unconfig_ip6() - self.vapi.qos_record_enable_disable(sub_if.sw_if_index, - QOS_SOURCE.VLAN, - 0) + self.vapi.qos_record_enable_disable( + sub_if.sw_if_index, + self.QOS_SOURCE.QOS_API_SOURCE_VLAN, + 0) self.vapi.qos_mark_enable_disable(sub_if.sw_if_index, - QOS_SOURCE.VLAN, + self.QOS_SOURCE.QOS_API_SOURCE_VLAN, 1, 0) self.vapi.qos_record_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 0) self.vapi.qos_mark_enable_disable(self.pg1.sw_if_index, - QOS_SOURCE.IP, + self.QOS_SOURCE.QOS_API_SOURCE_IP, 1, 0) diff --git a/test/test_syslog.py b/test/test_syslog.py index 90a0aef908f..0acf7c221eb 100644 --- a/test/test_syslog.py +++ b/test/test_syslog.py @@ -5,14 +5,18 @@ from framework import VppTestCase, VppTestRunner from util import ppp from scapy.packet import Raw from scapy.layers.inet import IP, UDP -from vpp_papi_provider import SYSLOG_SEVERITY from syslog_rfc5424_parser import SyslogMessage, ParseError from syslog_rfc5424_parser.constants import SyslogFacility, SyslogSeverity +from vpp_papi import VppEnum class TestSyslog(VppTestCase): """ Syslog Protocol Test Cases """ + @property + def SYSLOG_SEVERITY(self): + return VppEnum.vl_api_syslog_severity_t + @classmethod def setUpClass(cls): super(TestSyslog, cls).setUpClass() @@ -145,9 +149,11 @@ class TestSyslog(VppTestCase): msg) self.pg_enable_capture(self.pg_interfaces) - self.vapi.syslog_set_filter(SYSLOG_SEVERITY.WARN) + self.vapi.syslog_set_filter( + self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_WARN) filter = self.vapi.syslog_get_filter() - self.assertEqual(filter.severity, SYSLOG_SEVERITY.WARN) + self.assertEqual(filter.severity, + self.SYSLOG_SEVERITY.SYSLOG_API_SEVERITY_WARN) self.syslog_generate(SyslogFacility.local7, SyslogSeverity.info, appname, diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py index ad6d6bcf574..8084a7ffd8d 100644 --- a/test/vpp_papi_provider.py +++ b/test/vpp_papi_provider.py @@ -15,24 +15,6 @@ from hook import Hook from vpp_ip_route import MPLS_IETF_MAX_LABEL, MPLS_LABEL_INVALID -class QOS_SOURCE: - EXT = 0 - VLAN = 1 - MPLS = 2 - IP = 3 - - -class SYSLOG_SEVERITY: - EMERG = 0 - ALERT = 1 - CRIT = 2 - ERR = 3 - WARN = 4 - NOTICE = 5 - INFO = 6 - DBG = 7 - - # # Dictionary keyed on message name to override default values for # named parameters |