You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by dg...@apache.org on 2018/07/10 02:34:33 UTC
[incubator-openwhisk-runtime-php] 02/04: Update tests to pick up
upstream changes.
This is an automated email from the ASF dual-hosted git repository.
dgrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-php.git
commit 6caf902f527250ee4b7b695929b628d560e0dad1
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Sat Jul 7 21:20:35 2018 -0400
Update tests to pick up upstream changes.
---
core/php7.1Action/CHANGELOG.md | 4 +
core/php7.1Action/router.php | 2 +-
core/php7.2Action/CHANGELOG.md | 4 +
core/php7.2Action/router.php | 2 +-
tests/.pydevproject | 5 -
.../Php7ActionContainerTests.scala | 157 ++++++++++-----------
6 files changed, 87 insertions(+), 87 deletions(-)
diff --git a/core/php7.1Action/CHANGELOG.md b/core/php7.1Action/CHANGELOG.md
index 57ff219..8ad347b 100644
--- a/core/php7.1Action/CHANGELOG.md
+++ b/core/php7.1Action/CHANGELOG.md
@@ -17,6 +17,10 @@
#
-->
+## 1.0.2
+Changes:
+ - Disallow re-initialization of function.
+
## 1.0.1
- Change: Update PHP to 7.1.18
diff --git a/core/php7.1Action/router.php b/core/php7.1Action/router.php
index d023f1a..76d8765 100644
--- a/core/php7.1Action/router.php
+++ b/core/php7.1Action/router.php
@@ -108,7 +108,7 @@ function init() : array
$binary = $data['binary'] ?? false; // code is binary?
if (!$code) {
- throw new RuntimeException("No code to execute");
+ throw new RuntimeException("Missing main/no code to execute.");
}
if ($binary) {
diff --git a/core/php7.2Action/CHANGELOG.md b/core/php7.2Action/CHANGELOG.md
index 702b708..4e4c56e 100644
--- a/core/php7.2Action/CHANGELOG.md
+++ b/core/php7.2Action/CHANGELOG.md
@@ -17,6 +17,10 @@
#
-->
+## 1.0.1
+Changes:
+ - Disallow re-initialization of function.
+
## 1.0.0
Initial release
diff --git a/core/php7.2Action/router.php b/core/php7.2Action/router.php
index 87456d1..bbf50e1 100644
--- a/core/php7.2Action/router.php
+++ b/core/php7.2Action/router.php
@@ -139,7 +139,7 @@ function init() : array
$binary = $data['binary'] ?? false; // code is binary?
if (!$code) {
- throw new RuntimeException("No code to execute");
+ throw new RuntimeException("Missing main/no code to execute.");
}
if ($binary) {
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/Php7ActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
index 000d0b0..5e5c9e7 100644
--- a/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
@@ -27,11 +27,10 @@ import spray.json._
@RunWith(classOf[JUnitRunner])
abstract class Php7ActionContainerTests extends BasicActionRunnerTests with WskActorSystem {
- // note: "out" will not be empty as the PHP web server outputs a message when
- // it starts up
+ // note: "out" will not be empty as the PHP web server outputs a message when it starts up
val enforceEmptyOutputStream = false
- lazy val phpContainerImageName = "action-php-v7.x"
+ lazy val phpContainerImageName: String = ???
override def withActionContainer(env: Map[String, String] = Map.empty)(code: ActionContainer => Unit) = {
withContainer(phpContainerImageName, env)(code)
@@ -41,30 +40,56 @@ abstract class Php7ActionContainerTests extends BasicActionRunnerTests with WskA
behavior of phpContainerImageName
- testEcho(Seq {
- (
- "PHP",
+ override val testNoSourceOrExec = TestConfig("")
+
+ override val testNotReturningJson = {
+ TestConfig(
+ """
+ |<?php
+ |function main(array $args) {
+ | return "not a json object";
+ |}
+ """.stripMargin,
+ enforceEmptyOutputStream = enforceEmptyOutputStream,
+ enforceEmptyErrorStream = false)
+ }
+
+ override val testInitCannotBeCalledMoreThanOnce = {
+ TestConfig(
"""
- |<?php
- |function main(array $args) : array {
- | echo 'hello stdout';
- | error_log('hello stderr');
- | return $args;
- |}
- """.stripMargin)
- })
-
- testNotReturningJson("""
|<?php
- |function main(array $args) {
- | return "not a json object";
+ |function main(array $args) : array {
+ | return $args;
|}
- """.stripMargin)
+ """.stripMargin,
+ enforceEmptyOutputStream = enforceEmptyOutputStream)
+ }
- testUnicode(Seq {
- (
- "PHP",
+ override val testEntryPointOtherThanMain = {
+ TestConfig(
"""
+ | <?php
+ | function niam(array $args) {
+ | return $args;
+ | }
+ """.stripMargin,
+ main = "niam",
+ enforceEmptyOutputStream = enforceEmptyOutputStream)
+ }
+
+ override val testEcho = {
+ TestConfig("""
+ |<?php
+ |function main(array $args) : array {
+ | echo 'hello stdout';
+ | error_log('hello stderr');
+ | return $args;
+ |}
+ """.stripMargin)
+ }
+
+ override val testUnicode = {
+ TestConfig("""
|<?php
|function main(array $args) : array {
| $str = $args['delimiter'] . " ☃ " . $args['delimiter'];
@@ -72,37 +97,37 @@ abstract class Php7ActionContainerTests extends BasicActionRunnerTests with WskA
| return ["winter" => $str];
|}
""".stripMargin.trim)
- })
+ }
- testEnv(
- Seq {
- (
- "PHP",
- """
- |<?php
- |function main(array $args) : array {
- | return [
- | "env" => $_ENV,
- | "api_host" => $_ENV['__OW_API_HOST'],
- | "api_key" => $_ENV['__OW_API_KEY'],
- | "namespace" => $_ENV['__OW_NAMESPACE'],
- | "action_name" => $_ENV['__OW_ACTION_NAME'],
- | "activation_id" => $_ENV['__OW_ACTIVATION_ID'],
- | "deadline" => $_ENV['__OW_DEADLINE'],
- | ];
- |}
- """.stripMargin.trim)
- },
- enforceEmptyOutputStream)
-
- testInitCannotBeCalledMoreThanOnce("""
- |<?php
- |function main(array $args) : array {
- | echo 'hello stdout';
- | error_log('hello stderr');
- | return $args;
- |}
- """.stripMargin)
+ override val testEnv = {
+ TestConfig(
+ """
+ |<?php
+ |function main(array $args) : array {
+ | return [
+ | "env" => $_ENV,
+ | "api_host" => $_ENV['__OW_API_HOST'],
+ | "api_key" => $_ENV['__OW_API_KEY'],
+ | "namespace" => $_ENV['__OW_NAMESPACE'],
+ | "action_name" => $_ENV['__OW_ACTION_NAME'],
+ | "activation_id" => $_ENV['__OW_ACTIVATION_ID'],
+ | "deadline" => $_ENV['__OW_DEADLINE'],
+ | ];
+ |}
+ """.stripMargin.trim,
+ enforceEmptyOutputStream = enforceEmptyOutputStream)
+ }
+
+ override val testLargeInput = {
+ TestConfig("""
+ |<?php
+ |function main(array $args) : array {
+ | echo 'hello stdout';
+ | error_log('hello stderr');
+ | return $args;
+ |}
+ """.stripMargin)
+ }
it should "fail to initialize with bad code" in {
val (out, err) = withPhp7Container { c =>
@@ -127,19 +152,6 @@ abstract class Php7ActionContainerTests extends BasicActionRunnerTests with WskA
})
}
- it should "fail to initialize with no code" in {
- val (out, err) = withPhp7Container { c =>
- val code = ""
-
- val (initCode, error) = c.init(initPayload(code))
-
- initCode should not be (200)
- error shouldBe a[Some[_]]
- error.get shouldBe a[JsObject]
- error.get.fields("error").toString should include("No code to execute")
- }
- }
-
it should "return some error on action error" in {
val (out, err) = withPhp7Container { c =>
val code = """
@@ -467,21 +479,6 @@ abstract class Php7ActionContainerTests extends BasicActionRunnerTests with WskA
})
}
- it should "support actions using non-default entry point" in {
- val (out, err) = withPhp7Container { c =>
- val code = """
- | <?php
- | function niam(array $args) {
- | return [result => "it works"];
- | }
- """.stripMargin
-
- c.init(initPayload(code, main = "niam"))._1 should be(200)
- val (runCode, runRes) = c.run(runPayload(JsObject()))
- runRes.get.fields.get("result") shouldBe Some(JsString("it works"))
- }
- }
-
it should "support zipped actions using non-default entry point" in {
val srcs = Seq(Seq("index.php") -> """
| <?php