stack twitter tryhackme rss linkedin cross

Wilco van Esch

Skip to main content

Search results

    Examples of LUA usage in LoadImpact test scenarios

    GET request

    http.request_batch({
    	{"GET", "http://subdomain.domain.co.uk/",
      auto_decompress=true}
    })
    

    To take the effort out of gathering all relevant page requests, you can use LoadImpact's User Scenario Recorder and manually adjust the requests.

    POST request

    http.request_batch({
    	{"POST",
      "https://subdomain.domain.co.uk/",
    	headers={["X-Requested-With"]=
    	"XMLHttpRequest, XMLHttpRequest",
    	["Content-Type"]="application/
    	x-www-form-urlencoded; charset=UTF-8"},
      data="X-Requested-With=
      XMLHttpRequest&nonJsSearch=false
      &searchTerm=", auto_decompress=true}
    })

    Log in

    http.request_batch({
    	{"POST",
      "https://subdomain.domain.co.uk/AjaxSignIn",
    	headers={["X-Requested-With"]="XMLHttpRequest,
    	XMLHttpRequest",["Content-Type"]=
    	"application/x-www-form-urlencoded;
      charset=UTF-8"},
      data="Password=userpassword&RememberMe=false
      &SignInUrl=%2F&UserName=useremail
      &X-Requested-With=XMLHttpRequest",
      auto_decompress=true}
    })

    Sleep

    client.sleep(3)

    Of course the duration can be adjusted at will. It is measured in seconds.

    Identify the boundaries of a page metric.

    http.page_start("Page 1")
    
    page requests go here
    
    http.page_end("Page 1")

    Looping

    for loopCount = 10 do
    	something ten times
    end
    for loopCount = 11, 21 do
    	something ten times, enumerated as 11 to 21
    end

    String interpolation

    for loopCount = 10 do
    	http.page_start("Page .. loopCount .. ")
    	page requests go here
    	http.page_end("Page .. loopCount ..")
    end

    Redirect HTTP & HTTPS traffic to specific server IP

    util.dns_remap("http://subdomain.domain.co.uk",
    "95.95.95.95")
    util.dns_remap("http://subdomain.domain.co.uk:443",
    "95.95.95.95")