Commit graph

13 commits

Author SHA1 Message Date
Dominik Pataky a829d428bf Add test for IPFIX padding handling 2023-08-19 14:33:12 +02:00
Dominik Pataky 8b5675913d Small changes to PR #37 preventing infinite loops; bump version
Closes #37
2022-04-25 20:26:04 +02:00
Vitali Sepetnitsky b8e911a40a avoid infinite loop in V9ExportPacket's constructor 2022-02-16 18:39:15 +02:00
Dominik Pataky 5cdb514ffc Ensure compatibility with Python 3.5.3
This commit replaces multiple occurences of new features which were not
yet implemented with Python 3.5.3, which is the reference backwards
compatibility version for this package. The version is based on the
current Python version in Debian Stretch (oldstable). According to
pkgs.org, all other distros use 3.6+, so 3.5.3 is the lower boundary.

Changes:
  * Add maxsize argument to functools.lru_cache decorator
  * Replace f"" with .format()
  * Replace variable type hints "var: type = val" with "# type:" comments
  * Replace pstats.SortKey enum with strings in performance tests

Additionally, various styling fixes were applied.
The version compatibility was tested with tox, pyenv and Python 3.5.3,
but there is no tox.ini yet which automates this test.

Bump patch version number to 0.10.3
Update author's email address.

Resolves #27
2020-04-24 16:52:25 +02:00
Dominik Pataky 5d1c5b8710 IPFIX: add template withdrawal handling; bump version to v0.10.2
Templates may be withdrawn as per RFC7011. Receiving a template with an
existing template_id and a field_count of 0 now triggers deletion of
this template.
2020-04-06 17:27:26 +02:00
Dominik Pataky 742f5a0a48 IPFIX: enhance (data|field) types and parsing; extend tests
Parts of the IPFIXFieldTypes class were extracted into the new
IPFIXDataTypes class, to increase readability and stability.

The IPFIXDataRecord class and its field parser is now more in tune with
the specifications, handling signed and unsigned, as well as float,
boolean and UTF8 strings etc.

Corresponding tests were extended with softflowd packets (level
"ethernet") and value checks (e.g. MAC address).

Resolves #25
2020-04-06 17:02:52 +02:00
Dominik Pataky f7a44852c3 Tests: add memory performance test for v1 and v5; bump version to 0.10.1 2020-04-04 10:58:06 +02:00
Dominik Pataky 959f8d3c2c Tests: add parameter store_packets to send_recv_packets
The function send_recv_packets in tests stored all processed
ExportPackets by default in a list. Memory usage tests were therefore
based on this high amount of stored objects, since no instance of any
ExportPacket was deleted until exit.
With the new parameter store_packets the caller can define how many
packets should be stored during receiving, as to test multiple
scenarios.

Three such scenarios are implemented: don't store any packet, store
maximum of 500 at a time and store all packets. This comes much closer
to the real world scenario of the collector, which uses a "for export in
listener.get" loop, dumping any new ExportPacket to file immediatelly
and then deleting the object.

Yet, the case where all packets are stored must still be covered as
well, because the collector might not be the only implementation which
uses listener.get, so finding memory leaks should be covered.
2020-04-03 17:28:16 +02:00
Dominik Pataky 53f8ca764e Tests: add memory performance tests
A new test file is added which contains memory and CPU tests. For now,
only the memory usage tests work (threading!). They print out tables of
memory usage based on file path and on function. Additionally, they check
some basic measurements: if all packets were processed and if a
collection of version 9/10 called any functions in 10/9.

Refs #24
2020-04-03 15:36:09 +02:00
Dominik Pataky 258b7c1e0b Tests: move packets into lib again, add packet generator
The static packets in the tests are back in lib.py to avoid circular
imports. A new packet generator function was added.
2020-04-03 15:20:41 +02:00
Dominik Pataky 55272e8a0a Fix analyzer test; IPFIX: change handling of 16 bytes fields
Analyzer test was missing imports.

IPFIX templates with 16 bytes fields were processed extra, since struct
does not natively support conversion to int. The new implementation
still handles it extra, but uses struct's "s" unpack format descriptor
now.
2020-04-03 10:29:38 +02:00
Dominik Pataky 547792c5c2 Tests: move packets into each version test file; add tests for IPFIX
The previously introduced tests/lib.py contained the NetFlow v9 packets
and then the IPFIX packets, those were split and put into their
respective test files again. The lib now contains shared objects only.

For IPFIX tests were added. Two new packets were added, one with
templates and one without (again, real exports from softflowd).
Different cases are checked: no template, template and later template.
Fields of flows are also checked, especially IPv6 addresses.

Note: exports made with softflowd were created by softflowd 1.0.0,
compiled from https://github.com/irino/softflowd
2020-04-01 14:15:53 +02:00
Dominik Pataky 56d443aa2a Refactor tests, moved into tests/
The tests are now located in tests/. They are also split into multiple
files, beginning with test_netflow and test_analyzer. The tests for
IPFIX will be added to test_ipfix.
2020-04-01 11:55:45 +02:00