Skip to content

Commit 68b8afa

Browse files
authored
Fix e2e tests (GoogleCloudPlatform#284)
e2e tests send request against the live app living at `https://${opts.version}-dot-${opts.project}.appspot.com`; The test config relies on `opts.project`, which we configure via an environment variable. Note that only our tests use $GCLOUD_PROJECT, it is not used in the app.
1 parent 269106a commit 68b8afa

File tree

7 files changed

+11
-3
lines changed

7 files changed

+11
-3
lines changed

.kokoro/e2e-tests/build.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export NVM_DIR="$HOME/.nvm"
2929
nvm install 10
3030

3131
export NODE_ENV=development
32-
export E2E_TESTS=true # test the deployed app
32+
export E2E_TESTS=true # test the deployed app, used by repo-tools.getRequest()
3333

3434
# Register post-test cleanup
3535
export GAE_VERSION=${BOOKSHELF_DIRECTORY:0:1}-${DATA_BACKEND}
@@ -54,21 +54,23 @@ function cleanup {
5454
trap cleanup EXIT
5555

5656
# Configure gcloud
57+
# Export the project as repo-tools e2e tests rely on it:
58+
# `https://${opts.version}-dot-${opts.project}.appspot.com`.
5759
export GCLOUD_PROJECT=nodejs-getting-started-tests
5860
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secrets-key.json
5961
gcloud auth activate-service-account --key-file "$GOOGLE_APPLICATION_CREDENTIALS"
6062
gcloud config set project $GCLOUD_PROJECT
6163

6264
# Install Node dependencies
63-
yarn global add @google-cloud/nodejs-repo-tools
65+
npm i -g @google-cloud/nodejs-repo-tools
6466
cd github/nodejs-getting-started/${BOOKSHELF_DIRECTORY}
6567

6668
# Copy secrets
6769
cp ${KOKORO_GFILE_DIR}/secrets-config.json config.json
6870
cp $GOOGLE_APPLICATION_CREDENTIALS key.json
6971

7072
# Install dependencies (for running the tests, not the apps themselves)
71-
yarn install
73+
npm install
7274

7375
# Deploy a single step
7476
gcloud app deploy --version $GAE_VERSION --no-promote # nodejs-repo-tools doesn't support specifying versions, so deploy manually

2-structured-data/test/_test-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ module.exports = {
2929
url: `http://localhost:${PORT}`,
3030
version: process.env.GAE_VERSION || TESTNAME,
3131
msg: `Bookshelf`,
32+
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
3233
};

3-binary-data/test/_test-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ module.exports = {
2929
url: `http://localhost:${PORT}`,
3030
version: process.env.GAE_VERSION || TESTNAME,
3131
msg: `Bookshelf`,
32+
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
3233
};

4-auth/test/_test-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ module.exports = {
2929
url: `http://localhost:${PORT}`,
3030
version: process.env.GAE_VERSION || TESTNAME,
3131
msg: `Bookshelf`,
32+
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
3233
};

5-logging/test/_test-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ module.exports = {
2929
url: `http://localhost:${PORT}`,
3030
version: process.env.GAE_VERSION || TESTNAME,
3131
msg: `Bookshelf`,
32+
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
3233
};

6-pubsub/test/_test-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ module.exports = {
3030
PORT: PORT,
3131
TOPIC_NAME: `book-process-queue-${TESTNAME}`,
3232
},
33+
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
3334
};

7-gce/test/_test-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ module.exports = {
3131
SUBSCRIPTION_NAME: `shared-worker-subscription-${TESTNAME}`,
3232
TOPIC_NAME: `book-process-queue-${TESTNAME}`,
3333
},
34+
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
3435
};

0 commit comments

Comments
 (0)