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.
diff --git a/README.md b/README.md index a62b520..26dbb2e 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 02f5949..7a30848 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 dd374f6..af00eba 100644 --- a/core/python2Action/Dockerfile +++ b/core/python2Action/Dockerfile
@@ -50,8 +50,9 @@ 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 9f95463..34eba5c 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 1f4873b..3021fa8 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 @@ 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 ecc40e3..9dcdee5 100644 --- a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala +++ b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala
@@ -42,87 +42,78 @@ behavior of imageName - testNotReturningJson( - """ + 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) { + """ |def main(args): - | return "not a json object" - """.stripMargin, - checkResultInLogs = false) - - testEcho(Seq { - ( - "python", - """ - |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) + | 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) - }) + |def main(args): + | sep = args['delimiter'] + | str = sep + " ☃ ".decode('utf-8') + sep + | print(str.encode('utf-8')) + | return {"winter" : str } + """.stripMargin.trim + }) - testInitCannotBeCalledMoreThanOnce(""" + 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") -> """