diff --git a/src/debuggee.ts b/src/debuggee.ts index 4d12501b..777e727c 100644 --- a/src/debuggee.ts +++ b/src/debuggee.ts @@ -52,6 +52,7 @@ export class Debuggee { // TODO: This doesn't seem to ever be set but is referenced in the // debuglet.ts file. isDisabled?: boolean; + isInactive?: boolean; /** * Creates a Debuggee service object. diff --git a/system-test/test-e2e.ts b/system-test/test-e2e.ts index ba164fb3..b14c9df2 100644 --- a/system-test/test-e2e.ts +++ b/system-test/test-e2e.ts @@ -98,9 +98,11 @@ describe('@google-cloud/debug end-to-end behavior', () => { for (let i = 0; i < CLUSTER_WORKERS; i++) { // Fork child processes that sned messages to this process with IPC. + // We pass UUID to the children so that they can all get the same + // debuggee id. const child: Child = {transcript: ''}; child.process = cp.fork( - FILENAME, /* args */[], + FILENAME, /* args */[UUID], {execArgv: [], env: process.env, silent: true}); child.process.on('message', handler); @@ -139,7 +141,9 @@ describe('@google-cloud/debug end-to-end behavior', () => { }); async function verifyDebuggeeFound() { - const debuggees = await api.listDebuggees(projectId!, true); + const allDebuggees = await api.listDebuggees(projectId!, true); + const debuggees = + allDebuggees.filter(debuggee => debuggee.isInactive !== true); // Check that the debuggee created in this test is among the list of // debuggees, then list its breakpoints @@ -255,7 +259,7 @@ describe('@google-cloud/debug end-to-end behavior', () => { console.log('-- checking log point was hit again'); children.forEach((child) => { const count = (child.transcript.match(REGEX) || []).length; - assert.ok(count > 60); + assert.ok(count > 60, `expected count ${count} to be > 60`); }); console.log('-- test passed'); } diff --git a/test/fixtures/fib.js b/test/fixtures/fib.js index e7f3afa9..a56f73d0 100644 --- a/test/fixtures/fib.js +++ b/test/fixtures/fib.js @@ -21,8 +21,14 @@ function fib(n) { * limitations under the License. */ +const uuid = require('uuid'); const nocks = require('../nocks.js'); nocks.projectId('fake-project-id'); +// mock the metadata instance to uniformly make this look like a non-gcp +// environment. +nocks.metadataInstance(); + +const UUID = process.argv[2] || uuid.v4(); var debuglet = require('../../..').start({ debug: { @@ -31,12 +37,9 @@ var debuglet = require('../../..').start({ logDelaySeconds: 5, breakpointUpdateIntervalSec: 1, testMode_: true, - allowExpressions: true + allowExpressions: true, + description: UUID }, - serviceContext: { - service: 'cloud-debug-system-test-service', - version: 'unversioned' - } }); // Make troubleshooting easier if run by itself diff --git a/test/nocks.ts b/test/nocks.ts index 71da2d32..fab7730d 100644 --- a/test/nocks.ts +++ b/test/nocks.ts @@ -53,3 +53,9 @@ export function projectId(reply: string): nock.Scope { .once() .reply(200, reply); } + +export function metadataInstance(): nock.Scope { + return nock('http://metadata.google.internal/') + .get('/computeMetadata/v1/instance') + .replyWithError({code: 'ENOTFOUND', message: 'nocked request'}); +}