From 82e4c24e6b37eca20e9a57b2011ae590d7fae558 Mon Sep 17 00:00:00 2001 From: Kelvin Jin Date: Thu, 14 Feb 2019 11:09:28 -0800 Subject: [PATCH] test: don't make network request in gRPC context test (#970) --- test/test-grpc-context.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/test-grpc-context.ts b/test/test-grpc-context.ts index 8cd66cc98..769b00d3a 100644 --- a/test/test-grpc-context.ts +++ b/test/test-grpc-context.ts @@ -21,7 +21,8 @@ import { describeInterop } from './utils'; // because express can't be re-patched. var agent = require('../..').start({ projectId: '0', - samplingRate: 0 + samplingRate: 0, + ignoreUrls: ['/no-trace'] }); var common = require('./plugins/common'/*.js*/); @@ -37,7 +38,9 @@ var client, grpcServer, server; function makeHttpRequester(callback, expectedReqs) { var pendingHttpReqs = expectedReqs; return function() { - http.get('http://www.google.com/', function(httpRes) { + // Make a request to an endpoint that won't create an additional server + // trace. + http.get(`http://localhost:${common.serverPort}/no-trace`, function(httpRes) { httpRes.on('data', function() {}); httpRes.on('end', function() { if (--pendingHttpReqs === 0) { @@ -71,6 +74,10 @@ describeInterop('grpc', fixture => { var proto = grpc.load(protoFile).nodetest; var app = express(); + app.get('/no-trace', function(req, res) { + res.sendStatus(200); + }); + app.get('/unary', function(req, res) { var httpRequester = requestAndSendHTTPStatus(res, 1); client.testUnary({n: 42}, httpRequester);