-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add remote host binding for JenkinsRule #289
base: master
Are you sure you want to change the base?
Conversation
e6646b6
to
580910c
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.
Looks good to me 👍
The reason for this change is that the JenkinRule based tests were all running inside a docker container and i needed a way to bind it a non localhost address in order to access it from outside the running container. The host binding for the JenkinsRule is configurable with the `host` property. The default value is `localhost` this keeps the backward compatibility. The following code snippet shows how to bind the JenkinsRule instance ``` @rule public JenkinsRule j = new JenkinsRule() {{ host = null; } }; ``` to all network interfaces. This is similar to set the `host` value to `0.0.0.0`. The test case `JenkinsRuleHostIPTest` validates that the assignment to a specific host ip address is working correctly. The test case `JenkinsRuleAllHostInterfaceTest` validates that the assignment to all network interfaces is working correctly.
580910c
to
8f860d2
Compare
This is basically #84 I think, and is potentially problematic for the same reason. See https://github.com/jenkinsci/kubernetes-plugin/blob/55e01eaca472ddaf7f4ae15ea9569571db6672ab/src/test/java/org/jvnet/hudson/test/JenkinsRuleNonLocalhost.java |
That's true if you bind JenkinsRule instance to 0.0.0.0. Then its possible to access it from remote depends on the network setup. I could add a log warning too. The default is still localhost and has to be conciously overwritten with a different IP or hostname. |
The reason for this change is that the JenkinRule based tests were all running
inside a docker container and i needed a way to bind it a non localhost address
in order to access it from outside the running container.
The host binding for the JenkinsRule is configurable with the
host
property. The default value is
localhost
this keeps the backwardcompatibility.
The following code snippet shows how to bind the JenkinsRule instance
to all network interfaces. This is similar to set the
host
value to0.0.0.0
.The test case
JenkinsRuleHostIPTest
validates that the assignment to a specifichost ip address is working correctly.
The test case
JenkinsRuleAllHostInterfaceTest
validates that the assignment to allnetwork interfaces is working correctly.