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
Telemetry - determine run context from stack introspection #4907
Conversation
Code Climate has analyzed commit 6051618 and detected 5 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
|
||
def self.audit_cookbook?(stack) | ||
stack_match(stack: stack[-21..-11], path: "chef/handler", label: "run_report_handlers") && | ||
stack_match(stack: stack[-26..-16], path: "handler/audit_report", label: "report") |
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.
These fixed numbers like -26
feel likely to change and break, is that true? What happens if they do? What are the consequences of false positives/negatives?
At the least I think we'd want unit tests that run against a captured stack trace embedded in the tests. That would make it easier to understand what is being picked out by seeing the same. Of course that wouldn't detect any changes to the stack, so we'd probably want an integration tests for each of these, no?
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.
I've removed the fixed frame ranges. I agree they would be brittle.
The consequence of a false positive would be miscategorizing a run in the telemetry data. A false negative would likely result in an "unknown" result.
I've added integration tests that exercise each of the three outcomes.
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
…tKitchen Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
be5448e
to
d5be4c2
Compare
@james-stocks @Schwad Two of the tests on this require test-kitchen. We don't currently run any test-kitchen suites automatically, AFAIK, so I didn't add anything to BuildKite or Rake to enable that; let me know how you'd like that handled. |
@@ -387,11 +393,6 @@ def version | |||
end | |||
map %w{-v --version} => :version | |||
|
|||
desc "nothing", "does nothing" |
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 would be best to delete these lines in a separate commit.
Regarding test-kitchen, I'm not comfortable with the general approach of adding a test command to the CLI and having the integration suite depend on both kitchen and the audit cookbook. I'd prefer that the unit and integration tests stick to static fixtures and mocking; and exercise only the code contained in this project. |
@james-stocks, in order for this code to be integration tested, which @btm stated was required, it must run in its real environment, which means running under test-kitchen and audit cookbook. |
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.
Apologies for the confusion @clintoncwolfe - this looks good to me - as discussed I'll raise an issue for us to get test/integration
running in buildkite
Description
Provides ability to determine how InSpec is being run - whether via the CLI, via the Audit cookbook, or via kitchen-inspec, all via looking at the call stack.
Here is some of the stack data captured :
During an audit run under chef-solo (manipulated to include indices from the outermost frame):
Related Issue
Needed for #4900
Types of changes
Checklist:
Aha! Link: https://chef.aha.io/features/SH-2163