createAndRunTest()

in lib/RunnerFiles/CreateAndRunTest.js [54:94]


    createAndRunTest() {
        return __awaiter(this, void 0, void 0, function* () {
            var _a;
            yield this.initialize();
            let testPayload = yield this.getTestPayload();
            if (this.isCreateTest) {
                console.log("Creating a new load test " + this.loadTestConfig.testId);
            }
            let createdTestObj = yield this.apiService.createTestAPI(testPayload);
            this.isCreateTest ? console.log(`Created test with id ${createdTestObj.testId}`) : console.log("Test '" + createdTestObj.testId + "' already exists");
            let testFiles = createdTestObj.inputArtifacts;
            let filesToDelete = testFiles ? (0, CreateAndRunUtils_1.getAllFileNamesTobeDeleted)(this.loadTestConfig, testFiles) : [];
            if (filesToDelete.length > 0) {
                console.log(`Deleting ${filesToDelete.length} existing test file(s) which is(are) not in the configuration yaml file.`);
            }
            for (const file of filesToDelete) {
                yield this.apiService.deleteFileAPI(file);
            }
            yield this.uploadAllTestFiles(this.loadTestConfig, this.apiService);
            let validatedTest = yield this.awaitTerminationForFileValidation(this.apiService);
            this.checkForValidationsOfTest(validatedTest);
            let appComponentsPayload = yield this.getAppComponentsPayload();
            let appComponentsResp = yield this.apiService.patchAppComponents(appComponentsPayload);
            appComponentsResp && console.log("Updated app components successfully");
            let serverMetricsConfigPayload = yield this.getServerMetricsConfigPayload();
            yield this.apiService.patchServerMetricsConfig(serverMetricsConfigPayload);
            serverMetricsConfigPayload && console.log("Updated server metrics successfully");
            console.log("Creating and running a testRun for the test");
            let testRunPayload = yield this.getTestRunPayload();
            let testRunResult = yield this.apiService.createTestRun(testRunPayload);
            this.printPortalUrl(testRunResult);
            CoreUtils.exportVariable(UtilModels_1.PostTaskParameters.runId, testRunResult.testRunId);
            yield this.awaitTerminationForTestRun(testRunResult.testRunId, this.apiService);
            testRunResult = (_a = yield this.awaitResultsPopulation(testRunResult.testRunId, this.apiService)) !== null && _a !== void 0 ? _a : testRunResult;
            CoreUtils.exportVariable(UtilModels_1.PostTaskParameters.isRunCompleted, 'true');
            this.printMetrics(testRunResult);
            yield this.uploadResultsToPipeline(testRunResult);
            this.setTaskResults(testRunResult);
            this.setOutputVariable(testRunResult);
        });
    }