-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
improve the quality of starlark docs by executing them as tests #8020
Conversation
@ssoroka i really like the idea of testing these processors! The first thing that comes to mind is if this in line with the way people test starlark code in other platforms? How would you test different scenarios for a processor? You could add a LP record for each scenario, but is there a way to document which line protocol line is testing what? I don't want to complicate things, but what does this look like when i have 10 different things i want to test in the starlark processor? I wonder if the ability to name the tests might become important. Is it better to be explicit in the |
@russorat I like the way you think. We do already have existing processor tests in Go, but this does open the door to very simple tests that don't require Go. I don't think the Starlark language needs tests per-se, because that's covered elsewhere by the Starlark repo. So what's left? I think these tests started as "let's make sure our implementation works", but going forward they're more useful as a user-facing tool, explaining how one might use Starlark to solve various problems. From that perspective, I don't think we should complicate them too much. it's less about stress testing the python function and more about ensuring it works as advertised. A user should be able to copy the function and examples and get the same result. Given this change, I've been thinking about renaming the |
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.
Thanks for fixing all my wrong LP syntax!
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.
good idea
We can vastly improve the quality of the starlark examples by executing them, along with their documentation standards, as tests.
Using
Example Input:
andExample Output:
as section header markers, we can parse the subsequent metrics out and use them as inputs to test the Starlark function, comparing the processed metrics to the example output, and failing if it does not match.Example docs standards + function:
also the multi-line string format works, too:
These get executed as tests, and if the lines are not parsable, the headers are missing, or the example output claimed is not generated, the test fails.
Example failures:
results: