-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use ‘docker.host’ java property as a way to set Docker access for Runtime unit tests #3616
Use ‘docker.host’ java property as a way to set Docker access for Runtime unit tests #3616
Conversation
@csantanapr Please review. If we do just this, we can avoid having to deploy full OpenWhisk when we build/test runtimes. |
@jonpspri check this PR, travis is has errors. In addition I tried this PR locally, in docker for Mac, where it's fine to run I deleted the whisk.properties and try to run the test for the runtime-nodejs runtime
It looks like something still depends on whisk.properties |
Ah it looks like just having one property is enough
But now fails the same as Travis
|
" " | ||
val version = WhiskProperties.getProperty("whisk.version.name") | ||
// Check if we are running on docker-machine env. | ||
val hostStr = if (version.toLowerCase().contains("mac")) { |
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.
remove val hostStr
if (version.toLowerCase().contains("mac")) {
s" --host tcp://${WhiskProperties.getMainDockerEndpoint()} "
} else {
" "
}
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.
Oops. Yep, that’ll help.
Apologies for the spent time. I should have run this through the cases for whisk.properties still being there more thoroughly. I’ll ping you when I get a clean Travis build. |
7549d44
to
dd3bc04
Compare
Codecov Report
@@ Coverage Diff @@
## master #3616 +/- ##
=======================================
Coverage 74.49% 74.49%
=======================================
Files 126 126
Lines 5990 5990
Branches 390 390
=======================================
Hits 4462 4462
Misses 1528 1528 Continue to review full report at Codecov.
|
" " | ||
val version = WhiskProperties.getProperty("whisk.version.name") | ||
// Check if we are running on docker-machine env. | ||
if (version.toLowerCase().contains("mac")) { |
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.
What do you think making the unit tests work with no “whisk.properties” present at all?
By adding a check if System.getenv("OPENWHISK_HOME")/WhiskProperties.WHISK_PROPS_FILE doesn’t exist.
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.
Same thing below
Check if file doesn’t exist and onOSX the. Use a port
Or if file exist read if local and OSX then same as today use a port
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 file doesn’t exist and not OSX then don’t use a port
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.
Could be. I was thinking this morning of stringing together several options and using whichever came back first with an affirmative result:
1). The ‘docker.host’ Java property (which is what I’ll be using in multi-arch builds)
2). The ‘DOCKER_HOST’ environment variable (which is set on docker-machine systems)
3). The ‘WhiskProperties’ logic if ‘WhiskProperties’ exists (add a try/catch) block
4). Just run ‘docker info’ and see if it works
5). Fail
I can foldLeft an ordered list of anonymous functions implementing each of those to make it fairly maintainable. Of course, it’ll take us some time to test the tests...
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.
Yeah sounds good
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.
Okay. It'll take a little time to do and test. I'll mark this WIP for now.
90506cf
to
d398103
Compare
@jonpspri your done with WIP and ready for review? |
PG2 3111 ⌛️ |
PG2 3111 🔵 |
New PG1 2889 ⌛️ |
@@ -145,8 +169,7 @@ object ActionContainer { | |||
|
|||
// ...find out its IP address... | |||
val (ip, port) = | |||
if (WhiskProperties.getProperty("whisk.version.name") == "local" && | |||
WhiskProperties.onMacOSX()) { | |||
if (System.getProperty("os.name").toLowerCase().contains("mac")) { |
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.
@csantanapr, said to check if DOCKER_HOST
is set here to determine if docker-machine
is being used on a Mac.
@dubee this is ready now. |
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.
Run ./gradlew scalafmtAll
. Looks like the Travis check is failing.
// Test here that this actually works, otherwise throw a somewhat understandable error message | ||
proc(s"$dockerCmdString info").onComplete { | ||
case Success((v, _, _)) if (v != 0) => | ||
throw new RuntimeException("""Unable to connect to docker host using '$d' as command string. |
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.
What is $d
?
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 guess it needs to be $dockerCmdString
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.
Add s
in front of the string as well.
s"""Unable to connect to docker host using '$dockerCmdString' as command string.
|The docker host is determined using the Java property 'docker.host' or
|the envirnoment variable 'DOCKER_HOST'. Please verify that one or the
|other is set for your build/test process.""".stripMargin
PG3/2269 🏃 |
PG3/2269 🔵 |
Description
These changes allow new scripts using docker-gradle-plugin to use Java properties to pass Docker URL information to the test, rather than inferring it based on whisk. properties. If the ‘docker.host’ java property is not set, the original ‘whisk.properties’ logic is used as a fallback.
Related issue and scope
My changes affect the following components
Types of changes
Checklist: