-
Notifications
You must be signed in to change notification settings - Fork 380
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:cgroups: tests for cgroups package #401
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tixxdz
changed the title
tests:cgroups: more tests for cgroups package
tests:cgroups: tests for cgroups package
Sep 13, 2022
tixxdz
force-pushed
the
pr/tixxdz/cgroup-tests-batch1
branch
from
September 13, 2022 09:12
f133f45
to
38149e5
Compare
tixxdz
force-pushed
the
pr/tixxdz/cgroup-tests-batch1
branch
from
September 13, 2022 09:29
d650b57
to
836ff86
Compare
kevsecurity
reviewed
Sep 13, 2022
This asserts that TetragonConf and bpf tetragon_conf are aligned properly. Signed-off-by: Djalal Harouni <[email protected]>
Signed-off-by: Djalal Harouni <[email protected]>
Add unit tests to assert that cgroup mode can be one of the following: CGROUP_UNDEF = 0 Can't determin Cgroup mode CGROUP_LEGACY = 1 Cgroup is in pure lagacy mode (only cgroupv1 is mounted) CGROUP_HYBRID = 2 Cgroup is in hybrid mode, cgroupv1 is default and systemd mounted a cgroupv2 hierarchy at /sys/fs/cgroup/unified to organize units and processes. Container runtimes and kubernetes may use this or not... depends on their configuration. CGROUP_UNIFIED = 3 Cgroupv2 is the default mode, pure unified hierarchy. We follow systemd cgroup setup: https://systemd.io/CGROUP_DELEGATION/, however our cgroup package should work on non-systemd setups assuming they setup cgroups on the default location /sys/fs/cgroup We add two tests: - TestDetectCgroupModeInvalid() that runs the test on an invalid directory to assert that returned value contains errors and the mode is CGROUP_UNDEF - TestDetectCgroupModeDefault() that tests the default cgroup root location /sys/fs/cgroup and tries to guess what is the mode according to it. Signed-off-by: Djalal Harouni <[email protected]>
This tests the detect cgroup mode logic on our custom location where we mount Cgroup2: /run/tetragon/cgroup2 Signed-off-by: Djalal Harouni <[email protected]>
This runs DetectCgroupMode() helpers and asserts that global cgroup vars are set: cgroupMode and cgroupFSPath. These vars are set only once, the first time when we run the detection, second call we just return them, so assert they are properly set during first call. Signed-off-by: Djalal Harouni <[email protected]>
Add test to assert: - Cgroup FS magic detection. This will run DetectCgroupFSMagic() that returns the fs magic number. - Assert that cgroupMode is also properly set, since DetectCgroupFSMagic() will automatically run DetectCgroupMode(). We have to do this to properly detect all the cgroup setups variants. Statfs() the filesystem only will not work. Signed-off-by: Djalal Harouni <[email protected]>
tixxdz
force-pushed
the
pr/tixxdz/cgroup-tests-batch1
branch
from
September 13, 2022 11:36
836ff86
to
68df622
Compare
kevsecurity
approved these changes
Sep 13, 2022
This test will perform: - Assert discovery of compiled-in Cgroups controllers. - Assert that we properly setup their hierarchy ID - Assert that we properly setup their cgroup subsystem state index. Signed-off-by: Djalal Harouni <[email protected]>
tixxdz
force-pushed
the
pr/tixxdz/cgroup-tests-batch1
branch
from
September 13, 2022 13:47
68df622
to
5e24ce8
Compare
kkourt
approved these changes
Sep 15, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.