@@ -42,14 +42,13 @@ private static function createApp($phpVersion)
42
42
copy (__DIR__ . '/files/app.yaml ' , $ tempDir . '/app.yaml ' );
43
43
copy (__DIR__ . '/files/web/index.php ' , $ tempDir . '/web/index.php ' );
44
44
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 ));
53
52
return $ tempDir ;
54
53
}
55
54
@@ -58,49 +57,66 @@ public function testDeploymentLatency()
58
57
$ phpVersions = [
59
58
'5.6 ' ,
60
59
'7.0 ' ,
61
- '7.1 '
60
+ '7.1 ' ,
61
+ '7.2 '
62
62
];
63
63
$ types = [
64
- 'xrt ' ,
65
- 'builder '
64
+ 'debian8 ' ,
65
+ 'ubuntu16 '
66
66
];
67
67
$ gcloudTrack = getenv ('GCLOUD_TRACK ' ) === 'beta ' ? 'beta ' : '' ;
68
68
foreach ($ phpVersions as $ phpVersion ) {
69
- $ dir = self ::createApp ($ phpVersion );
70
- chdir ($ dir );
71
69
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 ++;
88
117
}
89
- $ failureCount ++ ;
118
+ exec ( " rm -rf $ dir " ) ;
90
119
}
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 ;
104
120
}
105
121
}
106
122
}
0 commit comments