Skip to content

Commit

Permalink
chore: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
07souravkunda committed Aug 30, 2024
1 parent 5e9257c commit a0b224b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/testObservability/helper/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ const RequestQueueHandler = require('./requestQueueHandler');
exports.requestQueueHandler = new RequestQueueHandler();

exports.uploadEventData = async (eventData, run=0) => {
exports.debugOnConsole(`[uploadEventData] ${eventData.event_type}`);
const log_tag = {
['TestRunStarted']: 'Test_Start_Upload',
['TestRunFinished']: 'Test_End_Upload',
Expand Down
10 changes: 10 additions & 0 deletions bin/testObservability/reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ class MyReporter {
})

.on(EVENT_HOOK_BEGIN, async (hook) => {
debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_BEGIN`);
if(this.testObservability == true) {
if(!hook.hookAnalyticsId) {
hook.hookAnalyticsId = uuidv4();
} else if(this.runStatusMarkedHash[hook.hookAnalyticsId]) {
delete this.runStatusMarkedHash[hook.hookAnalyticsId];
hook.hookAnalyticsId = uuidv4();
}
debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_BEGIN for uuid: ${hook.hookAnalyticsId}`);
hook.hook_started_at = (new Date()).toISOString();
hook.started_at = (new Date()).toISOString();
this.current_hook = hook;
Expand All @@ -103,6 +105,7 @@ class MyReporter {
})

.on(EVENT_HOOK_END, async (hook) => {
debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_END`);
if(this.testObservability == true) {
if(!this.runStatusMarkedHash[hook.hookAnalyticsId]) {
if(!hook.hookAnalyticsId) {
Expand All @@ -115,6 +118,9 @@ class MyReporter {

// Remove hooks added at hook start
delete this.hooksStarted[hook.hookAnalyticsId];

debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_END for uuid: ${hook.hookAnalyticsId}`);

await this.sendTestRunEvent(hook,undefined,false,"HookRunFinished");
}
}
Expand Down Expand Up @@ -185,10 +191,12 @@ class MyReporter {

.once(EVENT_RUN_END, async () => {
try {
debugOnConsole(`[MOCHA EVENT] EVENT_RUN_END`);
if(this.testObservability == true) {
const hookSkippedTests = getHookSkippedTests(this.runner.suite);
for(const test of hookSkippedTests) {
if(!test.testAnalyticsId) test.testAnalyticsId = uuidv4();
debugOnConsole(`[MOCHA EVENT] EVENT_RUN_END TestRunSkipped for uuid: ${test.testAnalyticsId}`);
await this.sendTestRunEvent(test,undefined,false,"TestRunSkipped");
}
}
Expand Down Expand Up @@ -390,6 +398,7 @@ class MyReporter {
mapTestHooks(test);
}
} catch(e) {
debugOnConsole(`Exception in processing hook data for event ${eventType} with error : ${e}`);
debug(`Exception in processing hook data for event ${eventType} with error : ${e}`, true, e);
}

Expand Down Expand Up @@ -486,6 +495,7 @@ class MyReporter {
this.hooksStarted = {};
}
} catch(error) {
debugOnConsole(`Exception in populating test data for event ${eventType} with error : ${error}`);
debug(`Exception in populating test data for event ${eventType} with error : ${error}`, true, error);
}
}
Expand Down

0 comments on commit a0b224b

Please sign in to comment.