-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feature: Add optional port to host mappings. #1489
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1489 +/- ##
==========================================
+ Coverage 74.82% 74.85% +0.03%
==========================================
Files 164 164
Lines 14035 14104 +69
==========================================
+ Hits 10501 10558 +57
- Misses 3002 3010 +8
- Partials 532 536 +4
Continue to review full report at Codecov.
|
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 your contribution! I left a few comments, but don't see major blockers for merging this in.
Just a heads-up: this will likely have to wait until #1007 is finally merged (any day now... 🤞).
And I'm not sure how this could be defined with the K6_HOSTS
environment variable, which even without ports is not intuitive or well documented. So maybe some more tests would be needed there, or it could wait for #883 and the removal of envconfig.
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.
Hi @calavera, Thanks for the PR!!! 🎉
I have left some comments, mostly around more tests :D, great job!
Unfortunately (as has been mentioned in other PRs as well) we are at the end of working on PR 1007 which is a quite a big change (I think you won't need to rebase, but don't quote me :D) and don't really have time for anything else(mostly because working on other things is one of the reasons why it has been so long in the making). For this, we are more or less not merging any PRs until we've merged (and possibly released) 1007 as it's quite huge on its own.
So unfortunately this (as well as a bunch of other PRs) will probably wait for at least another month (hopefully not more) until we get back to you :(. You can of course continue working on this, and if we have some time to spare we might look at it, but don't count on it :(.
Thanks again, and sorry for the inconvenience :(
Thanks for the heads up @mstoykov. Don't worry about it, take your time with all other priorities that you have. I actually wrote this code months ago an never had time to push the PR. I'll address your comments for when you're ready to take a deeper look. I was going to write some documentation about this change, but I couldn't find any place to do it. Any pointers will be appreciated. |
I meant to spare you that ... but, given that you asked :D , there is this k6-docs repo :D. Also if you click on the Thanks again for all the work :D |
@mstoykov I've updated the code with your suggestions, thanks! 🙌 I'll wait for your review to make any changes in the docs. |
Thanks for the update @mstoykov 👍 |
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.
Hey @calavera, thanks again for this work! 👍
I had forgotten about this PR and was stepping on your toes with #1562 😅, but we decided to avoid the merging conflicts and close that PR in favor of this one. The IPv6 fix will have to wait for 0.28.0 because of the additional port feature introduced here, but that's been broken for a long time now, so it can wait for a couple more weeks. :)
I took another look at this and it looks good, besides that test nitpick. If you can rebase your branch on current master
, we'll merge this as soon as 0.27.1 is released (this or next week?). The rebase conflicts should be simple to fix 🤞
985e556
to
9262820
Compare
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 took a quick glance with the morning coffee - so I might be completely wrong :D
lib/options.go
Outdated
host := string(text) | ||
var port string | ||
|
||
if isHostPort(text) { | ||
var err error | ||
host, port, err = net.SplitHostPort(host) | ||
if err != nil { | ||
return nil, "", err | ||
} | ||
} | ||
|
||
ip := net.ParseIP(host) | ||
if ip == nil { | ||
return nil, "", &net.ParseError{Type: "IP address", Text: host} | ||
} | ||
|
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.
are you here trying to figure out if there is a port ? so that net.SplitHostPort
doesn't return you an error? Because IMO you can just call it - and if there is no error - there is a port, if there is an error - there is no port :D
As far as I can see this code currently doesn't handle something.com:8413
for example correctly ?
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 double check.
As far as I can see this code currently doesn't handle something.com:8413 for example correctly ?
I don't understand this comment. As far as I can tell, the current code expects the option to be a valid IP address, and something.com
won't ever work as IP address.
Thanks for the review @mstoykov. I pushed new changes. |
That way people can map a name under different ports. This is very convenient when you run k6 against a fleet of docker containers to test the same service but want to keep the port mapping. Signed-off-by: David Calavera <[email protected]>
- Include tests for denied hosts. - Include copyright notice in new file. Signed-off-by: David Calavera <[email protected]>
- Fix default ports for tests. Signed-off-by: David Calavera <[email protected]>
Clean lint errors. Signed-off-by: David Calavera <[email protected]>
Add new tests for dialer and options. Signed-off-by: David Calavera <[email protected]>
Signed-off-by: David Calavera <[email protected]>
Add more test cases. Signed-off-by: David Calavera <[email protected]>
That way we avoid a round trip for IP addresses. Signed-off-by: David Calavera <[email protected]>
Signed-off-by: David Calavera <[email protected]>
Signed-off-by: David Calavera <[email protected]>
Signed-off-by: David Calavera <[email protected]>
Copy the struct before setting the new port. Signed-off-by: David Calavera <[email protected]>
92728b0
to
361e9e2
Compare
Signed-off-by: David Calavera <[email protected]>
361e9e2
to
97ba9ff
Compare
21f9732
to
3532479
Compare
Signed-off-by: David Calavera <[email protected]>
3532479
to
3731805
Compare
Signed-off-by: David Calavera <[email protected]>
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.
This LGTM, save for the typo nitpick. Thanks for your work @calavera and apologies about the delay with merging this.
Signed-off-by: David Calavera <[email protected]>
I've fixed those typos, thanks for the review! |
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, though we should manually test this with k6 archive
(for cloud issues) and envconfig issues (K6_HOSTS
)
This is an extension for the host mapping feature. It allows people to map to a different port than the one in the original url.
This is very convenient when you run k6 against a fleet of docker
containers to test the same service but want to keep the port mapping.
Signed-off-by: David Calavera [email protected]