-
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
sensors tests improvements #237
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
kkourt
force-pushed
the
pr/kkourt/sensors-tests-improvements
branch
2 times, most recently
from
July 15, 2022 14:41
6caf260
to
cb96700
Compare
willfindlay
approved these changes
Jul 15, 2022
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.
Looks great, thank you!
kkourt
added
the
needs-rebase
This PR needs to be rebased because it has merge conflicts.
label
Jul 21, 2022
Turns out that captureLog operated on the default (global) logrus logger and never actually redirected output to t.Logf. Fix this, here, and also add the logger to the output so that we can redirect the output back (even though it's not obvious to me why we need to do so). There is still some output from the observer (which has its own logrus instance). See subsequent commits. Signed-off-by: Kornilios Kourtis <[email protected]>
Now we can use it outside of jsonChecker. Signed-off-by: Kornilios Kourtis <[email protected]>
There was duplicated code among the sensor tests. This PR creates a pkg/testutils/sensors package and places the code there. This package includes: - a TestSensorsRun function. This must be called by all sensor tests in their TestMain. - part of the above function is to setup some configuration (e.g., via flags. We add a helper function so that this confiugration can be accessed by the tests. There are additional things that can be pushed in the above package to simplify the tests, but this is beyond the scope of this patch. Signed-off-by: Kornilios Kourtis <[email protected]>
This is an quick optimization for tests that expect failure. It improves the performance of a successful test by 33%: before: ok github.com/cilium/tetragon/pkg/sensors/tracing 331.502s now: ok github.com/cilium/tetragon/pkg/sensors/tracing 221.583s Signed-off-by: Kornilios Kourtis <[email protected]>
Before this patch, we redirected the log when testing sensors only in the json checker. This, however, meant that a lot of log messages from the observer will still be part of the output. Fix this by redirecting the log output in the initialization of the testing observer. While we are at it, add flag to competely disable tetragon log output. Example: $ sudo sh -c 'CGO_LDFLAGS=-L$(realpath ./lib) LD_LIBRARY_PATH=$(realpath ./lib) go test -failfast ./pkg/sensors/test -test.v -test.run . -disable-tetragon-logs' === RUN TestTestChecker jsonchecker.go:132: jsonTestCheck: opening: /tmp/tetragon.gotest.TestTestChecker.812556859.json jsonchecker.go:126: test failed, marking export file to be kept checker_test.go:57: got error: dummy error filenames.go:60: deleting export file for TestTestChecker (/tmp/tetragon.gotest.TestTestChecker.812556859.json) --- PASS: TestTestChecker (1.28s) === RUN TestSensorLseekLoad jsonchecker.go:132: jsonTestCheck: opening: /tmp/tetragon.gotest.TestSensorLseekLoad.3782420253.json filenames.go:60: deleting export file for TestSensorLseekLoad (/tmp/tetragon.gotest.TestSensorLseekLoad.3782420253.json) --- PASS: TestSensorLseekLoad (1.11s) === RUN TestSensorLseekEnable jsonchecker.go:132: jsonTestCheck: opening: /tmp/tetragon.gotest.TestSensorLseekEnable.985908057.json filenames.go:60: deleting export file for TestSensorLseekEnable (/tmp/tetragon.gotest.TestSensorLseekEnable.985908057.json) --- PASS: TestSensorLseekEnable (1.19s) PASS ok github.com/cilium/tetragon/pkg/sensors/test 3.629s Signed-off-by: Kornilios Kourtis <[email protected]>
kkourt
force-pushed
the
pr/kkourt/sensors-tests-improvements
branch
from
July 21, 2022 10:55
cb96700
to
a82015f
Compare
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.
Improve the sensor tests, mostly with respect to logging.
See commits.