Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
tests: make sure that all traces have been sent
  • Loading branch information
jirikuncar committed Nov 25, 2021
commit 335362f2f31b432121d266eb459e12170b85055f
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist
node_modules
package-lock.json
@rerun.txt
@scenarios.json

examples

Expand Down
1 change: 1 addition & 0 deletions cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const feature = [
`--format ${process.env.CI || !process.stdout.isTTY ? 'progress' : 'progress-bar'
}`,
'--format rerun:@rerun.txt',
'--format json:@scenarios.json',
'--publish-quiet'
].join(' ')

Expand Down
12 changes: 1 addition & 11 deletions features/step_definitions/request_steps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Given, Then, When, AfterAll } from "@cucumber/cucumber";
import { Given, Then, When } from "@cucumber/cucumber";
import { expect } from "chai";
import { World } from "../support/world";

Expand Down Expand Up @@ -171,13 +171,3 @@ Then(
);
}
);

AfterAll( function (this: World) {
let dd_service = process.env.DD_SERVICE;
let ci_pipeline_id = process.env.GITHUB_RUN_ID;
if (dd_service !== undefined && ci_pipeline_id !== undefined) {
console.log("\nTest reports:\n")
console.log("* View test APM traces and detailed time reports on Datadog (can take a few minutes to become available):")
console.log(`* https://app.datadoghq.com/ci/test-runs?query=%40test.service%3A${dd_service}%20%40ci.pipeline.id%3A${ci_pipeline_id}&index=citest\n`)
}
});
22 changes: 21 additions & 1 deletion features/support/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Before } from "@cucumber/cucumber";
import { Before, AfterAll } from "@cucumber/cucumber";
import { ITestCaseHookParameter } from "@cucumber/cucumber/lib/support_code_library_builder/types";

import tracer from "./tracer";
import { World } from "./world";

Before({ tags: "@skip or @skip-typescript" }, function () {
Expand Down Expand Up @@ -29,3 +30,22 @@ Before(function (
const parts = gherkinDocument.uri?.split("/") as string[];
this.apiVersion = parts[parts.length - 2];
});

AfterAll(function (this: World) {
const writer = (tracer as any)._tracer?._exporter?._writer;
if (writer !== undefined) {
try {
(tracer as any)._tracer._exporter._writer.flush();
} catch (error) {
console.log(error);
}
}

let dd_service = process.env.DD_SERVICE;
let ci_pipeline_id = process.env.GITHUB_RUN_ID;
if (dd_service !== undefined && ci_pipeline_id !== undefined) {
console.log("\nTest reports:\n")
console.log("* View test APM traces and detailed time reports on Datadog (can take a few minutes to become available):")
console.log(`* https://app.datadoghq.com/ci/test-runs?query=%40test.service%3A${dd_service}%20%40ci.pipeline.id%3A${ci_pipeline_id}&index=citest\n`)
Comment on lines +49 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log("\nTest reports:\n")
console.log("* View test APM traces and detailed time reports on Datadog (can take a few minutes to become available):")
console.log(`* https://app.datadoghq.com/ci/test-runs?query=%40test.service%3A${dd_service}%20%40ci.pipeline.id%3A${ci_pipeline_id}&index=citest\n`)
logger.info("\nTest reports:\n")
logger.info("* View test APM traces and detailed time reports on Datadog (can take a few minutes to become available):")
logger.info(`* https://app.datadoghq.com/ci/test-runs?query=%40test.service%3A${dd_service}%20%40ci.pipeline.id%3A${ci_pipeline_id}&index=citest\n`)

}
});