From 7f4921adf2eea5a565d3783c15eadc14d125a638 Mon Sep 17 00:00:00 2001 From: rodric rabbah <rodric@gmail.com> Date: Mon, 9 Jul 2018 16:22:54 -0400 Subject: [PATCH] Update base images to openwhisk/dockerskeleton:1.3.2. (#33) Update base images to openwhisk/dockerskeleton:1.3.2. and adjust tests for upstream changes. --- README.md | 2 +- core/python2Action/CHANGELOG.md | 4 + core/python2Action/Dockerfile | 3 +- core/pythonAction/CHANGELOG.md | 4 + core/pythonAction/Dockerfile | 3 +- .../PythonActionContainerTests.scala | 139 ++++++++---------- 6 files changed, 78 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index a62b5200..26dbb2e2 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ### Give it a try today To use as a docker action using python 3 ``` -wsk action update myAction myAction.py --docker openwhisk/python3action:1.0.1 +wsk action update myAction myAction.py --docker openwhisk/python3action:1.0.2 ``` Replace `python3action` with `python2action` to use python 2. diff --git a/core/python2Action/CHANGELOG.md b/core/python2Action/CHANGELOG.md index 02f59494..7a308482 100644 --- a/core/python2Action/CHANGELOG.md +++ b/core/python2Action/CHANGELOG.md @@ -19,6 +19,10 @@ # Python 2 OpenWhisk Runtime Container +## 1.0.2 +Changes: + - Update base image to openwhisk/dockerskeleton:1.3.2 + ## 1.0.1 Changes: - Update base image to openwhisk/dockerskeleton:1.3.1 diff --git a/core/python2Action/Dockerfile b/core/python2Action/Dockerfile index dd374f68..af00eba9 100644 --- a/core/python2Action/Dockerfile +++ b/core/python2Action/Dockerfile @@ -50,8 +50,9 @@ RUN pip install --no-cache-dir --upgrade pip setuptools six \ ENV FLASK_PROXY_PORT 8080 # Add the action proxy -ADD https://raw.githubusercontent.com/apache/incubator-openwhisk-runtime-docker/dockerskeleton%401.3.1/core/actionProxy/actionproxy.py /actionProxy/actionproxy.py +ADD https://raw.githubusercontent.com/apache/incubator-openwhisk-runtime-docker/dockerskeleton%401.3.2/core/actionProxy/actionproxy.py /actionProxy/actionproxy.py ADD pythonrunner.py /pythonAction/ +RUN rm -rf /action CMD ["/bin/bash", "-c", "cd pythonAction && python -u pythonrunner.py"] diff --git a/core/pythonAction/CHANGELOG.md b/core/pythonAction/CHANGELOG.md index 9f954636..34eba5c4 100644 --- a/core/pythonAction/CHANGELOG.md +++ b/core/pythonAction/CHANGELOG.md @@ -19,6 +19,10 @@ # Python 3 OpenWhisk Runtime Container +## 1.0.2 +Changes: + - Update base image to openwhisk/dockerskeleton:1.3.2 + ## 1.0.1 Changes: - Update base image to openwhisk/dockerskeleton:1.3.1 diff --git a/core/pythonAction/Dockerfile b/core/pythonAction/Dockerfile index 1f4873b9..3021fa89 100644 --- a/core/pythonAction/Dockerfile +++ b/core/pythonAction/Dockerfile @@ -16,7 +16,7 @@ # # Dockerfile for python actions, overrides and extends ActionRunner from actionProxy -FROM openwhisk/dockerskeleton:1.3.1 +FROM openwhisk/dockerskeleton:1.3.2 RUN apk add --no-cache \ bzip2-dev \ @@ -45,5 +45,6 @@ ENV FLASK_PROXY_PORT 8080 RUN mkdir -p /pythonAction ADD pythonrunner.py /pythonAction/ +RUN rm -rf /action CMD ["/bin/bash", "-c", "cd pythonAction && python -u pythonrunner.py"] diff --git a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala index ecc40e38..9dcdee57 100644 --- a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala +++ b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala @@ -42,87 +42,78 @@ class PythonActionContainerTests extends BasicActionRunnerTests with WskActorSys behavior of imageName - testNotReturningJson( - """ - |def main(args): - | return "not a json object" - """.stripMargin, - checkResultInLogs = false) - - testEcho(Seq { - ( - "python", + override val testNoSourceOrExec = TestConfig("") + override val testNoSource = TestConfig("", hasCodeStub = true) + + override val testNotReturningJson = + TestConfig(""" + |def main(args): + | return "not a json object" + """.stripMargin) + + override val testInitCannotBeCalledMoreThanOnce = + TestConfig(""" + |def main(args): + | return args + """.stripMargin) + + override val testEntryPointOtherThanMain = + TestConfig( + """ + |def niam(args): + | return args + """.stripMargin, + main = "niam") + + override val testEcho = + TestConfig(""" + |from __future__ import print_function + |import sys + |def main(args): + | print('hello stdout') + | print('hello stderr', file=sys.stderr) + | return args + """.stripMargin) + + override val testUnicode = + TestConfig(if (pythonStringAsUnicode) { """ - |from __future__ import print_function - |import sys - |def main(args): - | print('hello stdout') - | print('hello stderr', file=sys.stderr) - | return args - """.stripMargin) - }) - - testUnicode(Seq { - if (pythonStringAsUnicode) { - ( - "python", - """ - |def main(args): - | sep = args['delimiter'] - | str = sep + " ☃ " + sep - | print(str) - | return {"winter" : str } - """.stripMargin.trim) + |def main(args): + | sep = args['delimiter'] + | str = sep + " ☃ " + sep + | print(str) + | return {"winter" : str } + """.stripMargin.trim } else { - ( - "python", - """ - |def main(args): - | sep = args['delimiter'] - | str = sep + " ☃ ".decode('utf-8') + sep - | print(str.encode('utf-8')) - | return {"winter" : str } - """.stripMargin.trim) - } - }) - - testEnv(Seq { - ( - "python", """ - |import os - |def main(dict): - | return { - | "api_host": os.environ['__OW_API_HOST'], - | "api_key": os.environ['__OW_API_KEY'], - | "namespace": os.environ['__OW_NAMESPACE'], - | "action_name": os.environ['__OW_ACTION_NAME'], - | "activation_id": os.environ['__OW_ACTIVATION_ID'], - | "deadline": os.environ['__OW_DEADLINE'] - | } - """.stripMargin.trim) - }) - - testInitCannotBeCalledMoreThanOnce(""" + |def main(args): + | sep = args['delimiter'] + | str = sep + " ☃ ".decode('utf-8') + sep + | print(str.encode('utf-8')) + | return {"winter" : str } + """.stripMargin.trim + }) + + override val testEnv = + TestConfig(""" + |import os + |def main(dict): + | return { + | "api_host": os.environ['__OW_API_HOST'], + | "api_key": os.environ['__OW_API_KEY'], + | "namespace": os.environ['__OW_NAMESPACE'], + | "action_name": os.environ['__OW_ACTION_NAME'], + | "activation_id": os.environ['__OW_ACTIVATION_ID'], + | "deadline": os.environ['__OW_DEADLINE'] + | } + """.stripMargin.trim) + + override val testLargeInput = + TestConfig(""" |def main(args): | return args """.stripMargin) - it should "support actions using non-default entry points" in { - withActionContainer() { c => - val code = """ - |def niam(dict): - | return { "result": "it works" } - |""".stripMargin - - val (initCode, initRes) = c.init(initPayload(code, main = "niam")) - initCode should be(200) - - val (_, runRes) = c.run(runPayload(JsObject())) - runRes.get.fields.get("result") shouldBe Some(JsString("it works")) - } - } - it should "support zip-encoded action using non-default entry points" in { val srcs = Seq( Seq("__main__.py") -> """ -- GitLab