diff --git a/cloudbuild-test-runner/.gcloudignore b/cloudbuild-test-runner/.gcloudignore new file mode 100644 index 00000000..c0f7db2e --- /dev/null +++ b/cloudbuild-test-runner/.gcloudignore @@ -0,0 +1 @@ +# Empty gcloudignore diff --git a/cloudbuild-test-runner/Dockerfile.in b/cloudbuild-test-runner/Dockerfile.in index d7598b4e..8e9a96d0 100644 --- a/cloudbuild-test-runner/Dockerfile.in +++ b/cloudbuild-test-runner/Dockerfile.in @@ -14,7 +14,7 @@ # Dockerfile for running phpunit within a cloudbuild step. -FROM ${PHP_56_IMAGE} +FROM ${TEST_RUNNER_BASE_IMAGE} RUN mkdir -p /opt/bin ENV PATH=${PATH}:/usr/local/bin:/opt/gcloud/google-cloud-sdk/bin diff --git a/perf-dashboard/deployment-latency/tests/CollectDeploymentLatencyTest.php b/perf-dashboard/deployment-latency/tests/CollectDeploymentLatencyTest.php index 94b255bf..0e1771be 100644 --- a/perf-dashboard/deployment-latency/tests/CollectDeploymentLatencyTest.php +++ b/perf-dashboard/deployment-latency/tests/CollectDeploymentLatencyTest.php @@ -42,14 +42,13 @@ private static function createApp($phpVersion) copy(__DIR__ . '/files/app.yaml', $tempDir . '/app.yaml'); copy(__DIR__ . '/files/web/index.php', $tempDir . '/web/index.php'); chdir($tempDir); - self::execWithError( - 'composer require google/cloud', - 'composer require google/cloud' - ); - self::execWithError( - 'composer --ignore-platform-reqs require php:' . $phpVersion . '.*', - 'composer require php' - ); + $composerJSON = [ + 'require' => [ + 'php' => $phpVersion . '.*', + 'google/cloud' => '*' + ] + ]; + file_put_contents('composer.json', json_encode($composerJSON)); return $tempDir; } @@ -58,49 +57,66 @@ public function testDeploymentLatency() $phpVersions = [ '5.6', '7.0', - '7.1' + '7.1', + '7.2' ]; $types = [ - 'xrt', - 'builder' + 'debian8', + 'ubuntu16' ]; $gcloudTrack = getenv('GCLOUD_TRACK') === 'beta' ? 'beta' : ''; foreach ($phpVersions as $phpVersion) { - $dir = self::createApp($phpVersion); - chdir($dir); foreach ($types as $type) { - $reportName = sprintf('%s-%s', $type, $phpVersion); - $failureCount = 0; - $command = 'gcloud -q ' . $gcloudTrack . ' app deploy' - . ' --version ' - . str_replace('.', '', $reportName) - . ' --no-stop-previous-version --no-promote'; - $configCmd = 'gcloud config set app/use_runtime_builders ' - . ($type === 'xrt' ? 'false' : 'true'); - self::execWithError($configCmd, 'runtime-builders-config'); - $latency = 0.0; - while ($failureCount < self::DEPLOYMENT_MAX_RETRY) { - $start = microtime(true); - $ret = self::execWithResult($command); - if ($ret === 0) { - $latency = microtime(true) - $start; - break; + $dir = self::createApp($phpVersion); + chdir($dir); + try { + $reportName = sprintf('%s-%s', $type, $phpVersion); + $failureCount = 0; + $command = 'gcloud -q ' . $gcloudTrack . ' app deploy' + . ' --version ' + . str_replace('.', '', $reportName) + . ' --no-stop-previous-version --no-promote'; + $configCmd = 'gcloud config set app/use_runtime_builders true'; + self::execWithError($configCmd, 'runtime-builders-config'); + $f = fopen('app.yaml', 'a+'); + fwrite($f, " base_os: $type\n"); + $latency = 0.0; + while ($failureCount < self::DEPLOYMENT_MAX_RETRY) { + $start = microtime(true); + $ret = self::execWithResult($command); + if ($ret === 0) { + $latency = microtime(true) - $start; + break; + } + $failureCount++; + } + self::$bigQuery = self::createBigQueryClient(); + $dataset = self::$bigQuery->dataset(self::DATASET_ID); + $table = $dataset->table(self::TABLE_ID); + $timestamp = self::$bigQuery->timestamp(new \DateTime()); + $row = [ + 'deployment_latency_seconds' => $latency, + 'report_name' => $reportName, + 'failure_count' => $failureCount, + 't' => $timestamp + ]; + $table->insertRow($row); + echo "Inserted: $reportName failure: $failureCount" . PHP_EOL; + echo "Inserted: $reportName latency: $latency" . PHP_EOL; + } finally { + $command = 'gcloud -q ' . $gcloudTrack . ' app versions delete ' + . str_replace('.', '', $reportName); + $failureCount = 0; + while ($failureCount < self::DEPLOYMENT_MAX_RETRY) { + $start = microtime(true); + $ret = self::execWithResult($command); + if ($ret === 0) { + break; + } + $failureCount++; } - $failureCount++; + exec("rm -rf $dir"); } - self::$bigQuery = self::createBigQueryClient(); - $dataset = self::$bigQuery->dataset(self::DATASET_ID); - $table = $dataset->table(self::TABLE_ID); - $timestamp = self::$bigQuery->timestamp(new \DateTime()); - $row = [ - 'deployment_latency_seconds' => $latency, - 'report_name' => $reportName, - 'failure_count' => $failureCount, - 't' => $timestamp - ]; - $table->insertRow($row); - echo "Inserted: $reportName failure: $failureCount" . PHP_EOL; - echo "Inserted: $reportName latency: $latency" . PHP_EOL; } } } diff --git a/scripts/build_images.sh b/scripts/build_images.sh index 7bd8d8a0..ada30839 100755 --- a/scripts/build_images.sh +++ b/scripts/build_images.sh @@ -42,6 +42,7 @@ export BASE_IMAGE="gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_PREFIX}php:${TAG}" export PHP_56_IMAGE="gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_PREFIX}php56:${TAG}" export PHP_71_IMAGE="gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_PREFIX}php71:${TAG}" export PHP_72_IMAGE="gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_PREFIX}php71:${TAG}" +export TEST_RUNNER_BASE_IMAGE=${PHP_56_IMAGE} if [ -z "${RUNTIME_DISTRIBUTION}" ]; then RUNTIME_DISTRIBUTION="${DEFAULT_RUNTIME_DISTRIBUTION}" @@ -51,7 +52,7 @@ export RUNTIME_DISTRIBUTION for TEMPLATE in `find . -name Dockerfile.in` do - envsubst '${BASE_IMAGE} ${PHP_BASE_IMAGE} ${PHP_71_IMAGE} ${PHP_56_IMAGE} ${PHP_72_IMAGE}' \ + envsubst '${BASE_IMAGE} ${PHP_BASE_IMAGE} ${PHP_71_IMAGE} ${PHP_56_IMAGE} ${PHP_72_IMAGE} ${TEST_RUNNER_BASE_IMAGE}' \ < ${TEMPLATE} \ > $(dirname ${TEMPLATE})/$(basename -s .in ${TEMPLATE}) done diff --git a/scripts/check_versions.sh b/scripts/check_versions.sh index ef75f3f8..cead6728 100755 --- a/scripts/check_versions.sh +++ b/scripts/check_versions.sh @@ -29,8 +29,8 @@ gcloud auth activate-service-account \ SRC_TMP=$(mktemp -d) # build the php test runner -export PHP_56_IMAGE="gcr.io/google-appengine/php56:latest" -envsubst '${PHP_56_IMAGE}' \ +export TEST_RUNNER_BASE_IMAGE="gcr.io/google-appengine/php56:latest" +envsubst '${TEST_RUNNER_BASE_IMAGE}' \ < cloudbuild-test-runner/Dockerfile.in \ > cloudbuild-test-runner/Dockerfile diff --git a/scripts/record_deployment_latency.sh b/scripts/record_deployment_latency.sh index 40e958c6..c93dcd18 100755 --- a/scripts/record_deployment_latency.sh +++ b/scripts/record_deployment_latency.sh @@ -32,8 +32,8 @@ TEST_RUNNER="gcr.io/${GOOGLE_PROJECT_ID}/php-test-runner:${TAG}" if [ -n "${REBUILD_TEST_RUNNER}" ]; then # build the php test runner - export PHP_56_IMAGE="gcr.io/google-appengine/php56:latest" - envsubst '${PHP_56_IMAGE}' \ + export TEST_RUNNER_BASE_IMAGE="gcr.io/google-appengine/ubuntu-php72:latest" + envsubst '${TEST_RUNNER_BASE_IMAGE}' \ < cloudbuild-test-runner/Dockerfile.in \ > cloudbuild-test-runner/Dockerfile gcloud -q container builds submit --tag "${TEST_RUNNER}" \ diff --git a/scripts/run_acceptance_tests.sh b/scripts/run_acceptance_tests.sh index d7016144..bec1df63 100755 --- a/scripts/run_acceptance_tests.sh +++ b/scripts/run_acceptance_tests.sh @@ -34,6 +34,7 @@ fi export PHP_BASE_IMAGE="gcr.io/google-appengine/php-base" export BASE_IMAGE="gcr.io/google-appengine/php" export PHP_56_IMAGE="gcr.io/google-appengine/php56" +export TEST_RUNNER_BASE_IMAGE=${PHP_56_IMAGE} for TEMPLATE in `find . -name Dockerfile.in` do