Skip to content

Commit

Permalink
test: stop using TRACE_TEST_* for system tests (#861)
Browse files Browse the repository at this point in the history
* test: stop using TRACE_TEST_* for system tests

* test: fix test script bug

* test: use hard-rejection in system tests

* test: make system tests use long-door-651 instead
  • Loading branch information
kjin authored Sep 11, 2018
1 parent fbb10a6 commit d5fe71b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ unit_tests: &unit_tests
command: npm run check-install
- run:
name: Run system tests (skipped for PRs)
environment:
GCLOUD_PROJECT: long-door-651
GOOGLE_APPLICATION_CREDENTIALS: /root/project/long-door-651-a179efbeda21.json
command: npm run system-test

# Services needed for unit tests.
Expand Down
Binary file added long-door-651-a179efbeda21.json.enc
Binary file not shown.
Binary file removed node-team-test-de480e4f9023.json.enc
Binary file not shown.
11 changes: 6 additions & 5 deletions scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import { runTests } from './run-tests';
import { testNonInterference } from './test-non-interference';
import { BUILD_DIRECTORY, existsP, spawnP } from './utils';

// The identifying string in the service account credentials file path.
const keyID = 'de480e4f9023';
// The identifying components in the service account credentials file path.
const projectID = 'long-door-651';
const keyID = 'a179efbeda21';

// Globs to exclude when running unit tests only.
const unitTestExcludeGlobs: string[] = TRACE_TEST_EXCLUDE_INTEGRATION ? [
Expand Down Expand Up @@ -66,7 +67,7 @@ async function run(steps: string[]) {
await checkInstall();
break;
case 'encrypt-service-account-credentials':
const keyAndIV = await encryptCredentials(`node-team-test-${keyID}.json`);
const keyAndIV = await encryptCredentials(`${projectID}-${keyID}.json`);
console.log([
`key: ${keyAndIV.key}`,
`iv: ${keyAndIV.iv}`
Expand All @@ -80,7 +81,7 @@ async function run(steps: string[]) {
break;
}

await decryptCredentials({ key, iv }, `node-team-test-${keyID}.json`);
await decryptCredentials({ key, iv }, `${projectID}-${keyID}.json`);
break;
case 'get-plugin-types':
await getPluginTypes();
Expand Down Expand Up @@ -113,7 +114,7 @@ async function run(steps: string[]) {
});
break;
case 'run-system-tests':
if (CIRCLE_PR_NUMBER && !(await existsP('node-team-test-${keyID}.json'))) {
if (CIRCLE_PR_NUMBER || !(await existsP(`${projectID}-${keyID}.json`))) {
console.log('> Not running system tests in PRs');
} else {
await spawnP(
Expand Down
1 change: 1 addition & 0 deletions system-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"express": "^4.16.3",
"google-auto-auth": "^0.10.0",
"got": "^8.0.0",
"hard-rejection": "^1.0.0",
"querystring": "^0.2.0"
}
}
19 changes: 13 additions & 6 deletions system-test/trace-express.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@

'use strict';

if (!process.env.TRACE_SYSTEM_TEST_PROJECT ||
!process.env.TRACE_SYSTEM_TEST_KEYFILE) {
// Note - The service account with the given credentials must have the
// following roles:
// - Cloud Trace Admin (cloudtrace.admin)
// - Cloud Datastore User (datastore.user)
if (!process.env.GCLOUD_PROJECT ||
!process.env.GOOGLE_APPLICATION_CREDENTIALS) {
console.error('system-test requires credentials to be available via ' +
'environment. Please set TRACE_SYSTEM_TEST_PROJECT and ' +
'TRACE_SYSTEM_TEST_KEYFILE.');
'environment. Please set GCLOUD_PROJECT and ' +
'GOOGLE_APPLICATION_CREDENTIALS.');
process.exit(1);
}

const WRITE_CONSISTENCY_DELAY_MS = 20 * 1000;
const projectId = process.env.TRACE_SYSTEM_TEST_PROJECT;
const keyFilename = process.env.TRACE_SYSTEM_TEST_KEYFILE;
const projectId = process.env.GCLOUD_PROJECT;
const keyFilename = process.env.GOOGLE_APPLICATION_CREDENTIALS;

// trace-agent must be loaded before everything else.
require('../').start({
Expand All @@ -35,6 +39,9 @@ require('../').start({
flushDelaySeconds: 1
});

// Immediately exit when an unhandled Promise rejection occurs.
require('hard-rejection')();

const assert = require('assert');
const googleAuth = require('google-auto-auth');
const got = require('got');
Expand Down

0 comments on commit d5fe71b

Please sign in to comment.