Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Create sniffer as a separate module #1068

Merged
merged 9 commits into from
Apr 6, 2020
Merged

Create sniffer as a separate module #1068

merged 9 commits into from
Apr 6, 2020

Conversation

arnout
Copy link
Collaborator

@arnout arnout commented Apr 1, 2020

This is yet another spinoff of #1031.
It is here to allow @Galvien to rebase #1020 on top of it and put the new tshark features in the sniffer class.

Also, at @Galvien's request, make test_flows.py PEP8-compliant now.

@arnout arnout self-assigned this Apr 1, 2020
@arnout arnout force-pushed the feature/tests_sniffer branch from 4e81fb6 to 8df84f7 Compare April 2, 2020 10:25
@arnout arnout force-pushed the feature/tests_sniffer branch 2 times, most recently from 81fc982 to b5e7127 Compare April 2, 2020 10:33
@arnout arnout requested a review from a user April 2, 2020 13:09
Comment on lines 10 to 15
'''Static class that encodes the global options.'''
verbose = False
tcpdump = False
tcpdump_dir = ''
stop_on_failure = False

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this common practice? while it's convenient to keep these options on a static class I would assume they would be stored in either a tests.config , a json file file or something of that sort.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A static class is a somewhat pythonesque way of organising global variables, yes. It has the advantage that you don't need the global keyword.

@arnout arnout added the ready for merge PR is ready to be merged (automatically) label Apr 6, 2020
arnout added 9 commits April 6, 2020 12:46
The Sniffer class is an abstraction of tcpdump. It's a generic
implementation where the bridge interface is passed in as an argument.

To make things easier, the directory where sniffer results are saved is
added as a member of opts.

Add the new Python module to the PEP8 checks.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
Create a new environment module with method launch_environment_docker.
For now, it just initialises the sniffer and runs the test_gw_repeater
script to start the containers.

wired_sniffer is defined as a global variable in the environment module,
so it can be accessed easily as env.wired_sniffer.

unique_id and skip_init are now passed as arguments to the init
function. Thus, the self.opts member is no longer needed.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
These are just oneliner functions, and called only once, so remove them.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
This fixes most of the flake8 issues in the script.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
Some of the long lines can be avoided (and become more readable) by
adding additional variables. Some lines are still too long so add noqa
E501 to them.

Also comments can be rewrapped.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
Some of the too long lines don't look better after splitting, so add
noqa E501 exceptions for them.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
Some of the too long lines can be overcome by splitting the line before
.format. autopep8 doesn't do this automatically because this way of
splitting is a bit controversial.

While we're at it, avoid the use of **locals() since it's also a bit
controversial.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
Check the MID of the topology query message.

Discovered by flake8 (mid was unused).

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
Now test_flows.py is PEP8 compliant, we can run the check on all files
under tests.

Use git-ls-files to do the pattern matching. Use -z (zero-separate) for
good measure, even though spaces are not allowed in python module names
so it shouldn't be necessary.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>
@arnout arnout force-pushed the feature/tests_sniffer branch from b5e7127 to 5aa9d6e Compare April 6, 2020 10:58
@mergify mergify bot merged commit b500ed2 into master Apr 6, 2020
@mergify mergify bot deleted the feature/tests_sniffer branch April 6, 2020 11:18
@mergify mergify bot removed the ready for merge PR is ready to be merged (automatically) label Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants