From 77dff6fefd2e7afbcb29140a93859ae8db269ee7 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Thu, 31 May 2018 11:58:20 -0700 Subject: [PATCH] Restore default installed extensions/packages to ubuntu base (#445) * Restore default installed extensions/packages to ubuntu base * Add test for installing via legacy php.ini method * Fix legacy extensions test directory --- cloudbuild-ubuntu.yaml | 12 ++++ testapps/php72_extensions_legacy/.gitignore | 1 + .../php72_extensions_legacy/Dockerfile.in | 15 +++++ .../php72_extensions_legacy/composer.json | 44 +++++++++++++ testapps/php72_extensions_legacy/php.ini | 13 ++++ .../php72_extensions_legacy/phpunit.xml.dist | 8 +++ .../tests/Blank300.png | Bin 0 -> 178 bytes .../tests/CassandraTest.php | 27 ++++++++ .../php72_extensions_legacy/tests/EvTest.php | 43 +++++++++++++ .../tests/EventTest.php | 27 ++++++++ .../tests/ExtensionsLoadedTest.php | 60 ++++++++++++++++++ .../php72_extensions_legacy/tests/GdTest.php | 33 ++++++++++ .../php72_extensions_legacy/tests/GmpTest.php | 34 ++++++++++ .../tests/ImagickTest.php | 35 ++++++++++ .../tests/LibSodiumTest.php | 32 ++++++++++ .../tests/OauthTest.php | 27 ++++++++ .../tests/PhalconTest.php | 28 ++++++++ .../tests/ProtobufTest.php | 27 ++++++++ .../tests/RdkafkaTest.php | 27 ++++++++ .../tests/bootstrap.php | 17 +++++ .../build-scripts/install_php56.sh | 12 ++++ .../build-scripts/install_php70.sh | 16 ++++- .../build-scripts/install_php71.sh | 15 ++++- .../build-scripts/install_php72.sh | 15 ++++- .../build-scripts/src/InstallExtensions.php | 37 +++++------ 25 files changed, 584 insertions(+), 21 deletions(-) create mode 100644 testapps/php72_extensions_legacy/.gitignore create mode 100644 testapps/php72_extensions_legacy/Dockerfile.in create mode 100644 testapps/php72_extensions_legacy/composer.json create mode 100644 testapps/php72_extensions_legacy/php.ini create mode 100644 testapps/php72_extensions_legacy/phpunit.xml.dist create mode 100644 testapps/php72_extensions_legacy/tests/Blank300.png create mode 100644 testapps/php72_extensions_legacy/tests/CassandraTest.php create mode 100644 testapps/php72_extensions_legacy/tests/EvTest.php create mode 100644 testapps/php72_extensions_legacy/tests/EventTest.php create mode 100644 testapps/php72_extensions_legacy/tests/ExtensionsLoadedTest.php create mode 100644 testapps/php72_extensions_legacy/tests/GdTest.php create mode 100644 testapps/php72_extensions_legacy/tests/GmpTest.php create mode 100644 testapps/php72_extensions_legacy/tests/ImagickTest.php create mode 100644 testapps/php72_extensions_legacy/tests/LibSodiumTest.php create mode 100644 testapps/php72_extensions_legacy/tests/OauthTest.php create mode 100644 testapps/php72_extensions_legacy/tests/PhalconTest.php create mode 100644 testapps/php72_extensions_legacy/tests/ProtobufTest.php create mode 100644 testapps/php72_extensions_legacy/tests/RdkafkaTest.php create mode 100644 testapps/php72_extensions_legacy/tests/bootstrap.php diff --git a/cloudbuild-ubuntu.yaml b/cloudbuild-ubuntu.yaml index 42552453..355e2b10 100644 --- a/cloudbuild-ubuntu.yaml +++ b/cloudbuild-ubuntu.yaml @@ -262,6 +262,18 @@ steps: waitFor: ['php72-extensions-build'] id: php72-extensions-test + # php72-extensions-legacy test + - name: gcr.io/cloud-builders/docker + args: ['build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php72-extensions:$_TAG', '.'] + dir: testapps/php72_extensions_legacy + waitFor: ['php-onbuild'] + id: php72-extensions-legacy-build + - name: gcr.io/cloud-builders/docker + args: ['run', 'gcr.io/${_GOOGLE_PROJECT_ID}/php72-extensions:$_TAG', 'vendor/bin/phpunit'] + dir: testapps/php72_extensions_legacy + waitFor: ['php72-extensions-build'] + id: php72-extensions-legacy-test + images: - gcr.io/${_GOOGLE_PROJECT_ID}/ubuntu-php-base:$_TAG - gcr.io/${_GOOGLE_PROJECT_ID}/ubuntu-php:$_TAG diff --git a/testapps/php72_extensions_legacy/.gitignore b/testapps/php72_extensions_legacy/.gitignore new file mode 100644 index 00000000..94143827 --- /dev/null +++ b/testapps/php72_extensions_legacy/.gitignore @@ -0,0 +1 @@ +Dockerfile diff --git a/testapps/php72_extensions_legacy/Dockerfile.in b/testapps/php72_extensions_legacy/Dockerfile.in new file mode 100644 index 00000000..6e73ea21 --- /dev/null +++ b/testapps/php72_extensions_legacy/Dockerfile.in @@ -0,0 +1,15 @@ +# Copyright 2017 Google Inc. +# +# Licensed 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 ${BASE_IMAGE} diff --git a/testapps/php72_extensions_legacy/composer.json b/testapps/php72_extensions_legacy/composer.json new file mode 100644 index 00000000..d6db0966 --- /dev/null +++ b/testapps/php72_extensions_legacy/composer.json @@ -0,0 +1,44 @@ +{ + "require": { + "php": "7.2.*", + "phpunit/phpunit": "^4.8.35", + "ext-amqp": "*", + "ext-apm": "*", + "ext-bcmath": "*", + "ext-calendar": "*", + "ext-couchbase": "*", + "ext-ds": "*", + "ext-eio": "*", + "ext-exif": "*", + "ext-ftp": "*", + "ext-gd": "*", + "ext-gettext": "*", + "ext-hprose": "*", + "ext-intl": "*", + "ext-jsond": "*", + "ext-krb5": "*", + "ext-lua": "*", + "ext-lzf": "*", + "ext-memprof": "*", + "ext-pdo_sqlite": "*", + "ext-seaslog": "*", + "ext-shmop": "*", + "ext-soap": "*", + "ext-sqlite3": "*", + "ext-stomp": "*", + "ext-swoole": "*", + "ext-sync": "*", + "ext-tcpwrap": "*", + "ext-timezonedb": "*", + "ext-v8js": "*", + "ext-vips": "*", + "ext-yaconf": "*", + "ext-yaf": "*", + "ext-yaml": "*", + "ext-xmlrpc": "*", + "ext-xsl": "*", + "ext-bitset": "*", + "ext-igbinary": "*", + "ext-iconv": "*" + } +} diff --git a/testapps/php72_extensions_legacy/php.ini b/testapps/php72_extensions_legacy/php.ini new file mode 100644 index 00000000..188e7335 --- /dev/null +++ b/testapps/php72_extensions_legacy/php.ini @@ -0,0 +1,13 @@ +extension=cassandra.so +extension=ev.so +extension=event.so +extension=grpc.so +extension=imagick.so +extension=mongodb.so +extension=oauth.so +extension=opencensus.so +extension=pq.so +extension=protobuf.so +extension=rdkafka.so +extension=redis.so +extension=stackdriver_debugger.so \ No newline at end of file diff --git a/testapps/php72_extensions_legacy/phpunit.xml.dist b/testapps/php72_extensions_legacy/phpunit.xml.dist new file mode 100644 index 00000000..8ded8984 --- /dev/null +++ b/testapps/php72_extensions_legacy/phpunit.xml.dist @@ -0,0 +1,8 @@ + + + + + tests + + + diff --git a/testapps/php72_extensions_legacy/tests/Blank300.png b/testapps/php72_extensions_legacy/tests/Blank300.png new file mode 100644 index 0000000000000000000000000000000000000000..e96fe466c1a8cd40d54a80844880b78f7137bf04 GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0y~yVAKJ!89CU1WQxUPO(4aV|H(?D8gCb z5n0T@z%2~Ij105pNB{-dOFVsD*{^c5h_NtFjy?r4K(@p+qQp5rH#aq}gu%HeHL)Z$ zMWH;iBts!2BUQoO(>LIKifSHEp_r$OV@SoVassertTrue(extension_loaded('cassandra')); + } +} diff --git a/testapps/php72_extensions_legacy/tests/EvTest.php b/testapps/php72_extensions_legacy/tests/EvTest.php new file mode 100644 index 00000000..cd556d33 --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/EvTest.php @@ -0,0 +1,43 @@ +assertTrue(extension_loaded('ev')); + } + + public function testTimer() + { + // after 5ms, update success + $w1 = new EvTimer(0.005, 0, function () { + $this->success = true; + }); + Ev::run(); + + // sleep 10ms + usleep(10000); + + Ev::stop(); + + $this->assertTrue($this->success); + } +} diff --git a/testapps/php72_extensions_legacy/tests/EventTest.php b/testapps/php72_extensions_legacy/tests/EventTest.php new file mode 100644 index 00000000..1fe6535f --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/EventTest.php @@ -0,0 +1,27 @@ +assertTrue(extension_loaded('event')); + } +} diff --git a/testapps/php72_extensions_legacy/tests/ExtensionsLoadedTest.php b/testapps/php72_extensions_legacy/tests/ExtensionsLoadedTest.php new file mode 100644 index 00000000..9521a9bb --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/ExtensionsLoadedTest.php @@ -0,0 +1,60 @@ +assertTrue(extension_loaded($extensionName)); + } + + public function extensions() + { + return [ + ['amqp'], + ['apm'], + ['bitset'], + ['couchbase'], + ['ds'], + ['eio'], + ['hprose'], + ['igbinary'], + ['jsond'], + ['krb5'], + ['lua'], + ['lzf'], + ['memprof'], + ['opencensus'], + ['seaslog'], + ['stackdriver_debugger'], + ['stomp'], + ['swoole'], + ['sync'], + ['tcpwrap'], + ['timezonedb'], + ['v8js'], + ['vips'], + ['yaconf'], + ['yaf'], + ['yaml'] + ]; + } +} diff --git a/testapps/php72_extensions_legacy/tests/GdTest.php b/testapps/php72_extensions_legacy/tests/GdTest.php new file mode 100644 index 00000000..c663b508 --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/GdTest.php @@ -0,0 +1,33 @@ +assertTrue(extension_loaded('gd')); + } + + public function testFreetypeSupport() + { + $this->assertTrue( + gd_info()['FreeType Support'], + 'GD should support Freetype' + ); + } +} diff --git a/testapps/php72_extensions_legacy/tests/GmpTest.php b/testapps/php72_extensions_legacy/tests/GmpTest.php new file mode 100644 index 00000000..ed7e0821 --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/GmpTest.php @@ -0,0 +1,34 @@ +assertTrue(extension_loaded('gmp')); + } + + public function testGcd() + { + // basic test for greatest common denominator to see if gmp works + $this->assertEquals( + 3, + gmp_intval(gmp_gcd("12", "21")) + ); + } +} diff --git a/testapps/php72_extensions_legacy/tests/ImagickTest.php b/testapps/php72_extensions_legacy/tests/ImagickTest.php new file mode 100644 index 00000000..4670b141 --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/ImagickTest.php @@ -0,0 +1,35 @@ +assertTrue(extension_loaded('imagick')); + } + + public function testLoadImage() + { + $image = new Imagick(__DIR__ . '/Blank300.png'); + $dimensions = $image->getImageGeometry(); + $this->assertEquals(300, $dimensions['width']); + $this->assertEquals(1, $dimensions['height']); + } +} diff --git a/testapps/php72_extensions_legacy/tests/LibSodiumTest.php b/testapps/php72_extensions_legacy/tests/LibSodiumTest.php new file mode 100644 index 00000000..9f2ac230 --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/LibSodiumTest.php @@ -0,0 +1,32 @@ +assertTrue(extension_loaded('sodium')); + } + + public function testLoadImage() + { + $re = new ReflectionExtension('sodium'); + $libsodiumVersion = $re->getVersion(); + $this->assertTrue(version_compare($libsodiumVersion, '2.0.0', '>=')); + } +} diff --git a/testapps/php72_extensions_legacy/tests/OauthTest.php b/testapps/php72_extensions_legacy/tests/OauthTest.php new file mode 100644 index 00000000..f0fa2572 --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/OauthTest.php @@ -0,0 +1,27 @@ +assertTrue(extension_loaded('oauth')); + } +} diff --git a/testapps/php72_extensions_legacy/tests/PhalconTest.php b/testapps/php72_extensions_legacy/tests/PhalconTest.php new file mode 100644 index 00000000..84ed26d1 --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/PhalconTest.php @@ -0,0 +1,28 @@ +markTestSkipped('Phalcon is not available for PHP 7.1 yet.'); + // $this->assertTrue(extension_loaded('phalcon')); + } +} diff --git a/testapps/php72_extensions_legacy/tests/ProtobufTest.php b/testapps/php72_extensions_legacy/tests/ProtobufTest.php new file mode 100644 index 00000000..0d9606e5 --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/ProtobufTest.php @@ -0,0 +1,27 @@ +assertTrue(extension_loaded('protobuf')); + } +} diff --git a/testapps/php72_extensions_legacy/tests/RdkafkaTest.php b/testapps/php72_extensions_legacy/tests/RdkafkaTest.php new file mode 100644 index 00000000..2e522a4e --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/RdkafkaTest.php @@ -0,0 +1,27 @@ +assertTrue(extension_loaded('rdkafka')); + } +} diff --git a/testapps/php72_extensions_legacy/tests/bootstrap.php b/testapps/php72_extensions_legacy/tests/bootstrap.php new file mode 100644 index 00000000..f76545c7 --- /dev/null +++ b/testapps/php72_extensions_legacy/tests/bootstrap.php @@ -0,0 +1,17 @@ +