summaryrefslogtreecommitdiffstats
path: root/test/util.py
AgeCommit message (Collapse)AuthorFilesLines
2023-08-16tests docs: update python3 venv packagesDave Wallace1-1/+0
- Package update performed by 1. updating pip, pip-tools, setuptools 2. 'make test-refresh-deps' on ubuntu 22.04 3. fixing 'make test' and 'make docs' issues on ubuntu 22.04 4. 'make test-refresh-deps' on ubuntu 20.04 - Add dependency for 'make test-refresh-deps' to insure python venv is set up. - Update of python formatter, black, caused reformating of 41 python code files. Type: make Change-Id: I7cafdf4b5189065ac57cb6b254937f6e0897a924 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
2022-05-10tests: replace pycodestyle with blackKlement Sekera1-78/+110
Drop pycodestyle for code style checking in favor of black. Black is much faster, stable PEP8 compliant code style checker offering also automatic formatting. It aims to be very stable and produce smallest diffs. It's used by many small and big projects. Running checkstyle with black takes a few seconds with a terse output. Thus, test-checkstyle-diff is no longer necessary. Expand scope of checkstyle to all python files in the repo, replacing test-checkstyle with checkstyle-python. Also, fixstyle-python is now available for automatic style formatting. Note: python virtualenv has been consolidated in test/Makefile, test/requirements*.txt which will eventually be moved to a central location. This is required to simply the automated generation of docker executor images in the CI. Type: improvement Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8 Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
2022-02-24tests: better reporting for unexpected packetsKlement Sekera1-10/+20
Raise a new UnexpectedPacketErrror, when a packet is captured unexpectedly. This pretty-prints a terse description of said packet. Type: improvement Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Change-Id: Ibac19fc5bbd82a150fec3c90940a37af6344fd4f
2022-02-21tests: add enhanced packet counter verificationKlement Sekera1-2/+48
Add support for inline packet counter verification to send_and_* functions. Diff dictionary is a dictionary of dictionaries of interesting stats: diff_dictionary = { "err" : { '/error/counter1' : 4, }, sw_if_index1 : { '/stat/segment/counter1' : 5, '/stat/segment/counter2' : 6, }, sw_if_index2 : { '/stat/segment/counter1' : 7, }, } It describes a per sw-if-index diffset, where each key is stat segment path and value is the expected change for that counter for sw-if-index. Special case string "err" is used for error counters. This then allows more precise packet counter verification by first defining a "zero" dictionary, e.g. for ED NAT: cls.no_diff = StatsDiff({ pg.sw_if_index: { '/nat44-ed/in2out/fastpath/tcp': 0, '/nat44-ed/in2out/fastpath/udp': 0, '/nat44-ed/in2out/fastpath/icmp': 0, '/nat44-ed/in2out/fastpath/drops': 0, '/nat44-ed/in2out/slowpath/tcp': 0, '/nat44-ed/in2out/slowpath/udp': 0, '/nat44-ed/in2out/slowpath/icmp': 0, '/nat44-ed/in2out/slowpath/drops': 0, '/nat44-ed/in2out/fastpath/tcp': 0, '/nat44-ed/in2out/fastpath/udp': 0, '/nat44-ed/in2out/fastpath/icmp': 0, '/nat44-ed/in2out/fastpath/drops': 0, '/nat44-ed/in2out/slowpath/tcp': 0, '/nat44-ed/in2out/slowpath/udp': 0, '/nat44-ed/in2out/slowpath/icmp': 0, '/nat44-ed/in2out/slowpath/drops': 0, } for pg in cls.pg_interfaces }) and then to specify only changed counters directly when calling one of send_and_* functions: self.send_and_assert_no_replies( self.pg0, pkts, msg="i2o pkts", stats_diff=self.no_diff | { "err": { '/err/nat44-ed-in2out-slowpath/out of ports': len(pkts), }, self.pg0.sw_if_index: { '/nat44-ed/in2out/slowpath/drops': len(pkts), }, } ) operator | is overloaded by StatsDiff class to perform a deep merge operation, so in above case, dictionaries for "err" and self.pg0.sw_if_index do not overwrite whole sub-dictionaries, rather the contents are merged, assuring that all the remaining counters are verified to be zero. Type: improvement Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Change-Id: I2b87f7bd58a7d4b34ee72344e2f871b2f372e2d9
2020-12-07tests: py2 cleanup - remove subclassing of objectPaul Vinciguerra1-2/+2
Type: refactor Change-Id: I9096e3b473110350e1e8e5936e3c4c164f8969a7 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-06tests: refactor ForeignAddressFactoryPaul Vinciguerra1-13/+0
Move ForeignAddressFactory back to test_lisp. It is the only test that uses the code and has embedded addresses specific to the test. Type: test Change-Id: If1a39f9b167e36dd7aff7481350ddb8fe17155d2 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-03tests: remove py2/py3 six compatability libraryPaul Vinciguerra1-1/+0
Type: test Change-Id: Idb6b8169845e0239e639429ccfd02a683212b7e6 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-05-05tests: clean up loggingPaul Vinciguerra1-18/+8
Tests currently expect the logger to be poked from run_tests.py. The tests should run without any magic values. This change sets a default null logger and removes the hasattr checks for the logger. For reference, see: https://docs.python-guide.org/writing/logging/ Type: test Change-Id: I98f953d73d12d00e74b59c94a0fb8c7a625b9c44 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-05-03tests: vpp_interface remove deprecated packed propertiesPaul Vinciguerra1-4/+16
The api no longer requires packed ip addresses. Type: test Change-Id: If67365d86b7c3189f871a58234e99f9c8f875371 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-10-17tests: python3 fixes for reassembly testssnaramre1-4/+4
Type: fix Change-Id: I0d9b823bd558c48b18af9b0d1e80c30729e64dac Signed-off-by: snaramre <snaramre@cisco.com>
2019-10-16tests: cli wrapper should return stringOle Troan1-1/+1
Python3 fixes. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I648b2142d45dfab9146a02eeb1b12de11103ff9f Signed-off-by: Ole Troan <ot@cisco.com>
2019-07-31ip: Ensure reassembly runs before IPSec decrypt.Neale Ranns1-2/+7
Type: fix Change-Id: I01eeedf8d5015b07b9422c65afe78bfe8177c22c Signed-off-by: Neale Ranns <nranns@cisco.com>
2019-03-11VPP-1508: Use scapy.compat to manage packet level library differences.Paul Vinciguerra1-6/+7
Change-Id: Icdf6abc9e53d33b26fd1d531c7dda6be0bb9cb55 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-03-01Tests: Refactor duplicated code.Paul Vinciguerra1-3/+5
Naveen suggested earlier today that we should refactor duplicate code. This commit kicks off the effort. Change-Id: I855b0f40d41d1f3a2e673f3b254b76b596409656 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-02-26VPP-1508 Python3 abstract classesPaul Vinciguerra1-3/+2
Update the syntax to support abstract classes in python 2 and python 3. Depends on: new style classes -- https://gerrit.fd.io/r/16166 Change-Id: Iad2c1240149f38b3faca1b37ab95d3d210e1daee Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-01-21Simplify test/util.py:ppp.Paul Vinciguerra1-9/+3
Change-Id: I10596335c7e8f51afc4bcee75132b7a25ebf2a4e Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2018-12-18PAPI: Add MACAddress object wrapper for vl_api_mac_address_tOle Troan1-2/+2
Change the definition of vl_api_mac_address_t to an aliased type. Change-Id: I1434f316d0fad6a099592f39bceeb8faeaf1d134 Signed-off-by: Ole Troan <ot@cisco.com>
2018-12-10Test framework: StringIO fixes for Python3Ole Troan1-7/+29
Add 2/3 support to binarytomac and mactobinary and move to vpp_mac.py Change-Id: I3dc7e4a24486aee22140c781aae7e44e58935877 Signed-off-by: Ole Troan <ot@cisco.com>
2018-10-10Setup, teardown, DEBUG=core, FAILFAST fixesjuraj.linkes1-12/+26
- Fixed a bug when an error occuring in tearDownClass would not result in test being marked as failed - Improved test results reporting in cases when an error occurs in setUpClass and tearDownClass - Fixed DEBUG=core when the core is produced in setUpClass or tearDownClass - Reworked DEBUG=core to always be handled after all tests have been executed - Fixed FAILFAST=1 for parallel test runs Change-Id: I3e9cd3b97ba6fa802fa0aa2dd7678ff82eee09ec Signed-off-by: juraj.linkes <juraj.linkes@pantheon.tech>
2018-10-03ipsec: add missing ipv6 ah code & ipv6 testsKlement Sekera1-0/+3
Change-Id: I89e90193ded1beb6cb0950c15737f9467efac1c3 Signed-off-by: Klement Sekera <ksekera@cisco.com>
2018-03-31make test: print a warning in case a core_pattern contains a filter programAndrew Yourtchenko1-0/+15
The default config on Ubuntu 16.04.4 desktop results in truncated cores when running make test which coredumps. Uninstalling the filter program (apport) makes the corefiles normal size. Print a warning about that fact, so the others potentially affected didn't have to wonder. Change-Id: Iba4b0a2765a25100d6e24fd7f4de0e0339efd835 Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
2018-03-19Scapy upgrade to 2.4.0.rc5Neale Ranns1-1/+1
- many of the patches fd.io applies in test/patches/2.3.3 are now upstreamed in 2.4 - 2.4 adds support for IGMPv3 which is my main motivation for the upgrade Change-Id: If2c0a524e3cba320b4a5d8cd07817c6ea2bf0c5a Signed-off-by: Neale Ranns <nranns@cisco.com>
2018-03-16IPv6 ND Router discovery data plane (VPP-1095)Juraj Sloboda1-0/+5
Add API call to send Router Solicitation messages. Save info from incoming Router Advertisement messages and notify listeners. Change-Id: Ie518b5492231e03291bd4c4280be4727bfecab46 Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
2018-02-01IPv4/6 reassemblyKlement Sekera1-10/+185
Change-Id: Ic5dcadd13c88b8a5e7896dab82404509c081614a Signed-off-by: Klement Sekera <ksekera@cisco.com>
2017-09-07test: factor out "L4_Conn" into a class within util.py (VPP-931)Andrew Yourtchenko1-0/+66
It seems a useful abstraction for the purposes of writing fine-grained tests, to be able to create a "connection" object which would be bound to two VPP interfaces, and hold some information about the state, allowing to send the packets back and forth with minimal amount of arguments. Change-Id: Idb83b6b82b38bded5b7e1756a41bb2df4cd58e3a Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
2017-07-04TEST:add L2BD arp term testsEyal Bari1-0/+26
Change-Id: I42414da9663ecfc8dfe5baf3e6615cf3b9b02e22 Signed-off-by: Eyal Bari <ebari@cisco.com>
2017-04-19Learn IP6 link-local ND entries from NSs sourced from link-local addressNeale Ranns1-1/+20
Change-Id: I4c3ce4d58df7977490fc94991291422ea1e31ee3 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-02-27[Proxy] ARP testsNeale Ranns1-0/+5
Change-Id: I40d6d763b55a26cdee0afef85d1acdd19dd10dd6 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-02-21Add basic 4o4 LISP unit testFilip Tehlar1-0/+13
Change-Id: I2d812153d7afe7980346382b525af89b3c47e796 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2017-02-14make test: improve stabilityKlement Sekera1-0/+2
Disable automatic garbage collection and run it manually before running each test case to minimize stalls. Improve vpp subprocess cleanup. Reduce helper thread count to one and properly clean that thread once it's not needed. Change-Id: I3ea78ed9628552b5ef3ff29cc7bcf2d3fc42f2c3 Signed-off-by: Klement Sekera <ksekera@cisco.com>
2017-01-17BFD: IPv6 supportKlement Sekera1-3/+8
Change-Id: Iaa9538c7cca500c04cf2704e5bf87480543cfcdf Signed-off-by: Klement Sekera <ksekera@cisco.com>
2017-01-17make test: add checkstyle targetKlement Sekera1-1/+2
Change-Id: I59d3c3bc77474c96e1d6fa51811c1b13fb9a6c5b Signed-off-by: Klement Sekera <ksekera@cisco.com>
2017-01-11vxlan unit test - minor fixesEyal Bari1-0/+10
moved ip4_range and ip4n_range to util added n_ucast_tunnels Change-Id: I9140c4e54a0636d90a97db03da842f5183319af5 Signed-off-by: Eyal Bari <ebari@cisco.com>
2016-12-23make test: improve handling of packet capturesKlement Sekera1-10/+7
Perform accounting of expected packets based on created packet infos. Use this accounting info to automatically expect (and verify) the correct number of packets to be captured. Automatically retry the read of the capture file if scapy raises an exception while doing so to handle rare cases when capture file is read while only partially written during busy wait. Don't fail assert_nothing_captured if only junk packets arrived. Change-Id: I16ec2e9410ef510d313ec16b7e13c57d0b2a63f5 Signed-off-by: Klement Sekera <ksekera@cisco.com>
2016-12-16make test: improve robustness and performanceKlement Sekera1-0/+22
Introduce an API which asserts empty capture for interface. Throw exception in old API if the capture does not exist, thus making it clear if the test expects packets to arrive or not. Improve performance by not doing sleeps after starting the packet generator, rather lazily deleting captures when needed. Fix wrong usage of packet.show() in various tests. Change-Id: I456cb23316eef99b3f35f80344fe595c4db9a21c Signed-off-by: Klement Sekera <ksekera@cisco.com>
2016-12-07BFD: basic asynchronous session up/downKlement Sekera1-0/+22
This is a work-in-progress basic BFD session handling. Only asynchronous mode is supported at the moment. Setting the session flags doesn't work. Change-Id: Idba27f721b5c35be5a66a6d202a63d23ff7ecf6f Signed-off-by: Klement Sekera <ksekera@cisco.com>
2016-12-05make test: fix missing log/packet messagesKlement Sekera1-0/+14
Change-Id: Idb3119792943664748c4abc3829ad723f4156dfe Signed-off-by: Klement Sekera <ksekera@cisco.com>
2016-11-11Add IRB testMatej Klotton1-4/+8
- JIRA: CSIT-255 - create loopback interfaces - move pg-interface specific arp and neighbor discovery from vpp_interface to vpp_pg_interface - base configuration of IRB tests - IP test scenario Change-Id: I9945a188163652a4e22325877aef008c4d029557 Signed-off-by: Matej Klotton <mklotton@cisco.com>
2016-10-26refactor test frameworkKlement Sekera1-133/+19
Change-Id: I31da3b1857b6399f9899276a2d99cdd19436296c Signed-off-by: Klement Sekera <ksekera@cisco.com> Signed-off-by: Matej Klotton <mklotton@cisco.com> Signed-off-by: Jan Gelety <jgelety@cisco.com> Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
2016-10-03test: new test infrastructureDamjan Marion1-0/+139
Change-Id: I73ca19c431743f6b39669c583d9222a6559346ef Signed-off-by: Jan Gelety <jgelety@cisco.com> Signed-off-by: Juraj Sloboda <jsloboda@cisco.com> Signed-off-by: Stefan Kobza <skobza@cisco.com> Signed-off-by: Matej Klotton <mklotton@cisco.com> Signed-off-by: Maciek Konstantynowicz <mkonstan@cisco.com> Signed-off-by: Damjan Marion <damarion@cisco.com>