dgrove-oss closed pull request #70: Update base images to openwhisk/dockerskeleton:1.3.1. URL: https://github.com/apache/incubator-openwhisk-runtime-swift/pull/70
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/swift3.1.1Action/CHANGELOG.md b/core/swift3.1.1Action/CHANGELOG.md index 146b9da..6eb342c 100644 --- a/core/swift3.1.1Action/CHANGELOG.md +++ b/core/swift3.1.1Action/CHANGELOG.md @@ -19,6 +19,10 @@ # Apache OpenWhisk Swift 3.1 Runtime Container +## 1.0.1 +Changes: + - Update base image to openwhisk/dockerskeleton:1.3.1 + ## 1.0.0 Initial Swift 3.1 image - Image name: `openwhisk/action-swift-v3.1.1` diff --git a/core/swift3.1.1Action/Dockerfile b/core/swift3.1.1Action/Dockerfile index dc64d91..e727f3b 100755 --- a/core/swift3.1.1Action/Dockerfile +++ b/core/swift3.1.1Action/Dockerfile @@ -27,7 +27,7 @@ RUN apt-get -y update \ && apt-get -y install --fix-missing python2.7 python-gevent python-flask zip # Add the action proxy -ADD https://raw.githubusercontent.com/apache/incubator-openwhisk-runtime-docker/dockerskeleton%401.1.0/core/actionProxy/actionproxy.py /actionProxy/actionproxy.py +ADD https://raw.githubusercontent.com/apache/incubator-openwhisk-runtime-docker/dockerskeleton%401.3.1/core/actionProxy/actionproxy.py /actionProxy/actionproxy.py # Add files needed to build and run action RUN mkdir -p /swift3Action diff --git a/core/swift41Action/CHANGELOG.md b/core/swift41Action/CHANGELOG.md index d98c082..d8f1379 100644 --- a/core/swift41Action/CHANGELOG.md +++ b/core/swift41Action/CHANGELOG.md @@ -19,6 +19,10 @@ # Apache OpenWhisk Swift 4.1 Runtime Container +## 1.0.6 +Changes: + - Update base image to openwhisk/dockerskeleton:1.3.1 + ## 1.0.5 Changes: - update to pass swiftc flags -Xswiftc -Onone to workaround swift optimization problem diff --git a/core/swift41Action/Dockerfile b/core/swift41Action/Dockerfile index cd3ae84..96fa9b5 100644 --- a/core/swift41Action/Dockerfile +++ b/core/swift41Action/Dockerfile @@ -72,7 +72,7 @@ RUN apt-get -y update \ && apt-get -y install --fix-missing python2.7 python-gevent python-flask zip # Add the action proxy -ADD https://raw.githubusercontent.com/apache/incubator-openwhisk-runtime-docker/dockerskeleton%401.1.0/core/actionProxy/actionproxy.py /actionProxy/actionproxy.py +ADD https://raw.githubusercontent.com/apache/incubator-openwhisk-runtime-docker/dockerskeleton%401.3.1/core/actionProxy/actionproxy.py /actionProxy/actionproxy.py # Add files needed to build and run action RUN mkdir -p /swift4Action/spm-build/Sources/Action diff --git a/tests/.pydevproject b/tests/.pydevproject deleted file mode 100644 index 40e9f40..0000000 --- a/tests/.pydevproject +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?eclipse-pydev version="1.0"?><pydev_project> -<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> -<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> -</pydev_project> diff --git a/tests/src/test/scala/runtime/actionContainers/SwiftActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/SwiftActionContainerTests.scala index 1ba70b0..8087b77 100644 --- a/tests/src/test/scala/runtime/actionContainers/SwiftActionContainerTests.scala +++ b/tests/src/test/scala/runtime/actionContainers/SwiftActionContainerTests.scala @@ -19,9 +19,9 @@ package runtime.actionContainers import java.io.File import common.WskActorSystem -import actionContainers.{ActionContainer, ActionProxyContainerTestUtils, ResourceHelpers} +import actionContainers.{ActionContainer, BasicActionRunnerTests} import actionContainers.ActionContainer.withContainer -import spray.json.DefaultJsonProtocol._ +import actionContainers.ResourceHelpers.readAsBase64 import spray.json._ abstract class SwiftActionContainerTests extends BasicActionRunnerTests with WskActorSystem { @@ -35,6 +35,8 @@ abstract class SwiftActionContainerTests extends BasicActionRunnerTests with Wsk behavior of swiftContainerImageName + //testNoSourceOrExec(checkResultInLogs = false) + testEcho(Seq { ( "swift echo", @@ -110,6 +112,12 @@ abstract class SwiftActionContainerTests extends BasicActionRunnerTests with Wsk }, enforceEmptyOutputStream) + testInitCannotBeCalledMoreThanOnce(""" + | func main(args: [String: Any]) -> [String: Any] { + | return args + | } + """.stripMargin) + it should "support actions using non-default entry points" in { withActionContainer() { c => val code = """ @@ -201,7 +209,7 @@ abstract class SwiftActionContainerTests extends BasicActionRunnerTests with Wsk it should "support pre-compiled binary in a zip file" in { val zip = new File(swiftBinaryName).toPath - val code = ResourceHelpers.readAsBase64(zip) + val code = readAsBase64(zip) val (out, err) = withActionContainer() { c => val (initCode, initRes) = c.init(initPayload(code)) @@ -252,128 +260,3 @@ abstract class SwiftActionContainerTests extends BasicActionRunnerTests with Wsk } } - -trait BasicActionRunnerTests extends ActionProxyContainerTestUtils { - def withActionContainer(env: Map[String, String] = Map.empty)(code: ActionContainer => Unit): (String, String) - - /** - * Runs tests for actions which do not return a dictionary and confirms expected error messages. - * @param codeNotReturningJson code to execute, should not return a JSON object - * @param checkResultInLogs should be true iff the result of the action is expected to appear in stdout or stderr - */ - def testNotReturningJson(codeNotReturningJson: String, checkResultInLogs: Boolean = true) = { - it should "run and report an error for script not returning a json object" in { - val (out, err) = withActionContainer() { c => - val (initCode, _) = c.init(initPayload(codeNotReturningJson)) - initCode should be(200) - val (runCode, out) = c.run(JsObject()) - runCode should be(502) - out should be(Some(JsObject("error" -> JsString("The action did not return a dictionary.")))) - } - - checkStreams(out, err, { - case (o, e) => - if (checkResultInLogs) { - (o + e) should include("not a json object") - } else { - o shouldBe empty - e shouldBe empty - } - }) - } - } - - /** - * Runs tests for code samples which are expected to echo the input arguments - * and print hello [stdout, stderr]. - */ - def testEcho(stdCodeSamples: Seq[(String, String)]) = { - stdCodeSamples.foreach { s => - it should s"run a ${s._1} script" in { - val argss = List( - JsObject("string" -> JsString("hello")), - JsObject("string" -> JsString("❄ ☃ ❄")), - JsObject("numbers" -> JsArray(JsNumber(42), JsNumber(1))), - // JsObject("boolean" -> JsBoolean(true)), // fails with swift3 returning boolean: 1 - JsObject("object" -> JsObject("a" -> JsString("A")))) - - val (out, err) = withActionContainer() { c => - val (initCode, _) = c.init(initPayload(s._2)) - initCode should be(200) - - for (args <- argss) { - val (runCode, out) = c.run(runPayload(args)) - runCode should be(200) - out should be(Some(args)) - } - } - - checkStreams(out, err, { - case (o, e) => - o should include("hello stdout") - e should include("hello stderr") - }, argss.length) - } - } - } - - def testUnicode(stdUnicodeSamples: Seq[(String, String)]) = { - stdUnicodeSamples.foreach { s => - it should s"run a ${s._1} action and handle unicode in source, input params, logs, and result" in { - val (out, err) = withActionContainer() { c => - val (initCode, _) = c.init(initPayload(s._2)) - initCode should be(200) - - val (runCode, runRes) = c.run(runPayload(JsObject("delimiter" -> JsString("❄")))) - runRes.get.fields.get("winter") shouldBe Some(JsString("❄ ☃ ❄")) - } - - checkStreams(out, err, { - case (o, _) => - o.toLowerCase should include("❄ ☃ ❄") - }) - } - } - } - - /** Runs tests for code samples which are expected to return the expected standard environment {auth, edge}. */ - def testEnv(stdEnvSamples: Seq[(String, String)], - enforceEmptyOutputStream: Boolean = true, - enforceEmptyErrorStream: Boolean = true) = { - stdEnvSamples.foreach { s => - it should s"run a ${s._1} script and confirm expected environment variables" in { - val props = Seq( - "api_host" -> "xyz", - "api_key" -> "abc", - "namespace" -> "zzz", - "action_name" -> "xxx", - "activation_id" -> "iii", - "deadline" -> "123") - val env = props.map { case (k, v) => s"__OW_${k.toUpperCase()}" -> v } - - val (out, err) = withActionContainer(env.take(1).toMap) { c => - val (initCode, _) = c.init(initPayload(s._2)) - initCode should be(200) - - val (runCode, out) = c.run(runPayload(JsObject(), Some(props.toMap.toJson.asJsObject))) - runCode should be(200) - out shouldBe defined - props.map { - case (k, v) => - withClue(k) { - out.get.fields(k) shouldBe JsString(v) - } - - } - } - - checkStreams(out, err, { - case (o, e) => - if (enforceEmptyOutputStream) o shouldBe empty - if (enforceEmptyErrorStream) e shouldBe empty - }) - } - } - - } -} diff --git a/tests/src/test/scala/runtime/actionContainers/SwiftCodableActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/SwiftCodableActionContainerTests.scala index cf60026..fc64f37 100644 --- a/tests/src/test/scala/runtime/actionContainers/SwiftCodableActionContainerTests.scala +++ b/tests/src/test/scala/runtime/actionContainers/SwiftCodableActionContainerTests.scala @@ -19,8 +19,9 @@ package runtime.actionContainers import java.io.File import common.WskActorSystem -import actionContainers.{ActionContainer, ResourceHelpers} +import actionContainers.{ActionContainer, BasicActionRunnerTests} import actionContainers.ActionContainer.withContainer +import actionContainers.ResourceHelpers.readAsBase64 import spray.json._ abstract class SwiftCodableActionContainerTests extends BasicActionRunnerTests with WskActorSystem { @@ -213,7 +214,7 @@ abstract class SwiftCodableActionContainerTests extends BasicActionRunnerTests w it should "support pre-compiled binary in a zip file" in { val zip = new File(swiftBinaryName).toPath - val code = ResourceHelpers.readAsBase64(zip) + val code = readAsBase64(zip) val (out, err) = withActionContainer() { c => val (initCode, initRes) = c.init(initPayload(code)) diff --git a/tests/src/test/scala/runtime/sdk/SwiftSDKTests.scala b/tests/src/test/scala/runtime/sdk/SwiftSDKTests.scala index d5437db..8822e31 100644 --- a/tests/src/test/scala/runtime/sdk/SwiftSDKTests.scala +++ b/tests/src/test/scala/runtime/sdk/SwiftSDKTests.scala @@ -18,18 +18,17 @@ package runtime.sdk import java.io.File + import scala.concurrent.duration.DurationInt import scala.language.postfixOps -import org.scalatest.Matchers -import common.{TestHelpers, WhiskProperties, WskProps, WskTestHelpers} -import common.rest.WskRest +import common._ import spray.json._ import spray.json.DefaultJsonProtocol.StringJsonFormat -abstract class SwiftSDKTests extends TestHelpers with WskTestHelpers with Matchers { +abstract class SwiftSDKTests extends TestHelpers with WskTestHelpers with WskActorSystem { implicit val wskprops = WskProps() - val wsk = new WskRest + val wsk = new Wsk val activationPollDuration = 2.minutes lazy val actionKind = "swift:3.1.1" lazy val lang = actionKind.split(":")(0) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
