-
Notifications
You must be signed in to change notification settings - Fork 0
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: internal and external DSL for writing nettests #7
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
bassosimone
changed the title
feat: richer input with homoiconicity and Go-based type checking
feat: improve DSL for writing nettests
Jul 3, 2023
bassosimone
changed the title
feat: improve DSL for writing nettests
feat: internal and external DSL for writing nettests
Jul 3, 2023
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.
This diff improves the DSL for writing nettests introduced in #5 such that we a single homoiconic representation of the DSL. The internal DSL, written in pure Go, could either perform a measurement directly or could be exported to a JSON-based AST. The external DSL derives from the JSON-serialized AST and runs the same operations as the internal one, except that type checking happens at runtime.
Because the internal DSL is in pure Go, we don't need to write custom code for type checking. At the same time, we have now lost the possibility of having a polymorphic HTTP step and we need to cast a TCP, TLS, or QUIC connection to become an HTTP connection by using the proper operation.
All the other functionality should be compatible with #5. Obviously, I needed to change the JSON representation to accommodate for minor changes, so the previously serialized JSONs should not be working anymore. This is fine, since we're still in the experimentation stage.
To be more confident that dynamic type checking works, this PR added comprehensive netem based QA tests that exercise the most common type conversions happening on success or error.
In terms of terminology, I also chose to replace "func" with "stage" (or "stage_name") since it seems more selective to deal with the composition of pipeline stages than with the composition of functions. (The pipeline stages are functions but, by calling them pipeline stages, we further clarify what we're dealing with.)
This work is part of ooni/probe#2494 and ooni/ooni.org#1296. The latter issue is related to this PR because we also included support for throttling to the DSL.