Skip to content

Commit c594414

Browse files
authored
feat: add deployment tests, remove unused scripts + GAE storage samples (GoogleCloudPlatform#1336)
1 parent 41ae641 commit c594414

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+198
-1166
lines changed

.kokoro/deploy_gae.cfg

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-kokoro-resources/php74"
7+
}
8+
9+
# Run the deployment tests
10+
env_vars: {
11+
key: "RUN_DEPLOYMENT_TESTS"
12+
value: "true"
13+
}
14+
15+
# Only run deployment tests for App Engine Standard
16+
env_vars: {
17+
key: "TEST_DIRECTORIES"
18+
value: "appengine/standard"
19+
}

.kokoro/deploy_gcf.cfg

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-kokoro-resources/php74"
7+
}
8+
9+
# Run the deployment tests
10+
env_vars: {
11+
key: "RUN_DEPLOYMENT_TESTS"
12+
value: "true"
13+
}
14+
15+
# Only run deployment tests for Cloud Functions
16+
env_vars: {
17+
key: "TEST_DIRECTORIES"
18+
value: "functions"
19+
}

.kokoro/deploy_misc.cfg

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-kokoro-resources/php74"
7+
}
8+
9+
# Run the deployment tests
10+
env_vars: {
11+
key: "RUN_DEPLOYMENT_TESTS"
12+
value: "true"
13+
}
14+
15+
# Run deployment tests for Cloud Run, EventArc Endpoints
16+
env_vars: {
17+
key: "TEST_DIRECTORIES"
18+
value: "endpoints eventarc run"
19+
}

.kokoro/secrets.sh.enc

163 Bytes
Binary file not shown.

appengine/standard/errorreporting/test/DeployTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DeployTest extends TestCase
3333

3434
public function setUp(): void
3535
{
36-
$this->projectId = getenv('GOOGLE_PROJECT_ID');
36+
self::$projectId = getenv('GOOGLE_PROJECT_ID');
3737
}
3838

3939
public function testIndex()
@@ -98,7 +98,7 @@ public function testFatalErrors()
9898
private function verifyReportedError($message, $retryCount = 5)
9999
{
100100
$errorStats = new ErrorStatsServiceClient();
101-
$projectName = $errorStats->projectName($this->projectId);
101+
$projectName = $errorStats->projectName(self::$projectId);
102102

103103
$timeRange = (new QueryTimeRange())
104104
->setPeriod(QueryTimeRange_Period::PERIOD_1_HOUR);
@@ -111,7 +111,10 @@ private function verifyReportedError($message, $retryCount = 5)
111111
$message
112112
) {
113113
$messages = [];
114-
$response = $errorStats->listGroupStats($projectName, $timeRange);
114+
$response = $errorStats->listGroupStats(
115+
$projectName,
116+
['timeRange' => $timeRange]
117+
);
115118
foreach ($response->iterateAllElements() as $groupStat) {
116119
$response = $errorStats->listEvents($projectName, $groupStat->getGroup()->getGroupId(), [
117120
'timeRange' => $timeRange,

appengine/standard/getting-started/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"slim/slim": "^4.0",
55
"slim/psr7": "^1.0",
66
"slim/twig-view": "^3.0",
7-
"php-di/slim-bridge": "^3.1"
7+
"php-di/slim-bridge": "^3.1",
8+
"symfony/yaml": "^5.2"
89
},
910
"autoload": {
1011
"psr-4": {

appengine/standard/laravel-framework/app-dbsessions.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Use the PHP 7.3 runtime (BETA) by replacing "php72" below with "php73"
2-
runtime: php72
1+
runtime: php74
32

43
env_variables:
54
## Put production environment variables here.
@@ -17,4 +16,4 @@ env_variables:
1716
## To use Stackdriver logging in your Laravel application, copy
1817
## "app/Logging/CreateStackdriverLogger.php" and "config/logging.php"
1918
## into your Laravel application. Then uncomment the following line:
20-
# LOG_CHANNEL: stackdriver
19+
# LOG_CHANNEL: stackdriver

appengine/standard/laravel-framework/bootstrap/app.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
App\Exceptions\Handler::class
4242
);
4343

44+
$app->singleton(
45+
Illuminate\Foundation\Exceptions\Handler::class,
46+
App\Exceptions\Handler::class
47+
);
48+
4449
# [START] Set the storage path to the environment variable APP_STORAGE
4550
/*
4651
|--------------------------------------------------------------------------

appengine/standard/laravel-framework/phpunit.xml.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<phpunit bootstrap="../../../testing/bootstrap.php">
1818
<testsuites>
1919
<testsuite name="AppEngine for PHP 7.2 Laravel Framework test">
20-
<directory>testdirectory>
20+
21+
22+
2123
testsuite>
2224
testsuites>
2325
<filter>

appengine/standard/laravel-framework/test/DeployDatabaseTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public static function beforeDeploy()
6767

6868
public function testHomepage()
6969
{
70+
$this->markTestSkipped(
71+
'This sample is BROKEN. See https://github.com/GoogleCloudPlatform/php-docs-samples/issues/1349'
72+
);
73+
7074
// Access the blog top page
7175
$resp = $this->client->get('/');
7276
$this->assertEquals(

appengine/standard/laravel-framework/test/DeployStackdriverTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public static function beforeDeploy()
6666

6767
public function testLogging()
6868
{
69+
$this->markTestSkipped(
70+
'This sample is BROKEN. See https://github.com/GoogleCloudPlatform/php-docs-samples/issues/1349'
71+
);
72+
6973
$logging = new LoggingClient([
7074
'projectId' => self::getProjectId()
7175
]);
@@ -98,6 +102,10 @@ public function testLogging()
98102

99103
public function testErrorReporting()
100104
{
105+
$this->markTestSkipped(
106+
'This sample is BROKEN. See https://github.com/GoogleCloudPlatform/php-docs-samples/issues/1349'
107+
);
108+
101109
$logging = new LoggingClient([
102110
'projectId' => self::getProjectId()
103111
]);

appengine/standard/laravel-framework/test/DeployTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public static function beforeDeploy()
4242

4343
public function testHomepage()
4444
{
45+
$this->markTestSkipped(
46+
'This sample is BROKEN. See https://github.com/GoogleCloudPlatform/php-docs-samples/issues/1349'
47+
);
48+
4549
// Access the blog top page
4650
$resp = $this->client->get('/');
4751
$this->assertEquals('200', $resp->getStatusCode(), 'top page status code');

appengine/standard/logging/test/DeployTest.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ public function testIndex()
4141
$response->getBody()->getContents()
4242
);
4343

44-
$this->verifyLog('This will show up as log level INFO', 'info', 3);
44+
$this->verifyLog('This will show up as log level INFO', 'info', 5);
4545

4646
// These should succeed if the above call has too.
4747
// Thus, they need fewer retries!
4848
$this->verifyLog('This will show up as log level WARNING', 'warning');
4949
$this->verifyLog('This will show up as log level ERROR', 'error');
5050
}
5151

52-
private function verifyLog($message, $level, $retryCount = 2)
52+
private function verifyLog($message, $level, $retryCount = 3)
5353
{
5454
$fiveMinAgo = date(\DateTime::RFC3339, strtotime('-5 minutes'));
5555
$filter = sprintf(
@@ -59,8 +59,8 @@ private function verifyLog($message, $level, $retryCount = 2)
5959
$fiveMinAgo
6060
);
6161
$logOptions = [
62-
'pageSize' => 20,
63-
'resultLimit' => 20,
62+
'pageSize' => 50,
63+
'resultLimit' => 50,
6464
'filter' => $filter,
6565
];
6666
$logging = new LoggingClient();
@@ -71,16 +71,14 @@ private function verifyLog($message, $level, $retryCount = 2)
7171
$logOptions,
7272
$message
7373
) {
74+
// Concatenate all relevant log messages.
7475
$logs = $logging->entries($logOptions);
75-
$matched = false;
76+
$actual = '';
7677
foreach ($logs as $log) {
77-
if ($log->info()['jsonPayload']['message'] == $message) {
78-
$matched = true;
79-
break;
80-
}
78+
$actual .= $log->info()['jsonPayload']['message'];
8179
}
8280

83-
$this->assertTrue($matched);
81+
$this->assertStringContainsString($message, $actual);
8482
}, $retryCount, true);
8583
}
8684
}

appengine/standard/slim-framework/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# [START gae_slim_front_controller]
3030
$app = AppFactory::create();
3131
$app->addRoutingMiddleware();
32+
$app->addErrorMiddleware(true, true, true);
3233

3334
$app->get('/', function (Request $request, Response $response) {
3435
// Use the Null Coalesce Operator in PHP7

appengine/standard/storage/README.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

appengine/standard/storage/app.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

appengine/standard/storage/composer.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)