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/openwhisk-runtime-php.git
The following commit(s) were added to refs/heads/master by this push:
new cd48ef1 Remove PHP 7.2 (#97)
cd48ef1 is described below
commit cd48ef168032da9ef21372ee1d6c4442a2f55ff8
Author: David Grove <[email protected]>
AuthorDate: Mon Jan 4 11:25:46 2021 -0500
Remove PHP 7.2 (#97)
PHP 7.2 is no longer supported by the PHP group as per
https://www.php.net/supported-versions.php
---
.travis.yml | 5 -
README.md | 22 +-
core/php7.2Action/CHANGELOG.md | 64 ----
core/php7.2Action/Dockerfile | 63 ----
core/php7.2Action/build.gradle | 19 --
core/php7.2Action/composer.json | 11 -
core/php7.2Action/php.ini | 37 ---
core/php7.2Action/router.php | 350 ---------------------
settings.gradle | 1 -
.../Php72ActionContainerTests.scala | 115 -------
10 files changed, 3 insertions(+), 684 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 6b20acc..990bb24 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -42,11 +42,6 @@ deploy:
all_branches: true
repo: apache/openwhisk-runtime-php
- provider: script
- script: "./tools/travis/publish.sh openwhisk 7.2 nightly"
- on:
- branch: master
- repo: apache/openwhisk-runtime-php
- - provider: script
script: "./tools/travis/publish.sh openwhisk 7.3 nightly"
on:
branch: master
diff --git a/README.md b/README.md
index b56726b..f5673d1 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@
## PHP versions
-This runtime provides PHP 7.4, 7.3 & 7.2.
+This runtime provides PHP 7.4 and 7.3.
### Give it a try today
To use as a docker action
@@ -39,11 +39,6 @@ PHP 7.3:
wsk action update myAction myAction.php --docker
openwhisk/action-php-v7.3:latest
```
-PHP 7.2:
-```
-wsk action update myAction myAction.php --docker
openwhisk/action-php-v7.2:latest
-```
-
This works on any deployment of Apache OpenWhisk
### To use on deployment that contains the runtime as a kind
@@ -59,28 +54,21 @@ PHP 7.3:
wsk action update myAction myAction.php --kind php:7.3
```
-PHP 7.2:
-```
-wsk action update myAction myAction.php --kind php:7.2
-```
-
### Local development
```
./gradlew core:php7.4Action:distDocker
./gradlew core:php7.3Action:distDocker
-./gradlew core:php7.2Action:distDocker
```
-This will produce the images `whisk/action-php-v7.4`, `whisk/action-php-v7.3`
& `whisk/action-php-v7.2` respectively.
+This will produce the images `whisk/action-php-v7.4` & `whisk/action-php-v7.3`
respectively.
Build and Push image
```
docker login
./gradlew core:php7.4Action:distDocker -PdockerImagePrefix=$prefix-user
-PdockerRegistry=docker.io
./gradlew core:php7.3Action:distDocker -PdockerImagePrefix=$prefix-user
-PdockerRegistry=docker.io
-./gradlew core:php7.2Action:distDocker -PdockerImagePrefix=$prefix-user
-PdockerRegistry=docker.io
```
-Deploy OpenWhisk using ansible environment that contains the kinds `php:7.4`,
`php:7.3` & `php:7.2`
+Deploy OpenWhisk using ansible environment that contains the kinds `php:7.4` &
`php:7.3`
Assuming you have OpenWhisk already deploy locally and `OPENWHISK_HOME`
pointing to root directory of OpenWhisk core repository.
Set `ROOTDIR` to the root directory of this repository.
@@ -111,10 +99,6 @@ docker push $user_prefix/action-php-v7.4
docker tag whisk/php7.3Action $user_prefix/action-php-v7.3
docker push $user_prefix/action-php-v7.3
```
-```
-docker tag whisk/php7.2Action $user_prefix/action-php-v7.2
-docker push $user_prefix/action-php-v7.2
-```
Then create the action using your the image from dockerhub
```
diff --git a/core/php7.2Action/CHANGELOG.md b/core/php7.2Action/CHANGELOG.md
deleted file mode 100644
index 0338d41..0000000
--- a/core/php7.2Action/CHANGELOG.md
+++ /dev/null
@@ -1,64 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-## Next Release
- - Update version of PHP to 7.2.34
-
-## Apache 1.15.0
- - Update version of PHP to 7.2.33
-
-## Apache 1.14.0
-Changes:
- - Update version of PHP to 7.2.25
- - Update guzzlehttp/guzzle to 6.5.0
- - Update ramsey/uuid to 3.9.1
- - Support getenv()
- - Support for __OW_ACTION_VERSION (openwhisk/4761)
-
-## Apache 1.13.0-incubating
-Changes:
- - Update version of PHP to 7.2.16
-
-## 1.12.0-incubating
-## 1.0.2
-Changes:
- - Allow /run endpoint to accept more environment variables
[#40](https://github.com/apache/openwhisk-runtime-php/pull/40)
-
-## 1.0.1
-Changes:
- - Disallow re-initialization of function.
-
-## 1.0.0
-Initial release
-
-- Added: PHP: 7.2.6
-- Added: PHP extensions in addition to the standard ones:
- - bcmath
- - curl
- - gd
- - intl
- - mbstring
- - mysqli
- - pdo_mysql
- - pdo_pgsql
- - pdo_sqlite
- - soap
- - zip
-- Added: Composer packages:
- - [guzzlehttp/guzzle](https://packagist.org/packages/guzzlehttp/guzzle):
6.3.3
- - [ramsey/uuid](https://packagist.org/packages/ramsey/uuid): 3.7.3
diff --git a/core/php7.2Action/Dockerfile b/core/php7.2Action/Dockerfile
deleted file mode 100644
index 0156a09..0000000
--- a/core/php7.2Action/Dockerfile
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# 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.
-#
-
-FROM php:7.2.34-alpine
-
-RUN \
- apk update && apk upgrade && \
- # install dependencies
- apk add \
- postgresql-dev \
- icu \
- icu-libs \
- icu-dev \
- freetype-dev \
- libjpeg-turbo-dev \
- libpng-dev \
- libxml2-dev \
- && \
- # install useful PHP extensions
- docker-php-ext-install \
- opcache \
- mysqli \
- pdo_mysql \
- pdo_pgsql \
- intl \
- bcmath \
- zip \
- gd \
- soap
-
-# install composer
-RUN curl -s -f -L -o /tmp/installer.php https://getcomposer.org/installer \
- && php /tmp/installer.php --no-ansi --install-dir=/usr/bin
--filename=composer \
- && composer --ansi --version --no-interaction
-
-# create src directory to store action files
-RUN mkdir -p /action/src
-
-# install Composer dependencies
-COPY composer.json /action
-RUN cd /action && /usr/bin/composer install --no-plugins --no-scripts
--prefer-dist --no-dev -o && rm composer.lock
-
-# copy required files
-COPY router.php /action
-COPY php.ini /usr/local/etc/php
-
-# Run webserver on port 8080
-CMD [ "php", "-S", "0.0.0.0:8080", "/action/router.php" ]
-
diff --git a/core/php7.2Action/build.gradle b/core/php7.2Action/build.gradle
deleted file mode 100644
index c168aa2..0000000
--- a/core/php7.2Action/build.gradle
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
-ext.dockerImageName = 'action-php-v7.2'
-apply from: '../../gradle/docker.gradle'
diff --git a/core/php7.2Action/composer.json b/core/php7.2Action/composer.json
deleted file mode 100644
index 621e25e..0000000
--- a/core/php7.2Action/composer.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "config": {
- "platform": {
- "php": "7.2"
- }
- },
- "require": {
- "guzzlehttp/guzzle": "6.5.0",
- "ramsey/uuid": "3.9.1"
- }
-}
diff --git a/core/php7.2Action/php.ini b/core/php7.2Action/php.ini
deleted file mode 100644
index bee173d..0000000
--- a/core/php7.2Action/php.ini
+++ /dev/null
@@ -1,37 +0,0 @@
-; 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.
-
-[PHP]
-short_open_tag = Off
-output_buffering = Off
-expose_php = Off
-max_execution_time = 0
-memory_limit = -1
-error_reporting = E_ALL
-display_errors = Off
-log_errors = On
-log_errors_max_len = 0
-html_errors = Off
-variables_order = "EGPCS"
-request_order = "GP"
-post_max_size = 0
-enable_dl = Off
-zend.assertions = -1
-
-[opcache]
-opcache.enable=1
-opcache.enable_cli=1
-opcache.max_accelerated_files=7963
-opcache.validate_timestamps=0
diff --git a/core/php7.2Action/router.php b/core/php7.2Action/router.php
deleted file mode 100644
index 78c5108..0000000
--- a/core/php7.2Action/router.php
+++ /dev/null
@@ -1,350 +0,0 @@
-<?php
-/*
- * 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.
- */
-
-/**
- * router.php
- *
- * This file is the API client for the action. The controller POSTs /init to
set up the action and
- * then POSTs to /run to invoke it.
- */
-
-namespace OpenWhiskPhpRuntime;
-
-use RuntimeException;
-use Throwable;
-use ZipArchive;
-
-// set up an output buffer to redirect any script output to stdout, rather
than the default
-// php://output, so that it goes to the logs, not the HTTP client.
-ob_start(function ($data) {
- file_put_contents("php://stdout", $data);
- return '';
-}, 1, PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_FLUSHABLE |
PHP_OUTPUT_HANDLER_REMOVABLE);
-
-// Register a shutdown function so that we can fail gracefully when a fatal
error occurs
-register_shutdown_function(function () {
- $error = error_get_last();
- if ($error && in_array($error["type"], [E_ERROR, E_CORE_ERROR,
E_COMPILE_ERROR, E_USER_ERROR])) {
- $result = ['error' => 'An error occurred running the action.'];
- $body = json_encode((object)$result);
- header('HTTP/1.0 502 Bad Gateway');
- header('Content-Type: application/json');
- header("Content-Length: " . mb_strlen($body));
-
- // write out sentinels as we've finished all log output
- file_put_contents("php://stdout",
"XXX_THE_END_OF_A_WHISK_ACTIVATION_XXX\n");
- file_put_contents("php://stderr",
"XXX_THE_END_OF_A_WHISK_ACTIVATION_XXX\n");
-
- ob_end_clean();
- echo $body;
- exit;
- }
-});
-
-const ACTION_SRC_FILENAME = 'index.php';
-const SRC_DIR = __DIR__ . '/src';
-const ACTION_CONFIG_FILE = __DIR__. '/config.json';
-const ACTION_SRC_FILE = SRC_DIR . '/' . ACTION_SRC_FILENAME;
-const TMP_ZIP_FILE = '/action.zip';
-
-// execute the revelant endpoint
-$result = route($_SERVER['REQUEST_URI']);
-sendResponse($result);
-exit;
-
-/**
- * executes the relevant method for a given URL and return an array of data to
send to the client
- */
-function route(string $uri) : array
-{
- try {
- switch ($uri) {
- case '/init':
- return init();
-
- case '/run':
- $result = run();
- writeSentinels();
- return $result;
-
- default:
- throw new RuntimeException('Unexpected call to ' .
$_SERVER["REQUEST_URI"], 500);
- }
- } catch (Throwable $e) {
- $code = $e->getCode() < 400 ? 500 : $e->getCode();
-
- if ($code != 502) {
- writeTo("php://stdout", 'Error: ' . $e->getMessage());
- }
- writeSentinels();
-
- http_response_code($code);
- return ['error' => $e->getMessage()];
- }
-}
-
-/**
- * Send the response back
- */
-function sendResponse(array $result) : void
-{
- $body = json_encode((object)$result);
- header('Content-Type: application/json');
- header("Content-Length: " . mb_strlen($body));
- ob_end_clean();
- echo $body;
-}
-
-/**
- * Handle the /init endpoint
- *
- * This end point is called once per container creation. It gives us the code
we need
- * to run and the name of the function within that code that's the entry
point. As PHP
- * has a setup/teardown model, we store the function name to a config file for
retrieval
- * in the /run end point.
- *
- * @return array Data to return to the client
- */
-function init() : array
-{
- // check that we haven't already been initialised
- if (file_exists(ACTION_CONFIG_FILE)) {
- 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
- $post = file_get_contents('php://input');
- $data = json_decode($post, true)['value'] ?? [];
-
- $name = $data['name'] ?? ''; // action name
- $main = $data['main'] ?? 'main'; // function to call (default: main)
- $code = trim($data['code'] ?? ''); // source code to run
- $binary = $data['binary'] ?? false; // code is binary?
-
- if (!$code) {
- throw new RuntimeException("Missing main/no code to execute.");
- }
-
- if ($binary) {
- // binary code is a zip file that's been base64 encoded, so unzip it
- unzipString($code, SRC_DIR);
-
- // if the zip file didn't contain a vendor directory, move our vendor
into the src folder
- if (! file_exists(SRC_DIR . '/vendor/autoload.php')) {
- exec('mv ' . escapeshellarg(__DIR__ . '/vendor') . ' ' .
escapeshellarg(SRC_DIR . '/vendor'));
- }
-
- // check that we have the expected action source file
- if (! file_exists(ACTION_SRC_FILE)) {
- throw new RuntimeException('Zipped actions must contain ' .
ACTION_SRC_FILENAME . ' at the root.', 500);
- }
- } else {
- // non-binary code is a text string, so save to disk
- file_put_contents(ACTION_SRC_FILE, $code);
-
- // move vendor folder into the src folder
- exec('mv ' . escapeshellarg(__DIR__ . '/vendor') . ' ' .
escapeshellarg(SRC_DIR . '/vendor'));
- }
-
- // is action file valid PHP? run `php -l` to find out
- list($returnCode, $stdout, $stderr) = runPHP(['-l', '-f',
ACTION_SRC_FILE]);
- if ($returnCode != 0) {
- writeTo("php://stderr", $stderr);
- writeTo("php://stdout", $stdout);
-
- $message = 'PHP syntax error in ' . ($binary ? ACTION_SRC_FILENAME :
'action.');
- throw new RuntimeException($message, 500);
- }
-
- // does the action have the expected function name?
- $testCode = 'require "' . ACTION_SRC_FILE . '"; exit((int)(!
function_exists("' . $main .'")));';
- list($returnCode, $stdout, $stderr) = runPHP(['-r', $testCode]);
- if ($returnCode != 0) {
- writeTo("php://stderr", $stderr);
- writeTo("php://stdout", $stdout);
- throw new RuntimeException("The function $main is missing.");
- }
-
- // write config file for use by /run
- $config = [
- 'file' => ACTION_SRC_FILE,
- 'function' => $main,
- 'name' => $name,
- ];
- file_put_contents(ACTION_CONFIG_FILE, '<?php return ' .
var_export($config, true) . ';');
-
- // reset OPcache
- opcache_reset();
-
- return ["OK" => true];
-}
-
-/**
- * Handle the /run endpoint
- *
- * This end point is called once per action invocation. We load the function
name from
- * the config file and then invoke it. Note that as PHP writes to
php://output, we
- * capture in an output buffer and write the buffer to stdout for the
OpenWhisk logs.
- *
- * @return array Data to return to the client
- */
-function run() : array
-{
- $config = require ACTION_CONFIG_FILE;
- $_actionFile = $config['file'];
- $_functionName = $config['function'];
-
- // Extract the posted data
- $post = json_decode(file_get_contents('php://input'), true);
- if (!is_array($post)) {
- $post = [];
- }
-
- // assign environment variables from the posted data
- foreach (array_keys($post) as $param) {
- if ($param !== "value") {
- $envKeyName = '__OW_' . strtoupper($param);
- $_ENV[$envKeyName] = $post[$param];
- putenv($envKeyName . '=' . $post[$param]);
- }
- }
-
- // extract the function arguments from the posted data's "value" field
- $args = [];
- if (array_key_exists('value', $post) && is_array($post['value'])) {
- $args = $post['value'];
- }
-
- // run the action
- require __DIR__ . '/src/vendor/autoload.php';
- require $_actionFile;
- $result = $_functionName($args);
- if (is_array($result)) {
- return $result;
- } elseif (is_scalar($result)) {
- file_put_contents("php://stderr", 'Result must be an array but has
type "'
- . gettype($result) . '": ' . (string)$result . "\n");
- file_put_contents("php://stdout", 'The action did not return a
dictionary.');
- throw new RuntimeException('The action did not return a dictionary.',
502);
- } elseif (is_object($result)) {
- if (method_exists($result, 'getArrayCopy')) {
- return $result->getArrayCopy();
- } elseif ($result instanceof \stdClass) {
- return (array)$result;
- }
- }
-
- return [];
-}
-
-/**
- * Unzip a base64 encoded string to a directory
- */
-function unzipString(string $b64Data, $dir): void
-{
- file_put_contents(TMP_ZIP_FILE, base64_decode($b64Data));
-
- $zip = new ZipArchive();
- $res = $zip->open(TMP_ZIP_FILE);
- if ($res !== true) {
- $reasons = [
- ZipArchive::ER_EXISTS => "File already exists.",
- ZipArchive::ER_INCONS => "Zip archive inconsistent.",
- ZipArchive::ER_INVAL => "Invalid argument.",
- ZipArchive::ER_MEMORY => "Malloc failure.",
- ZipArchive::ER_NOENT => "No such file.",
- ZipArchive::ER_NOZIP => "Not a zip archive.",
- ZipArchive::ER_OPEN => "Can't open file.",
- ZipArchive::ER_READ => "Read error.",
- ZipArchive::ER_SEEK => "Seek error.",
- ];
- $reason = $reasons[$res] ?? "Unknown error: $res.";
- throw new RuntimeException("Failed to open zip file: $reason", 500);
- }
-
- $res = $zip->extractTo($dir . '/');
- $zip->close();
-}
-
-/**
- * Write the OpenWhisk sentinels to stdout and stderr so that it knows that
we've finished
- * writing data to them.
- *
- * @return void
- */
-function writeSentinels() : void
-{
- // write out sentinels as we've finished all log output
- writeTo("php://stderr", "\nXXX_THE_END_OF_A_WHISK_ACTIVATION_XXX");
- writeTo("php://stdout", "\nXXX_THE_END_OF_A_WHISK_ACTIVATION_XXX");
-}
-
-/**
- * Run the PHP command in a separate process
- *
- * This ensures that if the action causes a fatal error, we can handle it.
- *
- * @param array $args arguments to the PHP executable
- * @param string $stdin stdin to pass to the process
- * @return array array containing [int return code, string stdout
string stderr]
- */
-function runPHP(array $args, string $stdin = '') : array
-{
- $cmd = '/usr/local/bin/php ' . implode(' ', array_map('escapeshellarg',
$args));
-
- $process = proc_open(
- $cmd,
- [
- 0 => ['pipe', 'r'],
- 1 => ['pipe', 'w'],
- 2 => ['pipe', 'w'],
- ],
- $pipes,
- SRC_DIR
- );
-
- // write to the process' stdin
- $bytes = fwrite($pipes[0], $stdin);
- fclose($pipes[0]);
-
- // read the process' stdout
- $stdout = stream_get_contents($pipes[1]);
- fclose($pipes[1]);
-
- // read the process' stderr
- $stderr = stream_get_contents($pipes[2]);
- fclose($pipes[2]);
-
- // close process & get return code
- $returnCode = proc_close($process);
-
- // tidy up paths in any PHP stack traces
- $stderr = str_replace(__DIR__ . '/', '', trim($stderr));
- $stdout = str_replace(__DIR__ . '/', '', trim($stdout));
-
- return [$returnCode, $stdout, $stderr];
-}
-
-function writeTo($pipe, $text)
-{
- if ($text) {
- file_put_contents($pipe, $text . PHP_EOL);
- }
-}
diff --git a/settings.gradle b/settings.gradle
index 08399f6..bc76cec 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -17,7 +17,6 @@
include 'tests'
-include 'core:php7.2Action'
include 'core:php7.3Action'
include 'core:php7.4Action'
diff --git
a/tests/src/test/scala/runtime/actionContainers/Php72ActionContainerTests.scala
b/tests/src/test/scala/runtime/actionContainers/Php72ActionContainerTests.scala
deleted file mode 100644
index 80897cc..0000000
---
a/tests/src/test/scala/runtime/actionContainers/Php72ActionContainerTests.scala
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.
- */
-
-package runtime.actionContainers
-
-import org.junit.runner.RunWith
-import org.scalatest.junit.JUnitRunner
-import actionContainers.ResourceHelpers.ZipBuilder
-import spray.json._
-
-@RunWith(classOf[JUnitRunner])
-class Php72ActionContainerTests extends Php7ActionContainerTests {
-
- override lazy val phpContainerImageName = "action-php-v7.2"
-
- it should "fail to initialize with bad code" in {
- val (out, err) = withPhp7Container { c =>
- val code = """
- |<?php
- | 10 PRINT "Hello world!"
- | 20 GOTO 10
- """.stripMargin
-
- 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("PHP syntax error")
- }
-
- // Somewhere, the logs should mention an error occurred.
- checkStreams(out, err, {
- case (o, e) =>
- (o + e).toLowerCase should include("error")
- (o + e).toLowerCase should include("syntax")
- })
- }
-
- it should "fail gracefully on invalid zip files" in {
- // Some text-file encoded to base64.
- val code = "Q2VjaSBuJ2VzdCBwYXMgdW4gemlwLgo="
-
- val (out, err) = withPhp7Container { c =>
- 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("Failed to open zip
file")
- }
-
- // Somewhere, the logs should mention the failure
- checkStreams(out, err, {
- case (o, e) =>
- (o + e).toLowerCase should include("error")
- (o + e).toLowerCase should include("failed to open zip file")
- })
- }
-
- it should "fail gracefully on valid zip files that are not actions" in {
- val srcs = Seq(Seq("hello") -> """
- | Hello world!
- """.stripMargin)
-
- val code = ZipBuilder.mkBase64Zip(srcs)
-
- val (out, err) = withPhp7Container { c =>
- c.init(initPayload(code))._1 should not be (200)
- }
-
- checkStreams(out, err, {
- case (o, e) =>
- (o + e).toLowerCase should include("error")
- (o + e).toLowerCase should include("zipped actions must contain
index.php at the root.")
- })
- }
-
- it should "fail gracefully on valid zip files with invalid code in
index.php" in {
- val (out, err) = withPhp7Container { c =>
- val srcs = Seq(Seq("index.php") -> """
- | <?php
- | 10 PRINT "Hello world!"
- | 20 GOTO 10
- """.stripMargin)
-
- val code = ZipBuilder.mkBase64Zip(srcs)
-
- 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("PHP syntax error in
index.php")
- }
-
- // Somewhere, the logs should mention an error occurred.
- checkStreams(out, err, {
- case (o, e) =>
- (o + e).toLowerCase should include("error")
- (o + e).toLowerCase should include("syntax")
- })
- }
-}