Skip to content

Commit

Permalink
[eventgrid] Fix nightly Min/Max CI issues
Browse files Browse the repository at this point in the history
Similar to Azure#19862, we have recently started to see some issues in our
nightly min/max jobs that prevent us from saving the entire Response
object during the `onResponse` callback due to multiple imports of the
"same" type.

Similar to the resolution for Azure#19862, I've decided to just not use
nominal types from `core-client` here and instead just stash away the
parts of the response I need inside the callback and observe the
values after.

Fixes Azure#20014
  • Loading branch information
ellismg committed Jan 28, 2022
1 parent 678b094 commit ef491d2
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions sdk/eventgrid/eventgrid/test/public/eventGridClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@ import { resetTracer, setTracer } from "@azure/test-utils";

import { AzureKeyCredential, EventGridPublisherClient } from "../../src";

import { FullOperationResponse } from "@azure/core-client";
import { RestError } from "@azure/core-rest-pipeline";
import { setSpan, context } from "@azure/core-tracing";

describe("EventGridPublisherClient", function (this: Suite) {
let recorder: Recorder;
let res: FullOperationResponse | undefined;

this.timeout(10000);

beforeEach(function () {
res = undefined;
});

describe("#send (EventGrid schema)", function () {
let client: EventGridPublisherClient<"EventGrid">;

Expand All @@ -43,6 +37,8 @@ describe("EventGridPublisherClient", function (this: Suite) {
});

it("sends a single event", async () => {
let status: number | undefined;

await client.send(
[
{
Expand All @@ -56,13 +52,15 @@ describe("EventGridPublisherClient", function (this: Suite) {
},
},
],
{ onResponse: (response) => (res = response) }
{ onResponse: (response) => (status = response.status) }
);

assert.equal(res?.status, 200);
assert.strictEqual(status, 200);
});

it("sends multiple events", async () => {
let status: number | undefined;

await client.send(
[
{
Expand All @@ -86,10 +84,10 @@ describe("EventGridPublisherClient", function (this: Suite) {
},
},
],
{ onResponse: (response) => (res = response) }
{ onResponse: (response) => (status = response.status) }
);

assert.equal(res?.status, 200);
assert.strictEqual(status, 200);
});
});

Expand Down Expand Up @@ -152,6 +150,8 @@ describe("EventGridPublisherClient", function (this: Suite) {
});

it("sends a single event", async () => {
let status: number | undefined;

await client.send(
[
{
Expand All @@ -164,13 +164,15 @@ describe("EventGridPublisherClient", function (this: Suite) {
},
},
],
{ onResponse: (response) => (res = response) }
{ onResponse: (response) => (status = response.status) }
);

assert.equal(res?.status, 200);
assert.strictEqual(status, 200);
});

it("sends multiple events", async () => {
let status: number | undefined;

await client.send(
[
{
Expand All @@ -194,13 +196,15 @@ describe("EventGridPublisherClient", function (this: Suite) {
},
},
],
{ onResponse: (response) => (res = response) }
{ onResponse: (response) => (status = response.status) }
);

assert.equal(res?.status, 200);
assert.strictEqual(status, 200);
});

it("enriches events with distributed tracing information", async () => {
let requestBody: string | undefined;

const tracer = setTracer();
const rootSpan = tracer.startSpan("root");
await client.send(
Expand All @@ -220,13 +224,13 @@ describe("EventGridPublisherClient", function (this: Suite) {
tracingOptions: {
tracingContext: setSpan(context.active(), rootSpan),
},
onResponse: (response) => (res = response),
onResponse: (response) => (requestBody = response.request.body as string),
}
);

rootSpan.end();

const parsedBody = JSON.parse(res?.request.body as string);
const parsedBody = JSON.parse(requestBody || "");

assert.isArray(parsedBody);
assert.equal(
Expand Down Expand Up @@ -301,6 +305,8 @@ describe("EventGridPublisherClient", function (this: Suite) {
});

it("sends a single event", async () => {
let status: number | undefined;

await client.send(
[
{
Expand All @@ -312,13 +318,15 @@ describe("EventGridPublisherClient", function (this: Suite) {
},
},
],
{ onResponse: (response) => (res = response) }
{ onResponse: (response) => (status = response.status) }
);

assert.equal(res?.status, 200);
assert.strictEqual(status, 200);
});

it("sends multiple events", async () => {
let status: number | undefined;

await client.send(
[
{
Expand All @@ -338,10 +346,10 @@ describe("EventGridPublisherClient", function (this: Suite) {
},
},
],
{ onResponse: (response) => (res = response) }
{ onResponse: (response) => (status = response.status) }
);

assert.equal(res?.status, 200);
assert.strictEqual(status, 200);
});
});

Expand Down

0 comments on commit ef491d2

Please sign in to comment.