From ff96b70f76e4179cdd7e37a74393d4812c09f3ec Mon Sep 17 00:00:00 2001 From: Nev <54870357+MSNev@users.noreply.github.com> Date: Thu, 1 Sep 2022 04:52:01 -0700 Subject: [PATCH] ci: [Bug] DNS Lookup and Promise Lookup test for error NOT_FOUND failing #1136 (#1138) * ci: [Bug] DNS Lookup and Promise Lookup test for error NOT_FOUND failing #1136 * chore: automatically fix lint issue --- .../test/integrations/dns-lookup.test.ts | 36 ++++++++------- .../integrations/dnspromise-lookup.test.ts | 44 +++++++++++-------- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-dns/test/integrations/dns-lookup.test.ts b/plugins/node/opentelemetry-instrumentation-dns/test/integrations/dns-lookup.test.ts index 8c5a42d33b..8bd5ad698a 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/test/integrations/dns-lookup.test.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/test/integrations/dns-lookup.test.ts @@ -98,24 +98,30 @@ describe('dns.lookup()', () => { }); }); - it('should export a valid span with error NOT_FOUND', done => { - const hostname = 'ᚕ'; - dns.lookup(hostname, (err, address, family) => { - assert.ok(err); + describe('extended timeout', function () { + // Extending the default timeout as some environments are taking longer than 2 seconds to fail + // So rather than fail the test -- just take a little longer + this.timeout(10000); - const spans = memoryExporter.getFinishedSpans(); - const [span] = spans; + it('should export a valid span with error NOT_FOUND', done => { + const hostname = 'ᚕ'; + dns.lookup(hostname, (err, address, family) => { + assert.ok(err); - assert.strictEqual(spans.length, 1); - assertSpan(span, { - addresses: [{ address, family }], - hostname, - forceStatus: { - code: SpanStatusCode.ERROR, - message: err!.message, - }, + const spans = memoryExporter.getFinishedSpans(); + const [span] = spans; + + assert.strictEqual(spans.length, 1); + assertSpan(span, { + addresses: [{ address, family }], + hostname, + forceStatus: { + code: SpanStatusCode.ERROR, + message: err!.message, + }, + }); + done(); }); - done(); }); }); diff --git a/plugins/node/opentelemetry-instrumentation-dns/test/integrations/dnspromise-lookup.test.ts b/plugins/node/opentelemetry-instrumentation-dns/test/integrations/dnspromise-lookup.test.ts index 68e9414151..bb9988ee1f 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/test/integrations/dnspromise-lookup.test.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/test/integrations/dnspromise-lookup.test.ts @@ -111,25 +111,31 @@ describe('dns.promises.lookup()', () => { assertSpan(span, { addresses: [{ address, family }], hostname }); }); - it('should export a valid span with error NOT_FOUND', async () => { - const hostname = 'ᚕ'; - try { - await lookupPromise(hostname); - assert.fail(); - } catch (error) { - const spans = memoryExporter.getFinishedSpans(); - const [span] = spans; - - assert.strictEqual(spans.length, 1); - assertSpan(span, { - addresses: [], - hostname, - forceStatus: { - code: SpanStatusCode.ERROR, - message: error!.message, - }, - }); - } + describe('extended timeout', function () { + // Extending the default timeout as some environments are taking longer than 2 seconds to fail + // So rather than fail the test -- just take a little longer + this.timeout(10000); + + it('should export a valid span with error NOT_FOUND', async () => { + const hostname = 'ᚕ'; + try { + await lookupPromise(hostname); + assert.fail(); + } catch (error) { + const spans = memoryExporter.getFinishedSpans(); + const [span] = spans; + + assert.strictEqual(spans.length, 1); + assertSpan(span, { + addresses: [], + hostname, + forceStatus: { + code: SpanStatusCode.ERROR, + message: error!.message, + }, + }); + } + }); }); it('should export a valid span with error INVALID_ARGUMENT when "family" param is equal to -1', async () => {