Posts

Script for replace the data into the file content using groovy with jsr223

Image
import java.nio.file.* def usdcor = vars.get('TestData_name') //TestData_name was defined in userdefined or any corralted value log.info("Current Working Directory: " + System.getProperty("user.dir")) // Path to the file to be updated def filePath = "./Scripts/file.txt" // Replace with your file's path // Define the new content def newData = "This is the new content being added./\n   asdfasdfasdfasdfsadf" + usdcor try {     // Overwrite the file with the new content (clears the old data)     Files.write(Paths.get(filePath), newData.getBytes())     log.info("File content replaced successfully!") } catch (Exception e) {     log.error("Error while updating the file: " + e.getMessage()) }

Convert Swagger apis into jmeter script

Method #1 1. Download "openapi-generator-cli-7.9.0.jar" from https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/ 2. get the json file from swagger 3. execute the below command in cmd prompt  java -jar openapi-generator-cli-7.9.0.jar generate -i sampleAPI.json -g jmeter  Note:  java should be  in env variables and jar be in  the same path Method #2 import to Postman and export each API with the curl command copy the curl command and Jmeter->Tools->import from cUrl-> place the command and import. Note: Manual effort and recommended for specific APIs 

How to Monitor Metrics in jmeter

Image
  Sub: They are two things in on-prime one is with overall CPU and memory i.e., server-level another one is to validate the process level i.e, PID while checking with TOP command in Linux or  monitoring in permon in windows. 1. For monitoring Linux server level we can use "SSHMon Sample Collector" which - sar -u 1 1 |awk '/^Average:/{print 100-$8}' For CPU - sar -b 1 1 | awk '/^Average:/ {print 0 + $2}' For I/O - sar -S 1 1 | awk '/^Average:/ {print 0 + $6}' For SWAP     This collector gets the samples with out agent and these are for global Samples for the hosts 2. For Monitoring Individual processes like tomcat, notification microservice, Orientdb service, and java services we need to install Perfmon agent in Linux servers. Steps to install perfmon : 1. create a folder and give full permissions like sudoers and download the software from wget  wget https://github.com/undera/perfmon-agent/releases/download/2.2.3/ServerAgent-2.2.3.zip . 2. unzip Server...

Simple foreach controller

Image
 Def: How to use simple controller - If we have any dynamic requests which have a dependent on previous call how we can handle Here we capture the all variables as shown below 2. now for the second Request in the controller

how to make passwordless communication between multiple hosts

  Sub: while doing cluster environment we required multiple nodes. hence for this, all servers should communicate with each other without credentials  EX: for example, three nodes like host1, host2, and host3 are 3 servers when you are in host1 terminal you can directly be moved to host2 without any new terminal by  > ssh host2  [ now without asking password you will be moved to host2 from host1 ] Setup : 1.  vi /etc/hosts 2.    Adding related hosts  in all places. Ie.,  hostip1 hostname1  hostip2 hostname2 hostip3 hostname3 3. SSH communication  [Generate SSH key passwordless]   [root@Host1]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): New Section 1 Page 3 Enter passphrase (empty for no passphrase): 4.  ssh-copy-...

Using Maps And for each loop in jmeter

Image
  - This is for use for each loop controller  - generally, it's based on a previous request no of requests will come in another transaction controller - using Regular expressions to get all details now its tome to use in loop, based on this results in its iterates 8 times in JSR223 preprocessor - assigning values using the map  now we have 2 variables : stakeholdercommunityfacets , keyvalueMap Now using return stakeholders  Now the number is the final variable with 8 iterations used in the following request.

Dynamic JSON Request based on previous request.

Image
 This explains the Dynamic Request based on the previous requests. Here is the second request based on the previous response.  In request 1: the response was like this Response: In the below response we have 5 collections [{"dataCollectionId":"3640e3ab-79d8-4d5c-a416-0381091349a2","dataCollectionName":"DC_02_042","orderCount":1},{"dataCollectionId":"6008171e-a070-49ba-828d-093e6336482f","dataCollectionName":"DC_03_013","orderCount":1},{"dataCollectionId":"7ec9ef40-f349-47ff-8699-ad8d1babe7e6","dataCollectionName":"DC_03_078","orderCount":1},{"dataCollectionId":"ac163d5f-ec0b-4635-aff8-e7a4533d2f1d","dataCollectionName":"DC_01_046","orderCount":1},{"dataCollectionId":"c33ebafd-0be4-41c2-ad3a-b906d7af1a1c","dataCollectionName":"DC_04_081","orderCo...