@hypertestco/ht-cli-v3 0.0.1-81 → 0.0.1-83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +115 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -30252,7 +30252,7 @@ var loadEnv = ({ throws } = { throws: true }) => {
|
|
|
30252
30252
|
};
|
|
30253
30253
|
|
|
30254
30254
|
// ../../package.json
|
|
30255
|
-
var version = "0.0.1-
|
|
30255
|
+
var version = "0.0.1-83";
|
|
30256
30256
|
|
|
30257
30257
|
// ../utils/commonPackages/debug.ts
|
|
30258
30258
|
var import_debug = __toESM(require_src());
|
|
@@ -30265,6 +30265,14 @@ var sleep_default = (milliseconds) => new Promise((resolve2) => {
|
|
|
30265
30265
|
|
|
30266
30266
|
// ../utils/types/index.ts
|
|
30267
30267
|
var import_generatedClient = __toESM(require_generatedClient());
|
|
30268
|
+
var RISK_LEVEL_WEIGHTAGE = {
|
|
30269
|
+
[import_generatedClient.RequestReviewSeverity.CRITICAL]: 100,
|
|
30270
|
+
[import_generatedClient.RequestReviewSeverity.HIGH]: 75,
|
|
30271
|
+
[import_generatedClient.RequestReviewSeverity.MEDIUM]: 50,
|
|
30272
|
+
[import_generatedClient.RequestReviewSeverity.LOW]: 25,
|
|
30273
|
+
[import_generatedClient.RequestReviewSeverity.VERY_LOW]: 10,
|
|
30274
|
+
"NONE": 0
|
|
30275
|
+
};
|
|
30268
30276
|
|
|
30269
30277
|
// ../backend/src/trpc/client/index.ts
|
|
30270
30278
|
var import_zlib = __toESM(require("zlib"));
|
|
@@ -32661,6 +32669,20 @@ var backendClient = {
|
|
|
32661
32669
|
trpcClient.versions.getVersions.query,
|
|
32662
32670
|
input
|
|
32663
32671
|
);
|
|
32672
|
+
},
|
|
32673
|
+
GET_REVIEW_STATUS_BY_REVIEW_ID(input) {
|
|
32674
|
+
return callAPI(
|
|
32675
|
+
"review.getReviewStatusByReviewId",
|
|
32676
|
+
trpcClient.review.getReviewStatusByReviewId.query,
|
|
32677
|
+
input
|
|
32678
|
+
);
|
|
32679
|
+
},
|
|
32680
|
+
GET_ALL_REQUEST_REVIEWS_BY_REVIEW_ID(input) {
|
|
32681
|
+
return callAPI(
|
|
32682
|
+
"requestReview.getAllRequestReviewsByReviewId",
|
|
32683
|
+
trpcClient.requestReview.getAllRequestReviewsByReviewId.query,
|
|
32684
|
+
input
|
|
32685
|
+
);
|
|
32664
32686
|
}
|
|
32665
32687
|
};
|
|
32666
32688
|
|
|
@@ -42241,25 +42263,25 @@ Test will commence in 10 seconds.
|
|
|
42241
42263
|
});
|
|
42242
42264
|
debug4("hypertest backend ping response", data);
|
|
42243
42265
|
} catch (e) {
|
|
42244
|
-
console.
|
|
42266
|
+
console.error("Error connecting to hypertest backend. #SNT-001", e);
|
|
42245
42267
|
process.exit(1);
|
|
42246
42268
|
}
|
|
42247
42269
|
let cliToken;
|
|
42248
42270
|
try {
|
|
42249
42271
|
cliToken = await backendAuthInit();
|
|
42250
42272
|
} catch (e) {
|
|
42251
|
-
console.
|
|
42273
|
+
console.error("Error getting cli token. #SNT-002", e);
|
|
42252
42274
|
process.exit(1);
|
|
42253
42275
|
}
|
|
42254
42276
|
const { data: userData, err: err1 } = await backendClient.GET_USER_FROM_AUTH_TOKEN({
|
|
42255
42277
|
cliToken
|
|
42256
42278
|
});
|
|
42257
42279
|
if (err1) {
|
|
42258
|
-
console.
|
|
42280
|
+
console.error("Error getting user details from cli token. #SNT-003", err1);
|
|
42259
42281
|
process.exit(1);
|
|
42260
42282
|
}
|
|
42261
42283
|
if (!((userData == null ? void 0 : userData.userId) && (userData == null ? void 0 : userData.email))) {
|
|
42262
|
-
console.
|
|
42284
|
+
console.error(
|
|
42263
42285
|
"User details returned from cli token are invalid. #SNT-004",
|
|
42264
42286
|
userData
|
|
42265
42287
|
);
|
|
@@ -42291,16 +42313,96 @@ Test will commence in 10 seconds.
|
|
|
42291
42313
|
testTypes: startTestParams.requestTypesToTest
|
|
42292
42314
|
});
|
|
42293
42315
|
if (startAiTestRes.err) {
|
|
42294
|
-
console.
|
|
42295
|
-
|
|
42296
|
-
|
|
42297
|
-
|
|
42316
|
+
console.error("Error starting test. #SNT-005", startAiTestRes.err);
|
|
42317
|
+
if (!startAiTestRes.err.message.startsWith("No requests found in service")) {
|
|
42318
|
+
console.error(
|
|
42319
|
+
"Test could not be started due to above error. Please fix the error and try again."
|
|
42320
|
+
);
|
|
42321
|
+
process.exit(1);
|
|
42322
|
+
}
|
|
42323
|
+
} else if (startAiTestRes.data.reviewId) {
|
|
42324
|
+
const reviewId = startAiTestRes.data.reviewId;
|
|
42298
42325
|
console.log("Test Started");
|
|
42299
42326
|
console.log(
|
|
42300
|
-
`Please go to ${startTestParams.htBackendBaseUrl}/dashboard/#/services/${serviceId.toString()}/testResults?testId=${
|
|
42327
|
+
`Please go to ${startTestParams.htBackendBaseUrl}/dashboard/#/services/${serviceId.toString()}/testResults?testId=${reviewId} to see the test results`
|
|
42301
42328
|
);
|
|
42329
|
+
if (options.waitForTestCompletion) {
|
|
42330
|
+
const terminalStates = [
|
|
42331
|
+
import_generatedClient.ReviewStatus.FORCED_FINISHED,
|
|
42332
|
+
import_generatedClient.ReviewStatus.TEST_START_FAILED,
|
|
42333
|
+
import_generatedClient.ReviewStatus.FINISHED,
|
|
42334
|
+
import_generatedClient.ReviewStatus.TERMINATED,
|
|
42335
|
+
import_generatedClient.ReviewStatus.TIMED_OUT,
|
|
42336
|
+
import_generatedClient.ReviewStatus.SKIPPED,
|
|
42337
|
+
import_generatedClient.ReviewStatus.MERGE_CONFLICT
|
|
42338
|
+
];
|
|
42339
|
+
console.log("Waiting for test completion...");
|
|
42340
|
+
const timeoutMs = 30 * 60 * 1e3;
|
|
42341
|
+
const startTime = Date.now();
|
|
42342
|
+
let finalStatus;
|
|
42343
|
+
while (true) {
|
|
42344
|
+
if (Date.now() - startTime > timeoutMs) {
|
|
42345
|
+
console.error("Timeout: Test polling exceeded 30 minutes.");
|
|
42346
|
+
process.exit(1);
|
|
42347
|
+
}
|
|
42348
|
+
try {
|
|
42349
|
+
const res = await backendClient.GET_REVIEW_STATUS_BY_REVIEW_ID({
|
|
42350
|
+
serviceId: BigInt(serviceId),
|
|
42351
|
+
reviewId: BigInt(reviewId)
|
|
42352
|
+
});
|
|
42353
|
+
if (res.err) {
|
|
42354
|
+
console.error("Error fetching review status:", res.err);
|
|
42355
|
+
} else if (res.data) {
|
|
42356
|
+
const status = res.data.reviewStatus;
|
|
42357
|
+
if (status && terminalStates.includes(status)) {
|
|
42358
|
+
finalStatus = status;
|
|
42359
|
+
break;
|
|
42360
|
+
}
|
|
42361
|
+
}
|
|
42362
|
+
} catch (e) {
|
|
42363
|
+
console.error("Transient network error during status check:", e);
|
|
42364
|
+
}
|
|
42365
|
+
await sleep_default(15e3);
|
|
42366
|
+
}
|
|
42367
|
+
console.log(`Final reviewStatus: ${finalStatus}`);
|
|
42368
|
+
try {
|
|
42369
|
+
const resFinal = await backendClient.GET_ALL_REQUEST_REVIEWS_BY_REVIEW_ID({
|
|
42370
|
+
serviceId: BigInt(serviceId),
|
|
42371
|
+
reviewId: BigInt(reviewId)
|
|
42372
|
+
});
|
|
42373
|
+
if (resFinal.err) {
|
|
42374
|
+
console.error("Error fetching review data:", resFinal.err);
|
|
42375
|
+
} else {
|
|
42376
|
+
console.log("Final Review Data:");
|
|
42377
|
+
console.log(JSON.stringify(resFinal.data, null, 2));
|
|
42378
|
+
}
|
|
42379
|
+
} catch (e) {
|
|
42380
|
+
console.error(
|
|
42381
|
+
"Transient network error during final data retrieval:",
|
|
42382
|
+
e
|
|
42383
|
+
);
|
|
42384
|
+
}
|
|
42385
|
+
if (finalStatus) {
|
|
42386
|
+
process.exitCode = getExitCodeForReviewStatus(finalStatus);
|
|
42387
|
+
}
|
|
42388
|
+
}
|
|
42302
42389
|
}
|
|
42303
42390
|
}
|
|
42391
|
+
var getExitCodeForReviewStatus = (status) => {
|
|
42392
|
+
switch (status) {
|
|
42393
|
+
case import_generatedClient.ReviewStatus.FINISHED:
|
|
42394
|
+
case import_generatedClient.ReviewStatus.FORCED_FINISHED:
|
|
42395
|
+
case import_generatedClient.ReviewStatus.SKIPPED:
|
|
42396
|
+
return 0;
|
|
42397
|
+
case import_generatedClient.ReviewStatus.TEST_START_FAILED:
|
|
42398
|
+
case import_generatedClient.ReviewStatus.TERMINATED:
|
|
42399
|
+
case import_generatedClient.ReviewStatus.TIMED_OUT:
|
|
42400
|
+
case import_generatedClient.ReviewStatus.MERGE_CONFLICT:
|
|
42401
|
+
return 1;
|
|
42402
|
+
default:
|
|
42403
|
+
return 1;
|
|
42404
|
+
}
|
|
42405
|
+
};
|
|
42304
42406
|
|
|
42305
42407
|
// src/index.ts
|
|
42306
42408
|
BigInt.prototype.toJSON = function() {
|
|
@@ -42316,6 +42418,9 @@ program.name("htcli");
|
|
|
42316
42418
|
program.command("start-new-test").description("starts a new test on hypertest").requiredOption(
|
|
42317
42419
|
"--config-file-path <config-file-path>",
|
|
42318
42420
|
"path to the ht config js file"
|
|
42421
|
+
).option(
|
|
42422
|
+
"--wait-for-test-completion",
|
|
42423
|
+
"wait for test completion and print the test output at the end on stdout"
|
|
42319
42424
|
).action(startNewTest);
|
|
42320
42425
|
program.parse();
|
|
42321
42426
|
/*! Bundled license information:
|