Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add a test for missing runmode v2 #1442

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/runmode_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Suricata Missing Runmode Issue

This directory contains test files and documentation for addressing the "Missing runmode" issue 5711 in Suricata.

## Issue Description

The issue relates to Suricata not providing adequate feedback when the runmode is missing, leading to confusion for users.
Copy link
Member

Choose a reason for hiding this comment

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

nit: please add redmine ticket link here




Copy link
Member

Choose a reason for hiding this comment

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

nit: unneeded whitespace

12 changes: 12 additions & 0 deletions tests/runmode_test/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%YAML 1.1
---

runmodes:
- workers:
enabled: yes






Copy link
Member

Choose a reason for hiding this comment

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

nit: unneeded whitespace

16 changes: 16 additions & 0 deletions tests/runmode_test/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
requires:
min-version: 7
pcap: false

exit-code: 1
args:
- --dump-config
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed for the test, it was an example given by Juliana. The args should be just like mentioned in the redmine ticket.


checks:
- shell:
args: suricata -S /dev/null
expect: 1
Comment on lines +9 to +12
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this test. Could you please explain what were you trying to do here?
Note: This test does not seem to be testing what you've done in your Suricata PR, you should be looking for the error message in the Suricata logs/stderr. e.g. tests/detect-bsize-01/test.yaml
Hint: Recommended steps to follow:

  1. Try to understand what shell checks are doing looking at other tests.
  2. Check out the output dir created in your test after you run it. See what's inside each file.
  3. Get back to fixing the test.

Copy link
Author

Choose a reason for hiding this comment

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

I don't understand this test. Could you please explain what were you trying to do here? Note: This test does not seem to be testing what you've done in your Suricata PR, you should be looking for the error message in the Suricata logs/stderr. e.g. tests/detect-bsize-01/test.yaml Hint: Recommended steps to follow:

  1. Try to understand what shell checks are doing looking at other tests.
  2. Check out the output dir created in your test after you run it. See what's inside each file.
  3. Get back to fixing the test.

Okay, I actually included this test to check whether Suricata behaves correctly when a specific run mode is missing. To do that, I ran Suricata with the '-S /dev/null' argument, which simulates the absence of the 'capture' run mode. I expected Suricata to return an error code (1) in this scenario, indicating that the run mode is missing.
But if I understand, I am expected to check for the presence of the expected error message in Suricata logs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for going through your thought process :)

So, as I mentioned on the previous review, you don't have to invoke shell to run suricata in Suricata-verify tests. So, whatever arguments you want to pass for this test to run suricata with, those would passed in that args section where you've putt the --dump-config option, instead.

For the expected exit code, and how to check for an error message from the output - in case you don't want to check log outputs, you can check this test: https://github.com/OISF/suricata-verify/blob/master/tests/detect-strip_whitespace-01/test.yaml#L5C1-L5C1

Not that right above the first args section, there's an exit-code: 1 line. That is how you tell suricata-verify that you expect Suri to exit with error code 1.

I hope this helps you move forward with this contribution! :)

Copy link
Author

Choose a reason for hiding this comment

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

Okay, thanks. It helps





Copy link
Member

Choose a reason for hiding this comment

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

nit: unneeded whitespace

Loading