Load Testing Tool | Vegeta | API Vegeta testing tool

For Ubuntu

  1. Install in ubuntu
        wget https://github.com/tsenart/vegeta/releases/download/cli%2Fv12.5.1/vegeta-12.5.1-linux- amd64.tar.gz
            tar xfz vegeta-12.5.1-linux-amd64.tar.gz
              mv vegeta /usr/bin/vegeta #try with root user permission

      Shell Script to run 
      1. Create a file vegeta_ubuntu.sh and paste following code

      #!/bin/bash
      touch post_targets.list #creating a file
      truncate -s 0 post_targets.list
      cat >./post_body.json <<EOF
       {

          "wifi": {

            "ssid": "$SSID",

            "pw":   "$PW"

          }

        }

      EOF

      echo 'PUT https://staging-sps.luxola.com/api/v2.5/ba/wishlist/variants/202146?card_number=6501087579617' > post_targets.list
      echo 'X-Site-Country:SG' >> post_targets.list
      echo 'X-App-Version: 1.0.0'  >> post_targets.list
      echo 'X-App-Platform: mobile_app'  >> post_targets.list
      echo 'Authorization:Bearer eyJraWQiOiJXWGZCdjZWQ2xLY09KOGJBVmhlZWRHLXI1ZVhNOUI4eXFUdzFHWjBmWk5zIiwiYWxnIjoiRVMyNTYifQ.eyJzZXBob3JhL2JhaWQiOiIxOSIsInNlcGhvcmEvc3RvcmVjb2RlIjoiMTQ4OSIsInN1YiI6IiIsImlhdCI6MTYyNTgxMzk1MCwiZXhwIjoxNjI1ODIxMTUwLCJqa3UiOiJodHRwczovL2FwaS5zZXBob3JhLnNnL2FwaS9hdXRoL2NlcnRzIiwiY291bnRyeSI6IlNHIiwidGVuYW50IjoibHhfZGVmYXVsdCIsInNjb3BlIjpbImJhIl19.cYXDCHi_oi-zOfHQi8ryS6vNhTABRuwXU4mwEAtW9XiUY9_KK-WOJ79QYubtx3bNgxaaxwkAdw_BrxFMKILb7A' >> post_targets.list

      echo 'Content-Type: application/json' >> post_targets.list
      #creating body of post or put request
      echo @./post_body.json >> post_targets.list

      DURATION="1s"  #Duration of the test

      REQUESTS=1 #Number of requests per time unit [0 = infinity] (default 50/1s)

      TIMEOUT="10s" #Requests timeout (default 30s)

      WORKERS=1       #Initial number of workers (default 10)

      # Setting -max-workers to a very high number while setting -rate=0 can result in vegeta consuming too many resources and crashing. Use with care.

      cat post_targets.list

      vegeta attack -rate=$REQUESTS -duration=$DURATION -workers=$WORKERS -targets=post_targets.list -timeout=$TIMEOUT | vegeta report  #if you want to print time on console

      # vegeta attack -rate=$REQUESTS -duration=$DURATION -workers=$WORKERS -targets=post_targets.list -timeout=$TIMEOUT # if you want to print response data on console

      ##below 4 commands for generating plot 

      # touch results.html #creating a file

      # truncate -s 0 results.html attack-5.bin

      # PLOTDURATION="5s"

      # PLOTREQUESTS=2

      # PLOTTIMEOUT=30s

      # vegeta attack -workers=$WORKERS -duration=$PLOTDURATION -rate=$PLOTREQUESTS -targets=post_targets.list -timeout=$PLOTTIMEOUT -output=attack-5.bin

      # vegeta plot -title=Attack%20Results attack-5.bin > results.html


      Popular posts from this blog

      Completely uninstall elasticsearch in Linux

      Install Elastic search 5.x in ubuntu 20, 18, 16