Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Commit 6ca8575

Browse files
author
Takashi Matsuo
authored
Record deployment latency for both ubuntu16 and debian8 images (#441)
1 parent 700aeac commit 6ca8575

File tree

7 files changed

+68
-49
lines changed

7 files changed

+68
-49
lines changed

cloudbuild-test-runner/.gcloudignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty gcloudignore

cloudbuild-test-runner/Dockerfile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Dockerfile for running phpunit within a cloudbuild step.
1616

17-
FROM ${PHP_56_IMAGE}
17+
FROM ${TEST_RUNNER_BASE_IMAGE}
1818

1919
RUN mkdir -p /opt/bin
2020
ENV PATH=${PATH}:/usr/local/bin:/opt/gcloud/google-cloud-sdk/bin

perf-dashboard/deployment-latency/tests/CollectDeploymentLatencyTest.php

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ private static function createApp($phpVersion)
4242
copy(__DIR__ . '/files/app.yaml', $tempDir . '/app.yaml');
4343
copy(__DIR__ . '/files/web/index.php', $tempDir . '/web/index.php');
4444
chdir($tempDir);
45-
self::execWithError(
46-
'composer require google/cloud',
47-
'composer require google/cloud'
48-
);
49-
self::execWithError(
50-
'composer --ignore-platform-reqs require php:' . $phpVersion . '.*',
51-
'composer require php'
52-
);
45+
$composerJSON = [
46+
'require' => [
47+
'php' => $phpVersion . '.*',
48+
'google/cloud' => '*'
49+
]
50+
];
51+
file_put_contents('composer.json', json_encode($composerJSON));
5352
return $tempDir;
5453
}
5554

@@ -58,49 +57,66 @@ public function testDeploymentLatency()
5857
$phpVersions = [
5958
'5.6',
6059
'7.0',
61-
'7.1'
60+
'7.1',
61+
'7.2'
6262
];
6363
$types = [
64-
'xrt',
65-
'builder'
64+
'debian8',
65+
'ubuntu16'
6666
];
6767
$gcloudTrack = getenv('GCLOUD_TRACK') === 'beta' ? 'beta' : '';
6868
foreach ($phpVersions as $phpVersion) {
69-
$dir = self::createApp($phpVersion);
70-
chdir($dir);
7169
foreach ($types as $type) {
72-
$reportName = sprintf('%s-%s', $type, $phpVersion);
73-
$failureCount = 0;
74-
$command = 'gcloud -q ' . $gcloudTrack . ' app deploy'
75-
. ' --version '
76-
. str_replace('.', '', $reportName)
77-
. ' --no-stop-previous-version --no-promote';
78-
$configCmd = 'gcloud config set app/use_runtime_builders '
79-
. ($type === 'xrt' ? 'false' : 'true');
80-
self::execWithError($configCmd, 'runtime-builders-config');
81-
$latency = 0.0;
82-
while ($failureCount < self::DEPLOYMENT_MAX_RETRY) {
83-
$start = microtime(true);
84-
$ret = self::execWithResult($command);
85-
if ($ret === 0) {
86-
$latency = microtime(true) - $start;
87-
break;
70+
$dir = self::createApp($phpVersion);
71+
chdir($dir);
72+
try {
73+
$reportName = sprintf('%s-%s', $type, $phpVersion);
74+
$failureCount = 0;
75+
$command = 'gcloud -q ' . $gcloudTrack . ' app deploy'
76+
. ' --version '
77+
. str_replace('.', '', $reportName)
78+
. ' --no-stop-previous-version --no-promote';
79+
$configCmd = 'gcloud config set app/use_runtime_builders true';
80+
self::execWithError($configCmd, 'runtime-builders-config');
81+
$f = fopen('app.yaml', 'a+');
82+
fwrite($f, " base_os: $type\n");
83+
$latency = 0.0;
84+
while ($failureCount < self::DEPLOYMENT_MAX_RETRY) {
85+
$start = microtime(true);
86+
$ret = self::execWithResult($command);
87+
if ($ret === 0) {
88+
$latency = microtime(true) - $start;
89+
break;
90+
}
91+
$failureCount++;
92+
}
93+
self::$bigQuery = self::createBigQueryClient();
94+
$dataset = self::$bigQuery->dataset(self::DATASET_ID);
95+
$table = $dataset->table(self::TABLE_ID);
96+
$timestamp = self::$bigQuery->timestamp(new \DateTime());
97+
$row = [
98+
'deployment_latency_seconds' => $latency,
99+
'report_name' => $reportName,
100+
'failure_count' => $failureCount,
101+
't' => $timestamp
102+
];
103+
$table->insertRow($row);
104+
echo "Inserted: $reportName failure: $failureCount" . PHP_EOL;
105+
echo "Inserted: $reportName latency: $latency" . PHP_EOL;
106+
} finally {
107+
$command = 'gcloud -q ' . $gcloudTrack . ' app versions delete '
108+
. str_replace('.', '', $reportName);
109+
$failureCount = 0;
110+
while ($failureCount < self::DEPLOYMENT_MAX_RETRY) {
111+
$start = microtime(true);
112+
$ret = self::execWithResult($command);
113+
if ($ret === 0) {
114+
break;
115+
}
116+
$failureCount++;
88117
}
89-
$failureCount++;
118+
exec("rm -rf $dir");
90119
}
91-
self::$bigQuery = self::createBigQueryClient();
92-
$dataset = self::$bigQuery->dataset(self::DATASET_ID);
93-
$table = $dataset->table(self::TABLE_ID);
94-
$timestamp = self::$bigQuery->timestamp(new \DateTime());
95-
$row = [
96-
'deployment_latency_seconds' => $latency,
97-
'report_name' => $reportName,
98-
'failure_count' => $failureCount,
99-
't' => $timestamp
100-
];
101-
$table->insertRow($row);
102-
echo "Inserted: $reportName failure: $failureCount" . PHP_EOL;
103-
echo "Inserted: $reportName latency: $latency" . PHP_EOL;
104120
}
105121
}
106122
}

scripts/build_images.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export BASE_IMAGE="gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_PREFIX}php:${TAG}"
4242
export PHP_56_IMAGE="gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_PREFIX}php56:${TAG}"
4343
export PHP_71_IMAGE="gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_PREFIX}php71:${TAG}"
4444
export PHP_72_IMAGE="gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_PREFIX}php71:${TAG}"
45+
export TEST_RUNNER_BASE_IMAGE=${PHP_56_IMAGE}
4546

4647
if [ -z "${RUNTIME_DISTRIBUTION}" ]; then
4748
RUNTIME_DISTRIBUTION="${DEFAULT_RUNTIME_DISTRIBUTION}"
@@ -51,7 +52,7 @@ export RUNTIME_DISTRIBUTION
5152

5253
for TEMPLATE in `find . -name Dockerfile.in`
5354
do
54-
envsubst '${BASE_IMAGE} ${PHP_BASE_IMAGE} ${PHP_71_IMAGE} ${PHP_56_IMAGE} ${PHP_72_IMAGE}' \
55+
envsubst '${BASE_IMAGE} ${PHP_BASE_IMAGE} ${PHP_71_IMAGE} ${PHP_56_IMAGE} ${PHP_72_IMAGE} ${TEST_RUNNER_BASE_IMAGE}' \
5556
< ${TEMPLATE} \
5657
> $(dirname ${TEMPLATE})/$(basename -s .in ${TEMPLATE})
5758
done

scripts/check_versions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ gcloud auth activate-service-account \
2929
SRC_TMP=$(mktemp -d)
3030

3131
# build the php test runner
32-
export PHP_56_IMAGE="gcr.io/google-appengine/php56:latest"
33-
envsubst '${PHP_56_IMAGE}' \
32+
export TEST_RUNNER_BASE_IMAGE="gcr.io/google-appengine/php56:latest"
33+
envsubst '${TEST_RUNNER_BASE_IMAGE}' \
3434
< cloudbuild-test-runner/Dockerfile.in \
3535
> cloudbuild-test-runner/Dockerfile
3636

scripts/record_deployment_latency.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ TEST_RUNNER="gcr.io/${GOOGLE_PROJECT_ID}/php-test-runner:${TAG}"
3232

3333
if [ -n "${REBUILD_TEST_RUNNER}" ]; then
3434
# build the php test runner
35-
export PHP_56_IMAGE="gcr.io/google-appengine/php56:latest"
36-
envsubst '${PHP_56_IMAGE}' \
35+
export TEST_RUNNER_BASE_IMAGE="gcr.io/google-appengine/ubuntu-php72:latest"
36+
envsubst '${TEST_RUNNER_BASE_IMAGE}' \
3737
< cloudbuild-test-runner/Dockerfile.in \
3838
> cloudbuild-test-runner/Dockerfile
3939
gcloud -q container builds submit --tag "${TEST_RUNNER}" \

scripts/run_acceptance_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ fi
3434
export PHP_BASE_IMAGE="gcr.io/google-appengine/php-base"
3535
export BASE_IMAGE="gcr.io/google-appengine/php"
3636
export PHP_56_IMAGE="gcr.io/google-appengine/php56"
37+
export TEST_RUNNER_BASE_IMAGE=${PHP_56_IMAGE}
3738

3839
for TEMPLATE in `find . -name Dockerfile.in`
3940
do

0 commit comments

Comments
 (0)