Skip to content

Commit afcca73

Browse files
committed
Merge pull request GoogleCloudPlatform#28 from bshaffer/misc-fixes-for-e2e-tests
misc fixes for e2e test script, fixes permissions for symfony
2 parents 74ccb82 + ea2b6b4 commit afcca73

File tree

4 files changed

+67
-25
lines changed

4 files changed

+67
-25
lines changed

managed_vms/drupal8/tests/run-tests.sh

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
22
set -e
3+
set -o xtrace
34

45
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
56
SAMPLE_DIR="${DIR}/.."
67
DRUPAL_DIR="${SAMPLE_DIR}/drupal8.test"
78

89
VARS=(
910
GOOGLE_PROJECT_ID
10-
GOOGLE_VERSION_ID
1111
DRUPAL_ADMIN_USERNAME
1212
DRUPAL_ADMIN_PASSWORD
1313
DRUPAL_DATABASE_NAME
@@ -63,11 +63,35 @@ drupal cache:rebuild all
6363
# Copy configuration files to the drupal project
6464
cp $SAMPLE_DIR/{app.yaml,php.ini,Dockerfile,nginx-app.conf} $DRUPAL_DIR
6565

66-
# Deploy to gcloud
67-
gcloud preview app deploy \
68-
--no-promote --quiet --stop-previous-version --force \
69-
--project=${GOOGLE_PROJECT_ID} \
70-
--version=${GOOGLE_VERSION_ID}
66+
# Deploy to a module other than "default"
67+
if [ ! -z "${GOOGLE_MODULE}" ]; then
68+
echo "module: ${GOOGLE_MODULE}" >> ${DRUPAL_DIR}/app.yaml
69+
fi
70+
71+
# Set a version ID if none was supplied
72+
if [ -z "${GOOGLE_VERSION_ID}" ]; then
73+
GOOGLE_VERSION_ID=$(date +%s)
74+
fi
75+
76+
# Deploy to gcloud (try 3 times)
77+
attempts=0
78+
until [ $attempts -ge 3 ]
79+
do
80+
gcloud preview app deploy \
81+
--no-promote --quiet --stop-previous-version --force --docker-build=remote \
82+
--project=${GOOGLE_PROJECT_ID} \
83+
--version=${GOOGLE_VERSION_ID} \
84+
&& break
85+
attempts=$[$attempts+1]
86+
sleep 1
87+
done
88+
89+
# Determine the deployed URL
90+
if [ -z "${GOOGLE_MODULE}" ]; then
91+
VERSION_PREFIX=${GOOGLE_VERSION_ID}
92+
else
93+
VERSION_PREFIX=${GOOGLE_VERSION_ID}-dot-${GOOGLE_MODULE}
94+
fi
7195

7296
# perform the test
73-
curl -vf https://${GOOGLE_VERSION_ID}-dot-${GOOGLE_PROJECT_ID}.appspot.com
97+
curl -fs https://${VERSION_PREFIX}-dot-${GOOGLE_PROJECT_ID}.appspot.com > /dev/null

managed_vms/symfony/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ FROM gcr.io/php-mvm-a/php-nginx:latest
66
ENV DOCUMENT_ROOT /app/web
77

88
# add write permissions to var directory for cache, logs, and session
9-
RUN chmod -R u+w /app/var
9+
RUN chmod -R ug+w /app/var

managed_vms/symfony/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ directory:
2929
# clone this repo somewhere
3030
git clone https://github.com/GoogleCloudPlatform/php-docs-samples /path/to/php-docs-samples
3131

32-
# copy the four files below to the root directory of your Drupal project
32+
# copy the four files below to the root directory of your Symfony project
3333
cd /path/to/php-docs-samples/managed_vms/symfony/
3434
cp ./{app.yaml,php.ini,Dockerfile,nginx-app.conf} /path/to/symfony
3535
```
@@ -39,7 +39,7 @@ The four files needed are as follows:
3939
1. [`app.yaml`](app.yaml) - The App Engine configuration for your project
4040
1. [`Dockerfile`](Dockerfile) - Container configuration for the PHP runtime
4141
1. [`php.ini`](php.ini) - Optional ini used to extend the runtime configuration.
42-
1. [`nginx-app.conf`](nginx-app.conf) - Nginx web server configuration needed for `Drupal 8`
42+
1. [`nginx-app.conf`](nginx-app.conf) - Nginx web server configuration needed for `Symfony`
4343

4444
[1]: https://cloud.google.com/appengine/docs/managed-vms/
4545
[2]: https://console.cloud.google.com

managed_vms/symfony/tests/run-tests.sh

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22
set -e
3+
set -o xtrace
34

45
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
56
SAMPLE_DIR="${DIR}/.."
@@ -42,28 +43,45 @@ sed -i -e "s/database_name: .*/database_name: ${SYMFONY_DATABASE_NAME}/" $PARAME
4243
sed -i -e "s/database_user: .*/database_user: ${SYMFONY_DATABASE_USER}/" $PARAMETERS_FILE
4344
sed -i -e "s/database_password: .*/database_password: ${SYMFONY_DATABASE_PASS}/" $PARAMETERS_FILE
4445

45-
## Perform steps outlined in the README ##
46-
47-
# Copy configuration files to user home directory:
48-
cp "${SAMPLE_DIR}/app.yaml" "${SYMFONY_DIR}/app.yaml"
49-
cp "${SAMPLE_DIR}/nginx-app.conf" "${SYMFONY_DIR}/nginx-app.conf"
50-
cp "${SAMPLE_DIR}/Dockerfile" "${SYMFONY_DIR}/Dockerfile"
51-
cp "${SAMPLE_DIR}/php.ini" "${SYMFONY_DIR}/php.ini"
52-
5346
cd $SYMFONY_DIR
5447

55-
# remove composer.json - this is causing problems right now
48+
# Remove composer.json - this is causing problems right now
5649
rm composer.json
5750

58-
# Deploy to gcloud
51+
## Perform steps outlined in the README ##
52+
53+
# Copy configuration files to the symfony project
54+
cp $SAMPLE_DIR/{app.yaml,php.ini,Dockerfile,nginx-app.conf} $SYMFONY_DIR
55+
56+
# Deploy to a module other than "default"
57+
if [ ! -z "${GOOGLE_MODULE}" ]; then
58+
echo "module: ${GOOGLE_MODULE}" >> ${SYMFONY_DIR}/app.yaml
59+
fi
60+
61+
# Set a version ID if none was supplied
5962
if [ -z "${GOOGLE_VERSION_ID}" ]; then
6063
GOOGLE_VERSION_ID=$(date +%s)
6164
fi
6265

63-
gcloud preview app deploy \
64-
--no-promote --quiet --stop-previous-version --force --docker-build=remote \
65-
--project=${GOOGLE_PROJECT_ID} \
66-
--version=${GOOGLE_VERSION_ID}
66+
# Deploy to gcloud (try 3 times)
67+
attempts=0
68+
until [ $attempts -ge 3 ]
69+
do
70+
gcloud preview app deploy \
71+
--no-promote --quiet --stop-previous-version --force --docker-build=remote \
72+
--project=${GOOGLE_PROJECT_ID} \
73+
--version=${GOOGLE_VERSION_ID} \
74+
&& break
75+
attempts=$[$attempts+1]
76+
sleep 1
77+
done
78+
79+
# Determine the deployed URL
80+
if [ -z "${GOOGLE_MODULE}" ]; then
81+
VERSION_PREFIX=${GOOGLE_VERSION_ID}
82+
else
83+
VERSION_PREFIX=${GOOGLE_VERSION_ID}-dot-${GOOGLE_MODULE}
84+
fi
6785

6886
# perform the test
69-
curl -fs https://${GOOGLE_VERSION_ID}-dot-${GOOGLE_PROJECT_ID}.appspot.com > /dev/null
87+
curl -fs https://${VERSION_PREFIX}-dot-${GOOGLE_PROJECT_ID}.appspot.com > /dev/null

0 commit comments

Comments
 (0)