Skip to content

Commit

Permalink
Merge pull request #1092 from intech/tests-integration-tracing
Browse files Browse the repository at this point in the history
test(integration): tracing
  • Loading branch information
icebob committed May 13, 2022
2 parents cc18949 + 1298716 commit 452cbf3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
14 changes: 7 additions & 7 deletions test/integration/__snapshots__/tracing.spec.js.snap
Expand Up @@ -431,7 +431,7 @@ Array [
},
Object {
"error": null,
"id": "broker-1-11",
"id": "broker-1-15",
"logs": Array [],
"name": "update others",
"parentID": "broker-1-2",
Expand All @@ -447,10 +447,10 @@ Array [
},
Object {
"error": null,
"id": "broker-2-15",
"id": "broker-2-19",
"logs": Array [],
"name": "User updated event",
"parentID": "broker-1-11",
"parentID": "broker-1-15",
"priority": 5,
"sampled": true,
"service": Object {
Expand All @@ -475,10 +475,10 @@ Array [
},
Object {
"error": null,
"id": "broker-2-16",
"id": "broker-2-20",
"logs": Array [],
"name": "updating user",
"parentID": "broker-2-15",
"parentID": "broker-2-19",
"priority": 5,
"sampled": true,
"service": Object {
Expand All @@ -491,10 +491,10 @@ Array [
},
Object {
"error": null,
"id": "broker-2-17",
"id": "broker-2-21",
"logs": Array [],
"name": "action 'friends.count'",
"parentID": "broker-2-16",
"parentID": "broker-2-20",
"priority": 5,
"sampled": true,
"service": Object {
Expand Down
22 changes: 19 additions & 3 deletions test/integration/tracing.spec.js
Expand Up @@ -47,15 +47,26 @@ describe("Test Tracing feature with actions", () => {
uidGenerator: broker => `${broker.nodeID}-${idCounter++}`
};

//const stacks = [];

const STORE = [];

const broker0 = H.createNode(_.defaultsDeep({ nodeID: "broker-0" }, COMMON_SETTINGS), [
{
name: "tracing-collector",
events: {
"$tracing.spans"(ctx) {
STORE.push(...ctx.params);
"$tracing.spans": {
tracing: false,
handler(ctx) {
STORE.push(...ctx.params);
}
}
/*"**": {
tracing: false,
handler(ctx) {
stacks.push(`${ctx.broker.nodeID}:${ctx.eventName}`);
}
}*/
}
}
]);
Expand All @@ -81,11 +92,13 @@ describe("Test Tracing feature with actions", () => {
}
},
events: {
"comments.removed"(ctx) {
async "comments.removed"(ctx) {
const span1 = ctx.startSpan("update posts");
ctx.broadcast("post.updated");
ctx.finishSpan(span1);

await broker1.Promise.delay(500);

const span2 = ctx.startSpan("update others");
ctx.broadcast("user.updated");
ctx.finishSpan(span2);
Expand Down Expand Up @@ -199,6 +212,7 @@ describe("Test Tracing feature with actions", () => {
it("should generate event spans", async () => {
idCounter = 1;
STORE.length = 0;
//stacks.length = 0;

await broker1.emit("comments.removed", null, {
meta: {
Expand All @@ -215,6 +229,8 @@ describe("Test Tracing feature with actions", () => {

const spans = getSpanFields(STORE);

//console.log(stacks);

expect(spans).toMatchSnapshot();
});
});

0 comments on commit 452cbf3

Please sign in to comment.