-
Notifications
You must be signed in to change notification settings - Fork 165
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
feat(tests): new e2e tests [1/N] #1661
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bd8ad48
to
2131dda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
LGTM label has been added. Git tree hash: 472ea3c0f282d766bada55f6a7991b1df036dc27
|
/hold i would like to review this before merging it |
test/libsinsp/libsinsp_test_var.h.in
Outdated
// Absolute path to the bpf probe .o file | ||
#define LIBSINSP_TEST_BPF_PROBE_PATH "${CMAKE_BINARY_DIR}/driver/bpf/probe.o" | ||
|
||
#define LIBSINSP_TEST_CAPTURES_PATH "${CMAKE_BINARY_DIR}/test/libsinsp/captures" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems relative to scap-files, but we already have a framework to support them https://github.com/falcosecurity/libs/tree/master/userspace/libsinsp/test/scap_files, maybe it could be enough WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LIBSINSP_TEST_CAPTURES_PATH
has a different motivation: each test dumps the captured events in a scap file so that we can inspect them in a second moment. This is not meant to test scap file correctness. 😅
test/libsinsp/main.cpp
Outdated
std::string captures_dir = LIBSINSP_TEST_CAPTURES_PATH; | ||
|
||
if(!std::filesystem::exists(captures_dir)) | ||
{ | ||
if (!std::filesystem::create_directory(captures_dir)) { | ||
std::cerr << "Failed to create captures directory." << std::endl;; | ||
return EXIT_FAILURE; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see what we decide to do with scap-files
test/libsinsp/main.cpp
Outdated
/* Get current cwd as a base directory for the driver path */ | ||
char driver_path[FILENAME_MAX]; | ||
if(!getcwd(driver_path, FILENAME_MAX)) | ||
{ | ||
std::cerr << "Unable to get current dir" << std::endl; | ||
return EXIT_FAILURE; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems we can remove this
test/libsinsp/CMakeLists.txt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a README.md
in this folder with instructions to run these tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More precisely I would try to follow the same structure we have in the other tests (e.g. the drivers
one):
/libsinsp_e2e
├─ `helpers`
├─ `test_suites`
├─ `event_capture`
├─ `CMakeLists.txt`
├─ `README.md`
├─ ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, totally on board on this! On the other hand I'd like to do this kind on changes later on (I already have some PRs in the working). Are you ok with that?
.github/workflows/e2e_ci.yml
Outdated
- name: Run e2e tests with modern bpf 🏎️ | ||
run: | | ||
cd build/test/libsinsp/ | ||
sudo ./tests -m | ||
|
||
- name: Run e2e tests with bpf 🏎️ | ||
run: | | ||
cd build/test/libsinsp/ | ||
sudo ./tests -b | ||
|
||
- name: Run e2e tests with kmod 🏎️ | ||
run: | | ||
cd build/test/libsinsp/ | ||
sudo ./tests -k |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On QEMU we should be able to inject eBPF drivers so I don't think we need to touch this job
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another suggestion I'd add here is that we may want to run the tests on different drivers by using a matrix without soft fail, so that we don't skip tests on a driver if we find errors in another.
test/libsinsp/sys_call_test.cpp
Outdated
|
||
using namespace std; | ||
|
||
TEST_F(sys_call_test, stat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, all the tests in this file seem to do the exact thing as drivers_test
.
They run a syscall or a combination of syscalls and then assert that the event is here and something is happening in userspace... why don't we extend the class event_test
to support some inspections in sinsp instead of introducing all these executables/classes + callbacks, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although some tests are similar in this first batch, the whole contribution process of the test suite we foresee can potentially cover use cases that diverge with the goals of the driver-level tests. It's hard to predict it at the moment, and refactor everything right now may be outside of the engineering bandwidth we currently have available. Plus, having this suite being its own standalone thing will allow us to converge it with the drivers one once we have a more high-level view than now. If this was a library code contribution, I'd agree with you of this being a strong blocker. But since this is a test-based contribution, I think it can provide tons of value as-is and we can postpone cleaning it up deeply as a secondary priority. Moreover @therealbobo is also curating each test while contributing them.
I left some initial comments but my main point is this one #1661 (comment) |
When attempting to build the test suite I get
Am I missing some dependency? |
This is probably related to the build of the is needed gcc with multilib support: there are some tests that run also for x86. |
Yep, I was missing |
7aa8ee4
to
a242e36
Compare
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
Signed-off-by: Roberto Scolaro <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably just a matter of setting the right directory
Hi @LucaGuerra
You are right, it's just a path issue caused by the new name of the test's directory.
I've tried running these tests with the correct paths and they are working 🎉
fa4f3ae
to
b23361c
Compare
I had tested this before and it seems like cmake had issues generating the binary, I'll clean and retry. Thank you for your efforts in making the e2e tests more compatible! |
Signed-off-by: Roberto Scolaro <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the latest fixes I was able to run the tests as specified in the readme. Thanks!
LGTM label has been added. Git tree hash: 7d47e4c299049d641e824eed88027c0d654f1548
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: leogr, LucaGuerra, therealbobo The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/unhold I believe review comments have been addressed |
What type of PR is this?
/kind feature
Any specific area of the project related to this PR?
/area CI
/area tests
Does this PR require a change in the driver versions?
What this PR does / why we need it:
This is the initial batch of new e2e tests.
Which issue(s) this PR fixes:
Part of #1650
Special notes for your reviewer:
Does this PR introduce a user-facing change?: