Skip to content

Commit

Permalink
Fix e2e tests (#284)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fhinkel authored Feb 26, 2019
1 parent 269106a commit 68b8afa
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .kokoro/e2e-tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export NVM_DIR="$HOME/.nvm"
nvm install 10

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

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

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

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

# Copy secrets
cp ${KOKORO_GFILE_DIR}/secrets-config.json config.json
cp $GOOGLE_APPLICATION_CREDENTIALS key.json

# Install dependencies (for running the tests, not the apps themselves)
yarn install
npm install

# Deploy a single step
gcloud app deploy --version $GAE_VERSION --no-promote # nodejs-repo-tools doesn't support specifying versions, so deploy manually
Expand Down
1 change: 1 addition & 0 deletions 2-structured-data/test/_test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ module.exports = {
url: `http://localhost:${PORT}`,
version: process.env.GAE_VERSION || TESTNAME,
msg: `Bookshelf`,
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
};
1 change: 1 addition & 0 deletions 3-binary-data/test/_test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ module.exports = {
url: `http://localhost:${PORT}`,
version: process.env.GAE_VERSION || TESTNAME,
msg: `Bookshelf`,
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
};
1 change: 1 addition & 0 deletions 4-auth/test/_test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ module.exports = {
url: `http://localhost:${PORT}`,
version: process.env.GAE_VERSION || TESTNAME,
msg: `Bookshelf`,
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
};
1 change: 1 addition & 0 deletions 5-logging/test/_test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ module.exports = {
url: `http://localhost:${PORT}`,
version: process.env.GAE_VERSION || TESTNAME,
msg: `Bookshelf`,
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
};
1 change: 1 addition & 0 deletions 6-pubsub/test/_test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ module.exports = {
PORT: PORT,
TOPIC_NAME: `book-process-queue-${TESTNAME}`,
},
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
};
1 change: 1 addition & 0 deletions 7-gce/test/_test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ module.exports = {
SUBSCRIPTION_NAME: `shared-worker-subscription-${TESTNAME}`,
TOPIC_NAME: `book-process-queue-${TESTNAME}`,
},
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
};

0 comments on commit 68b8afa

Please sign in to comment.