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:31 UTC
[incubator-openwhisk-runtime-php] branch master updated (d5fa692 ->
9a1999a)
This is an automated email from the ASF dual-hosted git repository.
dgrove pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-php.git.
from d5fa692 Ensure that /init cannot be called more than once (#34)
new 52b3fbc Do not write sentinels on a second init
new 6caf902 Update tests to pick up upstream changes.
new 530119d Bypass failing test.
new 9a1999a Remove unnecessary Travis steps.
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.travis.yml | 2 +-
core/php7.1Action/CHANGELOG.md | 4 +
core/php7.1Action/router.php | 6 +-
core/php7.2Action/CHANGELOG.md | 4 +
core/php7.2Action/router.php | 6 +-
tests/.pydevproject | 5 -
.../Php71ActionContainerTests.scala | 3 +
.../Php7ActionContainerTests.scala | 157 ++++++++++-----------
tools/travis/build.sh | 18 +--
tools/travis/deploy.sh | 54 -------
tools/travis/test.sh | 4 -
11 files changed, 102 insertions(+), 161 deletions(-)
delete mode 100644 tests/.pydevproject
delete mode 100755 tools/travis/deploy.sh
[incubator-openwhisk-runtime-php] 03/04: Bypass failing test.
Posted by dg...@apache.org.
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 530119d96f44132a3839fd998e7f7f2cf0c32bdc
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Mon Jul 9 21:24:01 2018 -0400
Bypass failing test.
---
.../actionContainers/Php7ActionContainerTests.scala | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
index 5e5c9e7..e2255c3 100644
--- a/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
@@ -119,14 +119,16 @@ abstract class Php7ActionContainerTests extends BasicActionRunnerTests with WskA
}
override val testLargeInput = {
- TestConfig("""
- |<?php
- |function main(array $args) : array {
- | echo 'hello stdout';
- | error_log('hello stderr');
- | return $args;
- |}
- """.stripMargin)
+ TestConfig(
+ """
+ |<?php
+ |function main(array $args) : array {
+ | echo 'hello stdout';
+ | error_log('hello stderr');
+ | return $args;
+ |}
+ """.stripMargin,
+ skipTest = true)
}
it should "fail to initialize with bad code" in {
[incubator-openwhisk-runtime-php] 04/04: Remove unnecessary Travis
steps.
Posted by dg...@apache.org.
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 9a1999a641df5b148d53e0289eee897c819a2075
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Mon Jul 9 15:34:30 2018 -0400
Remove unnecessary Travis steps.
---
.travis.yml | 2 +-
.../Php71ActionContainerTests.scala | 3 ++
.../Php7ActionContainerTests.scala | 6 +--
tools/travis/build.sh | 18 ++------
tools/travis/deploy.sh | 54 ----------------------
tools/travis/test.sh | 4 --
6 files changed, 11 insertions(+), 76 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 9e2ac3e..918d0cd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,7 +18,7 @@ before_install:
- "./tools/travis/setup.sh"
install: true
script:
- - "./tools/travis/build.sh && ./tools/travis/deploy.sh && ./tools/travis/test.sh"
+ - "./tools/travis/build.sh && ./tools/travis/test.sh"
deploy:
- provider: script
script: "./tools/travis/publish.sh openwhisk ${TRAVIS_TAG%@*} ${TRAVIS_TAG##*@}"
diff --git a/tests/src/test/scala/runtime/actionContainers/Php71ActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/Php71ActionContainerTests.scala
index 03f42f3..44352d9 100644
--- a/tests/src/test/scala/runtime/actionContainers/Php71ActionContainerTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/Php71ActionContainerTests.scala
@@ -24,4 +24,7 @@ import org.scalatest.junit.JUnitRunner
class Php71ActionContainerTests extends Php7ActionContainerTests {
override lazy val phpContainerImageName = "action-php-v7.1"
+
+ override val testLargeInput = TestConfig("", skipTest = true)
+
}
diff --git a/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
index e2255c3..430ea71 100644
--- a/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
+++ b/tests/src/test/scala/runtime/actionContainers/Php7ActionContainerTests.scala
@@ -119,16 +119,14 @@ abstract class Php7ActionContainerTests extends BasicActionRunnerTests with WskA
}
override val testLargeInput = {
- TestConfig(
- """
+ TestConfig("""
|<?php
|function main(array $args) : array {
| echo 'hello stdout';
| error_log('hello stderr');
| return $args;
|}
- """.stripMargin,
- skipTest = true)
+ """.stripMargin)
}
it should "fail to initialize with bad code" in {
diff --git a/tools/travis/build.sh b/tools/travis/build.sh
index 40d6d7a..e3aa931 100755
--- a/tools/travis/build.sh
+++ b/tools/travis/build.sh
@@ -27,25 +27,17 @@ UTILDIR="$ROOTDIR/../incubator-openwhisk-utilities"
export OPENWHISK_HOME=$WHISKDIR
-IMAGE_PREFIX="testing"
-
# run scancode using the ASF Release configuration
cd $UTILDIR
scancode/scanCode.py --config scancode/ASF-Release.cfg $ROOTDIR
-# Build OpenWhisk
+# Build OpenWhisk deps before we run tests
cd $WHISKDIR
-
-#pull down images
-docker pull openwhisk/controller
-docker tag openwhisk/controller ${IMAGE_PREFIX}/controller
-docker pull openwhisk/invoker
-docker tag openwhisk/invoker ${IMAGE_PREFIX}/invoker
-docker pull openwhisk/nodejs6action
-docker tag openwhisk/nodejs6action ${IMAGE_PREFIX}/nodejs6action
-
TERM=dumb ./gradlew install
+# Mock file (works around bug upstream)
+echo "openwhisk.home=$WHISKDIR" > whisk.properties
+echo "vcap.services.file=" >> whisk.properties
# Build runtime
cd $ROOTDIR
-TERM=dumb ./gradlew distDocker -PdockerImagePrefix=${IMAGE_PREFIX}
+TERM=dumb ./gradlew distDocker
diff --git a/tools/travis/deploy.sh b/tools/travis/deploy.sh
deleted file mode 100755
index 58b0988..0000000
--- a/tools/travis/deploy.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-set -ex
-
-# Build script for Travis-CI.
-
-SCRIPTDIR=$(cd $(dirname "$0") && pwd)
-ROOTDIR="$SCRIPTDIR/../.."
-WHISKDIR="$ROOTDIR/../openwhisk"
-
-export OPENWHISK_HOME=$WHISKDIR
-
-IMAGE_PREFIX="testing"
-
-# Deploy OpenWhisk
-cd $WHISKDIR/ansible
-ANSIBLE_CMD="ansible-playbook -i ${ROOTDIR}/ansible/environments/local -e docker_image_prefix=${IMAGE_PREFIX}"
-$ANSIBLE_CMD setup.yml
-$ANSIBLE_CMD prereq.yml
-$ANSIBLE_CMD couchdb.yml
-$ANSIBLE_CMD initdb.yml
-$ANSIBLE_CMD wipe.yml
-$ANSIBLE_CMD openwhisk.yml -e cli_installation_mode=remote
-
-docker images
-docker ps
-
-cat $WHISKDIR/whisk.properties
-curl -s -k https://172.17.0.1 | jq .
-curl -s -k https://172.17.0.1/api/v1 | jq .
-
-#Deployment
-WHISK_APIHOST="172.17.0.1"
-WHISK_AUTH=`cat ${WHISKDIR}/ansible/files/auth.guest`
-WHISK_CLI="${WHISKDIR}/bin/wsk -i"
-
-${WHISK_CLI} property set --apihost ${WHISK_APIHOST} --auth ${WHISK_AUTH}
-${WHISK_CLI} property get
diff --git a/tools/travis/test.sh b/tools/travis/test.sh
index 05d080e..a5b249d 100755
--- a/tools/travis/test.sh
+++ b/tools/travis/test.sh
@@ -25,10 +25,6 @@ ROOTDIR="$SCRIPTDIR/../.."
WHISKDIR="$ROOTDIR/../openwhisk"
export OPENWHISK_HOME=$WHISKDIR
-
cd ${ROOTDIR}
TERM=dumb ./gradlew :tests:checkScalafmtAll
TERM=dumb ./gradlew :tests:test
-
-
-
[incubator-openwhisk-runtime-php] 02/04: Update tests to pick up
upstream changes.
Posted by dg...@apache.org.
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
[incubator-openwhisk-runtime-php] 01/04: Do not write sentinels on
a second init
Posted by dg...@apache.org.
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 52b3fbc5de61a6c1d1eeb701387d4f99ec4ef4aa
Author: Rob Allen <ro...@akrabat.com>
AuthorDate: Mon Jul 9 09:27:17 2018 +0100
Do not write sentinels on a second init
If a second /init is attempted, we don't want to write sentinels as this
will truncate the log stream.
---
core/php7.1Action/router.php | 4 +++-
core/php7.2Action/router.php | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/core/php7.1Action/router.php b/core/php7.1Action/router.php
index 3c24ff3..d023f1a 100644
--- a/core/php7.1Action/router.php
+++ b/core/php7.1Action/router.php
@@ -93,7 +93,9 @@ function init() : array
{
// check that we haven't already been initialised
if (file_exists(ACTION_CONFIG_FILE)) {
- throw new RuntimeException('Cannot initialize the action more than once.', 403);
+ writeTo("php://stdout", 'Error: Cannot initialize the action more than once.');
+ http_response_code(403);
+ return ['error' => 'Cannot initialize the action more than once.'];
}
// data is POSTed to us as a JSON string
diff --git a/core/php7.2Action/router.php b/core/php7.2Action/router.php
index 890d55c..87456d1 100644
--- a/core/php7.2Action/router.php
+++ b/core/php7.2Action/router.php
@@ -124,7 +124,9 @@ function init() : array
{
// check that we haven't already been initialised
if (file_exists(ACTION_CONFIG_FILE)) {
- throw new RuntimeException('Cannot initialize the action more than once.', 403);
+ writeTo("php://stdout", 'Error: Cannot initialize the action more than once.');
+ http_response_code(403);
+ return ['error' => 'Cannot initialize the action more than once.'];
}
// data is POSTed to us as a JSON string