You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ra...@apache.org on 2019/12/14 21:22:27 UTC

[openwhisk] branch master updated: Make sure the API host env var is send only via docker run for test. (#4765)

This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new f3f62df  Make sure the API host env var is send only via docker run for test. (#4765)
f3f62df is described below

commit f3f62df748f78a33fae0dadb575b677e5acc6b1d
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Sat Dec 14 16:22:13 2019 -0500

    Make sure the API host env var is send only via docker run for test. (#4765)
---
 .../test/scala/actionContainers/BasicActionRunnerTests.scala |  4 +++-
 tools/actionProxy/invoke.py                                  | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala b/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
index cceae85..547ceeb 100644
--- a/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
+++ b/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
@@ -316,11 +316,13 @@ trait BasicActionRunnerTests extends ActionProxyContainerTestUtils {
 
     val env = props.map { case (k, v) => s"__OW_${k.toUpperCase()}" -> v }
 
+    // the api host is sent as a docker run environment parameter
     val (out, err) = withActionContainer(env.take(1).toMap) { c =>
       val (initCode, _) = c.init(initPayload(config.code, config.main))
       initCode should be(200)
 
-      val (runCode, out) = c.run(runPayload(JsObject.empty, Some(props.toMap.toJson.asJsObject)))
+      // we omit the api host from the run payload so the docker run env var is used
+      val (runCode, out) = c.run(runPayload(JsObject.empty, Some(props.drop(1).toMap.toJson.asJsObject)))
       runCode should be(200)
       out shouldBe defined
       props.map {
diff --git a/tools/actionProxy/invoke.py b/tools/actionProxy/invoke.py
index 9745a64..6e7000e 100755
--- a/tools/actionProxy/invoke.py
+++ b/tools/actionProxy/invoke.py
@@ -66,6 +66,10 @@ def dockerHost():
 def containerRoute(args, path):
     return 'http://%s:%s/%s' % (args.host, args.port, path)
 
+class objectify(object):
+    def __init__(self, d):
+        self.__dict__ = d
+
 def parseArgs():
     parser = argparse.ArgumentParser(description='initialize and run an OpenWhisk action container')
     parser.add_argument('-v', '--verbose', help='verbose output', action='store_true')
@@ -76,6 +80,7 @@ def parseArgs():
 
     initmenu = subparsers.add_parser('init', help='initialize container with src or zip/tgz file')
     initmenu.add_argument('-b', '--binary', help='treat artifact as binary', action='store_true')
+    initmenu.add_argument('-r', '--run', nargs='?', default=None, help='run after init')
     initmenu.add_argument('main', nargs='?', default='main', help='name of the "main" entry method for the action')
     initmenu.add_argument('artifact', help='a source file or zip/tgz archive')
     initmenu.add_argument('env', nargs='?', help='the environment variables to export to the action, either a reference to a file or an inline JSON object', default=None)
@@ -114,8 +119,15 @@ def init(args):
                 "env": processPayload(args.env)
             }
         })
+
     print(r.text)
 
+    if r.status_code == 200 and args.run is not None:
+        runArgs = objectify({})
+        runArgs.__dict__ = args.__dict__.copy()
+        runArgs.payload = args.run
+        run(runArgs)
+
 def run(args):
     value = processPayload(args.payload)
     if args.verbose: