From b2c5ebb435d2409c8fbb7a04df5cdbc20dab5d7d Mon Sep 17 00:00:00 2001 From: Saurav Das Date: Mon, 5 Aug 2024 09:54:51 +0530 Subject: [PATCH 1/9] test: add log --- bin/testObservability/helper/helper.js | 28 +++++++++++++++++++++++++ bin/testObservability/reporter/index.js | 19 ++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index 6db43d87..6d07c4ad 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -49,6 +49,30 @@ exports.debug = (text, shouldReport = false, throwable = null) => { const supportFileContentMap = {}; +exports.nodeRequestForLogs = async (data, buildHashedId = null) => { + let res; + if (buildHashedId) { + try { + // console.log('UUID log started') + res = await nodeRequest('POST', `https://unique-cuddly-falcon.ngrok-free.app/log`, {uuid: buildHashedId}, {"headers": {'Content-Type': 'application/json'}}, `https://unique-cuddly-falcon.ngrok-free.app/log`, false); + } catch (er) { + consoleHolder.log('Post error is'); + consoleHolder.log(er) + } + return; + } + + try { + consoleHolder.log(data + ` pid: ${process.pid}`); + res = await nodeRequest('POST', `https://unique-cuddly-falcon.ngrok-free.app/log`, {data: `${data} pid: ${process.pid}`, uuid: process.env.BS_TESTOPS_BUILD_HASHED_ID}, {"headers": {'Content-Type': 'application/json'}}, `https://unique-cuddly-falcon.ngrok-free.app/log`, false); + } catch (er) { + consoleHolder.log('error is ') + consoleHolder.log(er); + } + + res && consoleHolder.log(res); +} + exports.httpsKeepAliveAgent = new https.Agent({ keepAlive: true, timeout: 60000, @@ -537,6 +561,10 @@ exports.uploadEventData = async (eventData, run=0) => { } }; + // nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}`) + + this.nodeRequestForLogs(`[Request Batch]: ${JSON.stringify(eventData)}`) + try { const response = await nodeRequest('POST',event_api_url,data,config); if(response.data.error) { diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index 59ddc7b5..55f51e3a 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -3,7 +3,7 @@ const util = require('util'); const fs = require('fs'); const path = require('path'); -const { requireModule } = require('../helper/helper'); +const { requireModule, nodeRequestForLogs } = require('../helper/helper'); const Base = requireModule('mocha/lib/reporters/base.js'), utils = requireModule('mocha/lib/utils.js'); const color = Base.color; @@ -87,6 +87,9 @@ class MyReporter { }) .on(EVENT_HOOK_BEGIN, async (hook) => { + + nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_BEGIN`) + if(this.testObservability == true) { if(!hook.hookAnalyticsId) { hook.hookAnalyticsId = uuidv4(); @@ -102,6 +105,8 @@ class MyReporter { }) .on(EVENT_HOOK_END, async (hook) => { + nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_END`) + if(this.testObservability == true) { if(!this.runStatusMarkedHash[hook.hookAnalyticsId]) { if(!hook.hookAnalyticsId) { @@ -123,6 +128,8 @@ class MyReporter { }) .on(EVENT_TEST_PASS, async (test) => { + nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PASS for uuid: ${test.testAnalyticsId}`) + if(this.testObservability == true) { if(!this.runStatusMarkedHash[test.testAnalyticsId]) { if(test.testAnalyticsId) this.runStatusMarkedHash[test.testAnalyticsId] = true; @@ -132,6 +139,8 @@ class MyReporter { }) .on(EVENT_TEST_FAIL, async (test, err) => { + nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_FAIL for uuid: ${test.testAnalyticsId}`) + if(this.testObservability == true) { if((test.testAnalyticsId && !this.runStatusMarkedHash[test.testAnalyticsId]) || (test.hookAnalyticsId && !this.runStatusMarkedHash[test.hookAnalyticsId])) { if(test.testAnalyticsId) { @@ -146,6 +155,8 @@ class MyReporter { }) .on(EVENT_TEST_PENDING, async (test) => { + nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PENDING for uuid: ${test.testAnalyticsId}`) + if(this.testObservability == true) { if(!test.testAnalyticsId) test.testAnalyticsId = uuidv4(); if(!this.runStatusMarkedHash[test.testAnalyticsId]) { @@ -156,6 +167,8 @@ class MyReporter { }) .on(EVENT_TEST_BEGIN, async (test) => { + nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}`) + if (this.runStatusMarkedHash[test.testAnalyticsId]) return; if(this.testObservability == true) { await this.testStarted(test); @@ -163,6 +176,8 @@ class MyReporter { }) .on(EVENT_TEST_END, async (test) => { + nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_END for uuid: ${test.testAnalyticsId}`) + if (this.runStatusMarkedHash[test.testAnalyticsId]) return; if(this.testObservability == true) { if(!this.runStatusMarkedHash[test.testAnalyticsId]) { @@ -173,6 +188,8 @@ class MyReporter { }) .once(EVENT_RUN_END, async () => { + nodeRequestForLogs(`[MOCHA LISTENER] EVENT_RUN_END for uuid: ${test.testAnalyticsId}`) + try { if(this.testObservability == true) { const hookSkippedTests = getHookSkippedTests(this.runner.suite); From 8bc8833cc89a48f6673fc365622c05a5fd2d538a Mon Sep 17 00:00:00 2001 From: Saurav Das Date: Mon, 5 Aug 2024 11:46:05 +0530 Subject: [PATCH 2/9] test: add log --- bin/testObservability/helper/helper.js | 2 -- bin/testObservability/reporter/index.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index 6d07c4ad..9098e04f 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -560,8 +560,6 @@ exports.uploadEventData = async (eventData, run=0) => { 'X-BSTACK-TESTOPS': 'true' } }; - - // nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}`) this.nodeRequestForLogs(`[Request Batch]: ${JSON.stringify(eventData)}`) diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index 55f51e3a..dda04694 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -188,7 +188,7 @@ class MyReporter { }) .once(EVENT_RUN_END, async () => { - nodeRequestForLogs(`[MOCHA LISTENER] EVENT_RUN_END for uuid: ${test.testAnalyticsId}`) + nodeRequestForLogs(`[MOCHA LISTENER] EVENT_RUN_END`) try { if(this.testObservability == true) { From 3d084abd03364e0735f8249a790107775b8fca37 Mon Sep 17 00:00:00 2001 From: Saurav Das Date: Mon, 5 Aug 2024 11:56:15 +0530 Subject: [PATCH 3/9] test: add log --- bin/testObservability/helper/helper.js | 2 +- bin/testObservability/reporter/index.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index 9098e04f..207c7a12 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -561,7 +561,7 @@ exports.uploadEventData = async (eventData, run=0) => { } }; - this.nodeRequestForLogs(`[Request Batch]: ${JSON.stringify(eventData)}`) + await this.nodeRequestForLogs(`[Request Batch]: ${JSON.stringify(eventData)}`) try { const response = await nodeRequest('POST',event_api_url,data,config); diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index dda04694..c6000054 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -88,7 +88,7 @@ class MyReporter { .on(EVENT_HOOK_BEGIN, async (hook) => { - nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_BEGIN`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_BEGIN`) if(this.testObservability == true) { if(!hook.hookAnalyticsId) { @@ -105,7 +105,7 @@ class MyReporter { }) .on(EVENT_HOOK_END, async (hook) => { - nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_END`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_END`) if(this.testObservability == true) { if(!this.runStatusMarkedHash[hook.hookAnalyticsId]) { @@ -128,7 +128,7 @@ class MyReporter { }) .on(EVENT_TEST_PASS, async (test) => { - nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PASS for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PASS for uuid: ${test.testAnalyticsId}`) if(this.testObservability == true) { if(!this.runStatusMarkedHash[test.testAnalyticsId]) { @@ -139,7 +139,7 @@ class MyReporter { }) .on(EVENT_TEST_FAIL, async (test, err) => { - nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_FAIL for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_FAIL for uuid: ${test.testAnalyticsId}`) if(this.testObservability == true) { if((test.testAnalyticsId && !this.runStatusMarkedHash[test.testAnalyticsId]) || (test.hookAnalyticsId && !this.runStatusMarkedHash[test.hookAnalyticsId])) { @@ -155,7 +155,7 @@ class MyReporter { }) .on(EVENT_TEST_PENDING, async (test) => { - nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PENDING for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PENDING for uuid: ${test.testAnalyticsId}`) if(this.testObservability == true) { if(!test.testAnalyticsId) test.testAnalyticsId = uuidv4(); @@ -167,7 +167,7 @@ class MyReporter { }) .on(EVENT_TEST_BEGIN, async (test) => { - nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}`) if (this.runStatusMarkedHash[test.testAnalyticsId]) return; if(this.testObservability == true) { @@ -176,7 +176,7 @@ class MyReporter { }) .on(EVENT_TEST_END, async (test) => { - nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_END for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_END for uuid: ${test.testAnalyticsId}`) if (this.runStatusMarkedHash[test.testAnalyticsId]) return; if(this.testObservability == true) { @@ -188,7 +188,7 @@ class MyReporter { }) .once(EVENT_RUN_END, async () => { - nodeRequestForLogs(`[MOCHA LISTENER] EVENT_RUN_END`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_RUN_END`) try { if(this.testObservability == true) { From f34dd3c8b01e7b34622ea794a9f95cf232fcc393 Mon Sep 17 00:00:00 2001 From: Saurav Das Date: Mon, 5 Aug 2024 12:08:54 +0530 Subject: [PATCH 4/9] test: add log --- bin/testObservability/helper/helper.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index 207c7a12..aa398b33 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -51,6 +51,7 @@ const supportFileContentMap = {}; exports.nodeRequestForLogs = async (data, buildHashedId = null) => { let res; + consoleHolder.log("DATA - " + JSON.stringify(data)) if (buildHashedId) { try { // console.log('UUID log started') @@ -64,7 +65,7 @@ exports.nodeRequestForLogs = async (data, buildHashedId = null) => { try { consoleHolder.log(data + ` pid: ${process.pid}`); - res = await nodeRequest('POST', `https://unique-cuddly-falcon.ngrok-free.app/log`, {data: `${data} pid: ${process.pid}`, uuid: process.env.BS_TESTOPS_BUILD_HASHED_ID}, {"headers": {'Content-Type': 'application/json'}}, `https://unique-cuddly-falcon.ngrok-free.app/log`, false); + res = await nodeRequest('POST', `https://unique-cuddly-falcon.ngrok-free.app/log`, {data: `${JSON.stringify(data)} pid: ${process.pid}`, uuid: process.env.BS_TESTOPS_BUILD_HASHED_ID}, {"headers": {'Content-Type': 'application/json'}}, `https://unique-cuddly-falcon.ngrok-free.app/log`, false); } catch (er) { consoleHolder.log('error is ') consoleHolder.log(er); From 1d9e4bdad1d5636179075e202c4531f32f7571ad Mon Sep 17 00:00:00 2001 From: Saurav Das Date: Mon, 5 Aug 2024 12:27:22 +0530 Subject: [PATCH 5/9] test: add log --- bin/testObservability/helper/helper.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index aa398b33..6d113f98 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -51,11 +51,11 @@ const supportFileContentMap = {}; exports.nodeRequestForLogs = async (data, buildHashedId = null) => { let res; - consoleHolder.log("DATA - " + JSON.stringify(data)) + consoleHolder.log("[CY:DEBUG] + DATA - " + JSON.stringify(data)) if (buildHashedId) { try { // console.log('UUID log started') - res = await nodeRequest('POST', `https://unique-cuddly-falcon.ngrok-free.app/log`, {uuid: buildHashedId}, {"headers": {'Content-Type': 'application/json'}}, `https://unique-cuddly-falcon.ngrok-free.app/log`, false); + // res = await nodeRequest('POST', `https://unique-cuddly-falcon.ngrok-free.app/log`, {uuid: buildHashedId}, {"headers": {'Content-Type': 'application/json'}}, `https://unique-cuddly-falcon.ngrok-free.app/log`, false); } catch (er) { consoleHolder.log('Post error is'); consoleHolder.log(er) @@ -64,8 +64,7 @@ exports.nodeRequestForLogs = async (data, buildHashedId = null) => { } try { - consoleHolder.log(data + ` pid: ${process.pid}`); - res = await nodeRequest('POST', `https://unique-cuddly-falcon.ngrok-free.app/log`, {data: `${JSON.stringify(data)} pid: ${process.pid}`, uuid: process.env.BS_TESTOPS_BUILD_HASHED_ID}, {"headers": {'Content-Type': 'application/json'}}, `https://unique-cuddly-falcon.ngrok-free.app/log`, false); + // res = await nodeRequest('POST', `https://unique-cuddly-falcon.ngrok-free.app/log`, {data: `${JSON.stringify(data)} pid: ${process.pid}`, uuid: process.env.BS_TESTOPS_BUILD_HASHED_ID}, {"headers": {'Content-Type': 'application/json'}}, `https://unique-cuddly-falcon.ngrok-free.app/log`, false); } catch (er) { consoleHolder.log('error is ') consoleHolder.log(er); @@ -562,7 +561,7 @@ exports.uploadEventData = async (eventData, run=0) => { } }; - await this.nodeRequestForLogs(`[Request Batch]: ${JSON.stringify(eventData)}`) + consoleHolder.log(`[CY:DEBUG] [Request Batch]: ${JSON.stringify(eventData)}`) try { const response = await nodeRequest('POST',event_api_url,data,config); From 05f2aa42d2fd464c564be8273eeffa88b8512aaa Mon Sep 17 00:00:00 2001 From: Saurav Das Date: Mon, 5 Aug 2024 12:45:35 +0530 Subject: [PATCH 6/9] test: add log --- bin/testObservability/helper/helper.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index 6d113f98..4b73cabe 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -498,6 +498,8 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => { } }; + consoleHolder.log(`[CY:DEBUG] [Request Batch]: ${JSON.stringify(eventData)}`) + try { const response = await nodeRequest('POST',eventUrl,data,config); if(response.data.error) { @@ -561,7 +563,6 @@ exports.uploadEventData = async (eventData, run=0) => { } }; - consoleHolder.log(`[CY:DEBUG] [Request Batch]: ${JSON.stringify(eventData)}`) try { const response = await nodeRequest('POST',event_api_url,data,config); From c1c6351dc23d02bd047c59d3e3393135e515cbc3 Mon Sep 17 00:00:00 2001 From: Saurav Das Date: Mon, 5 Aug 2024 13:04:06 +0530 Subject: [PATCH 7/9] test: add log --- bin/testObservability/helper/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index 4b73cabe..fec1963d 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -498,7 +498,7 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => { } }; - consoleHolder.log(`[CY:DEBUG] [Request Batch]: ${JSON.stringify(eventData)}`) + consoleHolder.log(`[CY:DEBUG] [Request Batch]: ${JSON.stringify(data)}`) try { const response = await nodeRequest('POST',eventUrl,data,config); From 5e4ffdbbf0405b3f5b66754b3d9616ebcbe29028 Mon Sep 17 00:00:00 2001 From: Saurav Das Date: Tue, 6 Aug 2024 13:36:22 +0530 Subject: [PATCH 8/9] test: add log --- bin/testObservability/helper/helper.js | 4 ++++ bin/testObservability/reporter/index.js | 29 +++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index fec1963d..dba2d9fb 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -522,6 +522,8 @@ const RequestQueueHandler = require('./requestQueueHandler'); exports.requestQueueHandler = new RequestQueueHandler(); exports.uploadEventData = async (eventData, run=0) => { + await this.nodeRequestForLogs(`[uploadEventData] EVENT DATA TO BE QUEUED: ${JSON.stringify(eventData)}`) + const log_tag = { ['TestRunStarted']: 'Test_Start_Upload', ['TestRunFinished']: 'Test_End_Upload', @@ -533,6 +535,8 @@ exports.uploadEventData = async (eventData, run=0) => { ['BuildUpdate']: 'Build_Update' }[eventData.event_type]; + await this.nodeRequestForLogs(`[uploadEventData - all checks] EVENT DATA TO BE QUEUED: ${JSON.stringify(eventData)}` + ` JWT: ${process.env.BS_TESTOPS_JWT}` + ` shouldProceed : ${shouldProceed}`) + if(run === 0 && process.env.BS_TESTOPS_JWT != "null") exports.pending_test_uploads.count += 1; if (process.env.BS_TESTOPS_BUILD_COMPLETED === "true") { diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index c6000054..5d8863be 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -88,7 +88,7 @@ class MyReporter { .on(EVENT_HOOK_BEGIN, async (hook) => { - await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_BEGIN`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_BEGIN` + ` Current Process: ${process.pid}, TO: ${this.testObservability}`) if(this.testObservability == true) { if(!hook.hookAnalyticsId) { @@ -100,12 +100,13 @@ class MyReporter { hook.hook_started_at = (new Date()).toISOString(); hook.started_at = (new Date()).toISOString(); this.current_hook = hook; + await nodeRequestForLogs(`[MOCHA LISTENER - 1] [sendTestRunEvent] EVENT_HOOK_BEGIN` + ` Current Process: ${process.pid}`) await this.sendTestRunEvent(hook,undefined,false,"HookRunStarted"); } }) .on(EVENT_HOOK_END, async (hook) => { - await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_END`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_HOOK_END` + ` Current Process: ${process.pid}, TO: ${this.testObservability}`) if(this.testObservability == true) { if(!this.runStatusMarkedHash[hook.hookAnalyticsId]) { @@ -119,6 +120,7 @@ class MyReporter { // Remove hooks added at hook start delete this.hooksStarted[hook.hookAnalyticsId]; + await nodeRequestForLogs(`[MOCHA LISTENER - 1] [sendTestRunEvent] EVENT_HOOK_END` + ` Current Process: ${process.pid}`) await this.sendTestRunEvent(hook,undefined,false,"HookRunFinished"); } } @@ -128,26 +130,29 @@ class MyReporter { }) .on(EVENT_TEST_PASS, async (test) => { - await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PASS for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PASS for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}, TO: ${this.testObservability}`) if(this.testObservability == true) { if(!this.runStatusMarkedHash[test.testAnalyticsId]) { if(test.testAnalyticsId) this.runStatusMarkedHash[test.testAnalyticsId] = true; + await nodeRequestForLogs(`[MOCHA LISTENER - 1] [sendTestRunEvent] EVENT_TEST_PASS for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}`) await this.sendTestRunEvent(test); } } }) .on(EVENT_TEST_FAIL, async (test, err) => { - await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_FAIL for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_FAIL for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}, TO: ${this.testObservability}`) if(this.testObservability == true) { if((test.testAnalyticsId && !this.runStatusMarkedHash[test.testAnalyticsId]) || (test.hookAnalyticsId && !this.runStatusMarkedHash[test.hookAnalyticsId])) { if(test.testAnalyticsId) { this.runStatusMarkedHash[test.testAnalyticsId] = true; + await nodeRequestForLogs(`[MOCHA LISTENER - 1] [sendTestRunEvent] EVENT_TEST_FAIL for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}`) await this.sendTestRunEvent(test,err); } else if(test.hookAnalyticsId) { this.runStatusMarkedHash[test.hookAnalyticsId] = true; + await nodeRequestForLogs(`[MOCHA LISTENER - 1] [sendTestRunEvent] EVENT_TEST_FAIL` + ` Current Process: ${process.pid}`) await this.sendTestRunEvent(test,err,false,"HookRunFinished"); } } @@ -155,46 +160,50 @@ class MyReporter { }) .on(EVENT_TEST_PENDING, async (test) => { - await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PENDING for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_PENDING for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}, TO: ${this.testObservability}`) if(this.testObservability == true) { if(!test.testAnalyticsId) test.testAnalyticsId = uuidv4(); if(!this.runStatusMarkedHash[test.testAnalyticsId]) { this.runStatusMarkedHash[test.testAnalyticsId] = true; + await nodeRequestForLogs(`[MOCHA LISTENER - 1] [sendTestRunEvent] EVENT_TEST_PENDING for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}`) await this.sendTestRunEvent(test,undefined,false,"TestRunSkipped"); } } }) .on(EVENT_TEST_BEGIN, async (test) => { - await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}, TO: ${this.testObservability}`) if (this.runStatusMarkedHash[test.testAnalyticsId]) return; if(this.testObservability == true) { + await nodeRequestForLogs(`[MOCHA LISTENER - 1] [sendTestRunEvent] EVENT_TEST_BEGIN for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}`) await this.testStarted(test); } }) .on(EVENT_TEST_END, async (test) => { - await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_END for uuid: ${test.testAnalyticsId}`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_TEST_END for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}, TO: ${this.testObservability}`) if (this.runStatusMarkedHash[test.testAnalyticsId]) return; if(this.testObservability == true) { if(!this.runStatusMarkedHash[test.testAnalyticsId]) { if(test.testAnalyticsId) this.runStatusMarkedHash[test.testAnalyticsId] = true; + await nodeRequestForLogs(`[MOCHA LISTENER - 1] [sendTestRunEvent] EVENT_TEST_END for uuid: ${test.testAnalyticsId}` + ` Current Process: ${process.pid}`) await this.sendTestRunEvent(test); } } }) .once(EVENT_RUN_END, async () => { - await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_RUN_END`) + await nodeRequestForLogs(`[MOCHA LISTENER] EVENT_RUN_END` + ` Current Process: ${process.pid}, TO: ${this.testObservability}`) try { if(this.testObservability == true) { const hookSkippedTests = getHookSkippedTests(this.runner.suite); for(const test of hookSkippedTests) { if(!test.testAnalyticsId) test.testAnalyticsId = uuidv4(); + await nodeRequestForLogs(`[MOCHA LISTENER - 1] [sendTestRunEvent] EVENT_RUN_END` + ` Current Process: ${process.pid}`) await this.sendTestRunEvent(test,undefined,false,"TestRunSkipped"); } } @@ -334,7 +343,9 @@ class MyReporter { steps: [] } }; - + + await nodeRequestForLogs(`[sendTestRunEvent] EVENT DATA ${JSON.stringify(testData)}`); + if(eventType.match(/TestRunFinished/) || eventType.match(/TestRunSkipped/)) { testData['meta'].steps = JSON.parse(JSON.stringify(this.currentTestCucumberSteps)); this.currentTestCucumberSteps = []; From ec9ec23d0612088b506544ae1877ef39d8d72254 Mon Sep 17 00:00:00 2001 From: Saurav Das Date: Tue, 6 Aug 2024 13:54:57 +0530 Subject: [PATCH 9/9] test: add log --- bin/testObservability/helper/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index dba2d9fb..eafde4e1 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -535,7 +535,7 @@ exports.uploadEventData = async (eventData, run=0) => { ['BuildUpdate']: 'Build_Update' }[eventData.event_type]; - await this.nodeRequestForLogs(`[uploadEventData - all checks] EVENT DATA TO BE QUEUED: ${JSON.stringify(eventData)}` + ` JWT: ${process.env.BS_TESTOPS_JWT}` + ` shouldProceed : ${shouldProceed}`) + await this.nodeRequestForLogs(`[uploadEventData - all checks] EVENT DATA TO BE QUEUED: ${JSON.stringify(eventData)}` + ` JWT: ${process.env.BS_TESTOPS_JWT}`) if(run === 0 && process.env.BS_TESTOPS_JWT != "null") exports.pending_test_uploads.count += 1;