Skip to content

Commit 137599b

Browse files
authored
Merge pull request #345 from parthlambdatest/Dot-6176
[Dot-6176] smartUI capability support in start server functionality
2 parents e857b89 + a989744 commit 137599b

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

src/commander/server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { Command } from 'commander';
22
import { Context } from '../types.js';
33
import { color, Listr, ListrDefaultRendererLogLevels } from 'listr2';
44
import startServer from '../tasks/startServer.js';
5-
import auth from '../tasks/auth.js';
5+
import authExec from '../tasks/authExec.js';
66
import ctxInit from '../lib/ctx.js';
77
import getGitInfo from '../tasks/getGitInfo.js';
8-
import createBuild from '../tasks/createBuild.js';
8+
import createBuildExec from '../tasks/createBuildExec.js';
99
import snapshotQueue from '../lib/snapshotQueue.js';
1010
import { startPolling, startPingPolling } from '../lib/utils.js';
1111

@@ -30,10 +30,10 @@ command
3030

3131
let tasks = new Listr<Context>(
3232
[
33-
auth(ctx),
33+
authExec(ctx),
3434
startServer(ctx),
3535
getGitInfo(ctx),
36-
createBuild(ctx),
36+
createBuildExec(ctx),
3737

3838
],
3939
{

src/lib/server.ts

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,44 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
118118
}
119119
}, 1000);
120120
})
121-
await ctx.client.finalizeBuild(ctx.build.id, ctx.totalSnapshots, ctx.log);
121+
122+
for (const [sessionId, capabilities] of ctx.sessionCapabilitiesMap.entries()) {
123+
try {
124+
const buildId = capabilities?.buildId || '';
125+
const projectToken = capabilities?.projectToken || '';
126+
const totalSnapshots = capabilities?.snapshotCount || 0;
127+
const sessionBuildUrl = capabilities?.buildURL || '';
128+
const testId = capabilities?.id || '';
129+
130+
if (buildId && projectToken) {
131+
await ctx.client.finalizeBuildForCapsWithToken(buildId, totalSnapshots, projectToken, ctx.log);
132+
}
133+
134+
if (testId && buildId) {
135+
buildUrls += `TestId ${testId}: ${sessionBuildUrl}\n`;
136+
}
137+
} catch (error: any) {
138+
ctx.log.debug(`Error finalizing build for session ${sessionId}: ${error.message}`);
139+
}
140+
}
141+
142+
if (ctx.build && ctx.build.id) {
143+
await ctx.client.finalizeBuild(ctx.build.id, ctx.totalSnapshots, ctx.log);
144+
let uploadCLILogsToS3 = ctx?.config?.useLambdaInternal || uploadDomToS3ViaEnv;
145+
if (!uploadCLILogsToS3) {
146+
ctx.log.debug(`Log file to be uploaded`)
147+
let resp = await ctx.client.getS3PreSignedURL(ctx);
148+
await ctx.client.uploadLogs(ctx, resp.data.url);
149+
} else {
150+
ctx.log.debug(`Skipping upload of CLI logs as useLambdaInternal is set`)
151+
}
152+
}
153+
122154
await ctx.browser?.close();
123155
if (ctx.server){
124156
ctx.server.close();
125157
}
126158

127-
let uploadCLILogsToS3 = ctx?.config?.useLambdaInternal || uploadDomToS3ViaEnv;
128-
if (!uploadCLILogsToS3) {
129-
ctx.log.debug(`Log file to be uploaded`)
130-
let resp = await ctx.client.getS3PreSignedURL(ctx);
131-
await ctx.client.uploadLogs(ctx, resp.data.url);
132-
} else {
133-
ctx.log.debug(`Skipping upload of CLI logs as useLambdaInternal is set`)
134-
// ctx.log.debug(`Log file to be uploaded via LSRS`)
135-
// let resp = ctx.client.sendCliLogsToLSRS(ctx);
136-
}
137-
138159
if (pingIntervalId !== null) {
139160
clearInterval(pingIntervalId);
140161
ctx.log.debug('Ping polling stopped immediately.');

0 commit comments

Comments
 (0)