diff --git a/functions/tips_preload/.gcloudignore b/functions/tips_preload/.gcloudignore new file mode 100644 index 0000000000..d65708d3b0 --- /dev/null +++ b/functions/tips_preload/.gcloudignore @@ -0,0 +1,15 @@ +# The .gcloudignore file excludes file from upload to Cloud Build. +# If this file is deleted, gcloud will default to .gitignore. +# +# https://cloud.google.com/cloud-build/docs/speeding-up-builds#gcloudignore +# https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore + +# Exclude our local tests +test/ + +# Exclude locally vendored dependencies. +vendor/ + +# Exclude git history and configuration. +.git/ +.gitignore diff --git a/functions/tips_preload/ClassToPreload.php b/functions/tips_preload/ClassToPreload.php new file mode 100644 index 0000000000..3483dfd946 --- /dev/null +++ b/functions/tips_preload/ClassToPreload.php @@ -0,0 +1,28 @@ + + + + + + test + + + + + + + + . + + ./vendor + + + + diff --git a/functions/tips_preload/preload.php b/functions/tips_preload/preload.php new file mode 100644 index 0000000000..d06039c4b4 --- /dev/null +++ b/functions/tips_preload/preload.php @@ -0,0 +1,13 @@ + $file) { + require_once $file; +} diff --git a/functions/tips_preload/test/DeployTest.php b/functions/tips_preload/test/DeployTest.php new file mode 100644 index 0000000000..334233de1c --- /dev/null +++ b/functions/tips_preload/test/DeployTest.php @@ -0,0 +1,52 @@ +client->post('', [ + // Uncomment and CURLOPT_VERBOSE debug content will be sent to stdout. + // 'debug' => true + ]); + + $output = trim((string) $resp->getBody()); + + $this->assertEquals('200', $resp->getStatusCode()); + $this->assertStringContainsString('Class is preloaded: true', $output); + } +} diff --git a/functions/tips_preload/test/IntegrationTest.php b/functions/tips_preload/test/IntegrationTest.php new file mode 100644 index 0000000000..c12b29440e --- /dev/null +++ b/functions/tips_preload/test/IntegrationTest.php @@ -0,0 +1,52 @@ +client->get('/'); + $output = trim((string) $resp->getBody()); + + $this->assertEquals('200', $resp->getStatusCode()); + $this->assertStringContainsString('Class is preloaded: true', $output); + } + + private static function doRun() + { + $phpBin = (new PhpExecutableFinder())->find(); + + // add opcache.preload ini + $phpBin .= ' -d opcache.preload=preload.php'; + + return self::$fn->run([], '8080', $phpBin); + } +}