Skip to content
Permalink
Browse files

Fix e2e tests (#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.
  • Loading branch information...
fhinkel committed Feb 26, 2019
1 parent 269106a commit 68b8afa6741d9b04cff16f5efae624a5467afa90
@@ -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}
@@ -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
@@ -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
};
@@ -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
};
@@ -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
};
@@ -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
};
@@ -30,4 +30,5 @@ module.exports = {
PORT: PORT,
TOPIC_NAME: `book-process-queue-${TESTNAME}`,
},
project: process.env.GCLOUD_PROJECT, // needed for e2e URL
};
@@ -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.
You can’t perform that action at this time.