Skip to content

Commit ff2294e

Browse files
authored
Merge pull request #444 from Nick-1234531/DOT-6966
create separate function for upload logs in caps, reduced debug logs
2 parents bbb9d5a + 4f1bd67 commit ff2294e

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-cli",
3-
"version": "4.1.47",
3+
"version": "4.1.48",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/lib/httpClient.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ export default class httpClient {
112112

113113
async request(config: AxiosRequestConfig, log: Logger): Promise<Record<string, any>> {
114114
log.debug(`http request: ${config.method} ${config.url}`);
115-
if (config && config.data && !config.data.skipLogging && !config.data.name && !config.data.snapshot) {
115+
if (config && config.data && !config.data.skipLogging && !config.data.name && !config.data.snapshot && config.method!=='PUT') {
116116
log.debug(config.data);
117117
}
118-
if (config && config.data && !config.data.skipLogging && config.data.snapshotUuid) {
118+
if (config && config.data && !config.data.skipLogging && config.data.snapshotUuid && config.method!=='PUT') {
119119
log.debug(config.data);
120120
}
121121
return this.axiosInstance.request(config)
@@ -615,7 +615,24 @@ export default class httpClient {
615615
}
616616

617617
uploadLogs(ctx: Context, uploadURL: string) {
618-
const logContent = fs.readFileSync(constants.LOG_FILE_PATH);
618+
const fileStream = fs.createReadStream(constants.LOG_FILE_PATH);
619+
const { size } = fs.statSync(constants.LOG_FILE_PATH);
620+
621+
return this.request({
622+
url: uploadURL,
623+
method: 'PUT',
624+
headers: {
625+
'Content-Type': 'text/plain',
626+
'Content-Length': size,
627+
},
628+
data: fileStream,
629+
maxBodyLength: Infinity, // prevent axios from limiting the body size
630+
maxContentLength: Infinity, // prevent axios from limiting the content size
631+
}, ctx.log)
632+
}
633+
634+
uploadLogsForCaps(ctx: Context, uploadURL: string) {
635+
const logContent = fs.readFileSync(constants.LOG_FILE_PATH)
619636
const { size } = fs.statSync(constants.LOG_FILE_PATH);
620637

621638
return this.request({

src/tasks/finalizeBuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
6464
if (!uploadCLILogsToS3) {
6565
ctx.log.debug(`Log file to be uploaded`)
6666
let resp = await ctx.client.getS3PreSignedURLForCaps(ctx, buildId, projectToken);
67-
await ctx.client.uploadLogs(ctx, resp.data.url);
67+
await ctx.client.uploadLogsForCaps(ctx, resp.data.url);
6868
} else {
6969
ctx.log.debug(`Log file to be uploaded via LSRS`)
7070
ctx.client.sendCliLogsToLSRSForCaps(ctx, buildId, projectToken);

0 commit comments

Comments
 (0)