public async createAndRunTest()

in src/RunnerFiles/CreateAndRunTest.ts [26:73]


    public async createAndRunTest() {
        await this.initialize();
        let testPayload = await this.getTestPayload();

        if(this.isCreateTest) {
            console.log("Creating a new load test " + this.loadTestConfig.testId);
        }

        let createdTestObj = await 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 ? 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){
            await this.apiService.deleteFileAPI(file);
        }
    
        await this.uploadAllTestFiles(this.loadTestConfig, this.apiService);
        let validatedTest = await this.awaitTerminationForFileValidation(this.apiService) as TestModel;
        this.checkForValidationsOfTest(validatedTest);
    
        let appComponentsPayload = await this.getAppComponentsPayload();
        let appComponentsResp = await this.apiService.patchAppComponents(appComponentsPayload);
        appComponentsResp && console.log("Updated app components successfully");
    
        let serverMetricsConfigPayload = await this.getServerMetricsConfigPayload();
        await this.apiService.patchServerMetricsConfig(serverMetricsConfigPayload);
        serverMetricsConfigPayload && console.log("Updated server metrics successfully");
    
        console.log("Creating and running a testRun for the test");
        let testRunPayload : TestRunModel = await this.getTestRunPayload();
        let testRunResult = await this.apiService.createTestRun(testRunPayload);
        this.printPortalUrl(testRunResult);
    
        CoreUtils.exportVariable(PostTaskParameters.runId, testRunResult.testRunId);
    
        await this.awaitTerminationForTestRun(testRunResult.testRunId, this.apiService);
        testRunResult = await this.awaitResultsPopulation(testRunResult.testRunId, this.apiService) ?? testRunResult;
        CoreUtils.exportVariable(PostTaskParameters.isRunCompleted, 'true');
    
        this.printMetrics(testRunResult);
        await this.uploadResultsToPipeline(testRunResult);
        this.setTaskResults(testRunResult);
        this.setOutputVariable(testRunResult);
    }