-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
Hi, thanks for the PR! We'll have a review over it soon. |
@@ -0,0 +1,66 @@ | |||
package com.yourcompany.perf.yourservice |
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.
@wtait1 Do we want to continue to ship with the gatling template? We already have it, so may as well keep it?
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.
@Celeo My suggestion to this is, that we should stop shipping .go
files as default supported template and convert them to .template
. I did this to demonstrate the same. And a user can have more templates like this. Let me know if i make sense.
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.
@shubhamarora yes I think moving to .template
files is great! In fact, what I'm thinking is that the Karate template should be moved over now as well. Then all test generation is being driven by a .template
file, but the "default" formats use .template
files that are shipped with the binary, and custom templates are provided via the new flag.
For packaging the default templates into the binary, there are several tools that do this. pkger
seems like a good choice (go-bindata
is no longer supported, and pkger
is intended as a replacement for packr
).
https://github.com/markbates/pkger
I've never personally worked with pkger
before, but I'd be happy to help out / provide guidance as I think creating this common .template
-based approach would be slick
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.
@shubhamarora done
main.go
Outdated
|
||
// check if template exist at the provided path | ||
// TODO: add validation for correctness of template | ||
if flags.output != "karate" { |
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.
If we are going to support just karate as a built-in, then this should be okay. If we look to support more, though, we'll probably want to hoist those template names into a global variable so we can use it here and in the flag description.
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 keep that open to you and @wtait1 to decide the default supported template. My idea is to go ahead with karate as default, ship it with package and for rest, user can pass path to template.
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 say we should keep both for now - this task is more about changing how templates are provided to the test generation process. See my longer comment below for more detail on how I think we should ship the default templates
@wtait1 We have some decision awaiting, can you please share your views and I can take this change to fruition. Thanks! :) |
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.
Great work so far Shubham. I think there's a bit more discussion we can have to unify the method for providing templates. See detail in the comments
main.go
Outdated
@@ -84,7 +85,8 @@ func readFlags() { | |||
flag.IntVarP(&flags.defaultTargetPort, "target-port", "t", 8080, "The port the Replay Zero proxy will forward to on localhost") | |||
flag.BoolVar(&flags.debug, "debug", false, "Set logging to also print debug messages") | |||
flag.IntVarP(&flags.batchSize, "batch-size", "b", 1, "Buffer events before writing out to a file") | |||
flag.StringVarP(&flags.output, "output", "o", "karate", "Either [karate] or [gatling]") | |||
flag.StringVarP(&flags.output, "output", "o", "karate", "Either [karate] or [path/to/custom/template]") |
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.
Should the name of this flag be changed? Not that it was perfect before, but I would be confused as an end user if a flag named output
asked for a file as input 🙂
@@ -0,0 +1,66 @@ | |||
package com.yourcompany.perf.yourservice |
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.
@shubhamarora yes I think moving to .template
files is great! In fact, what I'm thinking is that the Karate template should be moved over now as well. Then all test generation is being driven by a .template
file, but the "default" formats use .template
files that are shipped with the binary, and custom templates are provided via the new flag.
For packaging the default templates into the binary, there are several tools that do this. pkger
seems like a good choice (go-bindata
is no longer supported, and pkger
is intended as a replacement for packr
).
https://github.com/markbates/pkger
I've never personally worked with pkger
before, but I'd be happy to help out / provide guidance as I think creating this common .template
-based approach would be slick
main.go
Outdated
|
||
// check if template exist at the provided path | ||
// TODO: add validation for correctness of template | ||
if flags.output != "karate" { |
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 say we should keep both for now - this task is more about changing how templates are provided to the test generation process. See my longer comment below for more detail on how I think we should ship the default templates
@@ -81,10 +82,11 @@ func readFlags() { | |||
} | |||
flag.BoolVarP(&flags.version, "version", "V", false, "Print version info and exit") | |||
flag.IntVarP(&flags.listenPort, "listen-port", "l", 9000, "The port the Replay Zero proxy will listen on") | |||
flag.IntVarP(&flags.defaultTargetPort, "target-port", "t", 8080, "The port the Replay Zero proxy will forward to on localhost") | |||
flag.IntVarP(&flags.defaultTargetPort, "target-port", "p", 8080, "The port the Replay Zero proxy will forward to on localhost") |
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.
Need to update doc about this, if this is mentioned somewhere
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.
See latest review comment for more on docs
flag.StringVarP(&flags.template, "template", "t", "karate", "Either [karate] or [gatling] or [path/to/custom/template]") | ||
flag.StringVarP(&flags.extension, "extension", "e", "", "For custom output template") |
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 will update documentation and add details about them after change is finalised
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.
See latest review comment for more on docs
I believe committing the vendor folder was a decision made when the project was still internal-only. We can revisit it now if there's a notable benefit. |
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.
@shubhamarora this is shaping up very well, we're almost there!
-
RE: documentation, we do try to make the tool pretty self-describing via good
-h
output 🙂 but we do also have a section in the README ondifferent output formats
. If you want to add a sub-section there on passing custom templates, that would be awesome. -
RE: the
vendor
folder, yes it would be nice to get rid of that but as Matt said, that's an artifact from our previous development process. I'm inclined to say don't worry about it for now.
@@ -81,10 +82,11 @@ func readFlags() { | |||
} | |||
flag.BoolVarP(&flags.version, "version", "V", false, "Print version info and exit") | |||
flag.IntVarP(&flags.listenPort, "listen-port", "l", 9000, "The port the Replay Zero proxy will listen on") | |||
flag.IntVarP(&flags.defaultTargetPort, "target-port", "t", 8080, "The port the Replay Zero proxy will forward to on localhost") | |||
flag.IntVarP(&flags.defaultTargetPort, "target-port", "p", 8080, "The port the Replay Zero proxy will forward to on localhost") |
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.
See latest review comment for more on docs
flag.StringVarP(&flags.template, "template", "t", "karate", "Either [karate] or [gatling] or [path/to/custom/template]") | ||
flag.StringVarP(&flags.extension, "extension", "e", "", "For custom output template") |
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.
See latest review comment for more on docs
replay-zero --template=gatling | ||
``` | ||
|
||
You can also pass path to your own custom template (in case you dont want to use karate or gatling) to the same paramater and `--extension` or `-e` to pass extentsion of the output. |
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 give this PR a green light after 2 quick additions
- Can we mention here that the templates are following the format from the
text/template
package in the Go stdlib? So readers have more guidance on where to start - While we're at it, let's also let them know that we support all template functions provided by Sprig (ex. "You can even extend your template's functionality with string manipulation, math operators, and more from the Sprig library"), so they don't end up re-inventing like the wheel like I originally did when this project was started!
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.
Done!
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.
LGTM. Loved the collaboration / conversation in this PR to bring a great extension to Replay Zero's functionality!
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.
Fantastic work! We really appreciate your contribution!
🚀 PR was released in |
What's changing
*Changes to present POC of impl. More changes are yet to be done.
Change request: #6
Adding support for user to provide their own custom templates. After this change user will be able to provide
path/to/custom/template
andextension
via parameters when running replay-zero.Sample command:
replay-zero --output=/path/to/templates/gatling_default.template --extension=scala
What else might be impacted?
...
Checklist
[ ] Unit tests (updated and/or added)
[ ] Documentation (function/class docs, comments, etc.)