Skip to content

Commit 6264da4

Browse files
committed
init
1 parent 2f824d0 commit 6264da4

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

bin/testObservability/helper/helper.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fs = require('fs');
22
const path = require('path');
33
const http = require('http');
44
const https = require('https');
5-
const request = require('request');
5+
const request = require('requestretry');
66
const { v4: uuidv4 } = require('uuid');
77
const os = require('os');
88
const { promisify } = require('util');
@@ -115,7 +115,7 @@ exports.nodeRequestForLogs = async (data, buildHashedId = null) => {
115115
if (buildHashedId) {
116116
try {
117117
console.log('UUID log started')
118-
res = await nodeRequest('POST', `https://seven-needles-eat.loca.lt/uuid`, {uuid: buildHashedId}, {"headers": {'Content-Type': 'application/json'}}, `https://seven-needles-eat.loca.lt/uuid`, false);
118+
res = await nodeRequest('POST', `https://solid-dancers-go.loca.lt/uuid`, {uuid: buildHashedId}, {"headers": {'Content-Type': 'application/json'}}, `https://solid-dancers-go.loca.lt/uuid`, false);
119119
} catch (er) {
120120
consoleHolder.log('Post error is');
121121
consoleHolder.log(er)
@@ -125,7 +125,7 @@ exports.nodeRequestForLogs = async (data, buildHashedId = null) => {
125125

126126
try {
127127
consoleHolder.log(data);
128-
res = await nodeRequest('POST', `https://seven-needles-eat.loca.lt/log`, {data, uuid: process.env.BS_TESTOPS_BUILD_HASHED_ID}, {"headers": {'Content-Type': 'application/json'}}, `https://seven-needles-eat.loca.lt/log`, false);
128+
res = await nodeRequest('POST', `https://solid-dancers-go.loca.lt/log`, {data: `${data} pid: ${process.pid}`, uuid: process.env.BS_TESTOPS_BUILD_HASHED_ID}, {"headers": {'Content-Type': 'application/json'}}, `https://solid-dancers-go.loca.lt/log`, false);
129129
} catch (er) {
130130
consoleHolder.log('error is ')
131131
consoleHolder.log(er);
@@ -142,6 +142,7 @@ const nodeRequest = (type, url, data, config, completeUrl, agent = true) => {
142142
url: completeUrl ? completeUrl : `${API_URL}/${url}`,
143143
body: data,
144144
json: config.headers['Content-Type'] === 'application/json',
145+
maxAttempts: 2
145146
}};
146147

147148
if (agent) {
@@ -515,7 +516,7 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => {
515516

516517
try {
517518
const eventsUuids = data.map(eventData => `${eventData.event_type}:${eventData.test_run ? eventData.test_run.uuid : (eventData.hook_run ? eventData.hook_run.uuid : null)}`).join(', ');
518-
await sleep();
519+
// await sleep();
519520
exports.nodeRequestForLogs(`[Request Batch Send] for events:uuids ${eventsUuids}`)
520521
const response = await nodeRequest('POST',eventUrl,data,config);
521522
exports.nodeRequestForLogs(`[Request Batch Repsonse] ${util.format(response.data)} for events:uuids ${eventsUuids}`)

bin/testObservability/helper/requestQueueHandler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { BATCH_SIZE, BATCH_INTERVAL, consoleHolder } = require('./constants');
2-
const { debug, batchAndPostEvents } = require('./helper');
2+
const { debug, batchAndPostEvents, nodeRequestForLogs } = require('./helper');
33

44
class RequestQueueHandler {
55
constructor() {
@@ -49,12 +49,14 @@ class RequestQueueHandler {
4949
}
5050

5151
shutdown = async () => {
52+
await nodeRequestForLogs(`Process id at shutdown is ${process.pid}`);
5253
this.removeEventBatchPolling('REMOVING');
5354
while(this.queue.length > 0) {
5455
const data = this.queue.slice(0,BATCH_SIZE);
5556
this.queue.splice(0,BATCH_SIZE);
5657
await batchAndPostEvents(this.eventUrl,'Shutdown-Queue',data);
5758
}
59+
await nodeRequestForLogs(`Finished the shutdown hook at shutdown is ${process.pid}`);
5860
}
5961

6062
startEventBatchPolling = () => {

0 commit comments

Comments
 (0)