Efficiency testing is essential to software program improvement. It ensures your utility can deal with excessive site visitors and utilization with out crashing or slowing down. Many instruments can be found for efficiency testing, however two standard ones are k6 and Postman. This information will present you the right way to do efficiency testing on Ubuntu utilizing K6 and Postman-to-k6.
K6 is a well-liked open-source software for efficiency and load-testing net functions, constructed on prime of the Go programming language, with developer-friendly options. For instance, it provides real-time check efficiency suggestions, simple integration with CI/CD pipelines, and a cloud-based testing service to simulate concurrent customers. As well as, K6’s massive open-source neighborhood contributes to its improvement and helps builders worldwide. General, K6 is a strong and versatile software that is a wonderful selection for optimizing utility efficiency.
Postman-to-k6 converts Postman collections into k6 scripts for efficiency and cargo testing, saving builders effort and time. It promotes collaboration amongst workforce members by offering a standard testing framework for sharing and bettering exams. Utilizing the identical exams for purposeful and efficiency testing helps to establish and handle efficiency points early within the improvement cycle, bettering net utility efficiency and reliability. By leveraging the strengths of each Postman and k6, builders can optimize their net functions’ efficiency and reliability with Postman-to-k6.
The simplest strategy to set up k6 on Ubuntu is through the use of a package deal supervisor corresponding to Snap or Apt.
You possibly can set up k6 utilizing the next Snap command. Nevertheless, operating k6 utilizing Snap could cause permission points when operating exams. So, use this technique in case you are acquainted with Snap.
Alternatively, you possibly can obtain the binary from the official k6 web site and set up it manually.
Right here’s how to do this:
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb secure major" | sudo tee /and so forth/apt/sources.checklist.d/k6.checklist
sudo apt-get replace
sudo apt-get set up k6
To make use of Postman-to-k6, you could set up the software utilizing npm (Node Package deal Supervisor). Right here’s the right way to set up npm on Ubuntu:
sudo apt replace
sudo apt set up nodejs npm
As soon as npm is put in, you should utilize it to put in Postman-to-k6:
npm set up -g postman-to-k6
To transform a Postman assortment to a k6 script utilizing Postman-to-k6, use the next command:
postman-to-k6 /path/to/assortment.json > check.js
You’ll want to substitute /path/to/assortment.json with the file path to your Postman assortment. This may output the transformed k6 script to a file known as check.js.
Now that you’ve a k6 script primarily based in your Postman assortment, you possibly can run a efficiency check utilizing k6.
Right here’s an instance command to run a check with 10 digital customers and a length of 30 seconds:
k6 run --vus 10 --duration 30s check.js
This command runs the check.js script with 10 digital customers (–vus 10) for a length of 30 seconds (–length 30s).
After the check is full, k6 will output detailed outcomes and metrics that can be utilized to investigate check efficiency.
Right here’s an instance output:
data_received..............: 300 MB
data_sent..................: 150 MB
http_req_blocked...........: avg=1.39ms min=0s med=160µs max=2.24s p(90)=444µs p(95)=678µs
http_req_connecting........: avg=1.2ms min=0s med=0s max=27.35s p(90)=0s p(95)=0s
http_req_duration..........: avg=146.11ms min=10.56ms med=89.2ms max=1.62s p(90)=276.2ms p(95)=376.32ms
http_req_receiving.........: avg=6.36ms min=0s med=4.95ms max=405.49ms p(90)=11.14ms p(95)=15.01ms
http_req_sending...........: avg=154.36µs min=0s med=119µs max=16.12ms p(90)=225µs p(95)=285µs
http_req_tls_handshaking...: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...........: avg=139.24ms min=6.64ms med=84.72ms max=1.6s p(90)=258.15ms p(95)=357.69ms
http_reqs..................: 2000 33.330417/s
iterations.................: 2000 33.330417/s
vus........................: 100 min=100 max=100
These metrics can be utilized to establish efficiency points and fine-tune your utility’s efficiency. For instance, you could wish to analyze metrics like http_req_duration, http_req_waiting, or http_req_connecting to see any bottlenecks in your utility’s community or server infrastructure.
In conclusion, efficiency testing is essential for guaranteeing your utility can deal with excessive site visitors and utilization with out crashing or slowing down. With the assistance of k6 and Postman-to-k6, you possibly can rapidly and simply create and run efficiency exams in your utility to establish and optimize its efficiency.
We’ve lined the fundamentals of k6 and its options, the advantages of utilizing Postman-to-k6 for efficiency testing, and the right way to arrange and configure k6 and Postman-to-k6 on Ubuntu. By following the steps outlined on this submit, you possibly can create and run efficiency exams in your utility and establish any bottlenecks or efficiency points that have to be addressed.
Whether or not you’re a developer, QA engineer, or DevOps skilled, incorporating efficiency testing into your improvement course of is important for delivering high-quality functions that deal with excessive site visitors and utilization. We hope this submit has supplied an excellent start line for utilizing k6 and Postman-to-k6 on Ubuntu to carry out efficient efficiency testing and optimize your utility’s efficiency.