Pass command Line arguments

22 views
Skip to first unread message

pandya ronak

unread,
Jun 25, 2016, 3:35:35 PM6/25/16
to scala-user
Hii,

This is related to SCALA so posted here

I m stuck in a problem need your help.
** I want that user can input 'Count, repeatCount, testServerUrl and definitionId' from command line while executing from Gatling. From command line I execute**
`

   
> export JAVA_OPTS="-DuserCount=1 -DflowRepeatCount=1 -DdefinitionId=10220101 -DtestServerUrl='https://someurl.com'"
   
> sudo bash gatling.sh`

but there is runtime error, can u please help?
Errors --------------------------------------------------------------------
` url null/api/workflows can't be parsed into a URI: scheme `

URL which I provide is shown null

Here is the code snippet,

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._        

class TestCLI extends Simulation {          
    val userCount
= Integer.getInteger("userCount", 1).toInt    
    val holdEachUserToWait
= 2  
    val flowRepeatCount
= Integer.getInteger("flowRepeatCount", 2).toInt    
    val definitionId  
= java.lang.Long.getLong("definitionId", 0L)      
    val testServerUrl
= System.getProperty("testServerUrl")

    val httpProtocol
= http
           
.baseURL(testServerUrl)
           
.inferHtmlResources()
           
.acceptHeader("""*/*""")
           
.acceptEncodingHeader("""gzip, deflate""")
           
.acceptLanguageHeader("""en-US,en;q=0.8""")
           
.authorizationHeader(envAuthenticationHeaderFromPostman)
           
.connection("""keep-alive""")
           
.contentTypeHeader("""application/vnd.v7811+json""")
           
.userAgentHeader("""Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36""")

    val headers_0
= Map(
           
"""Cache-Control""" -> """no-cache""",
           
"""Origin""" -> """chrome-extension://faswwegilgnpjigdojojuagwoowdkwmasem""")


                    val scn
= scenario("testabcd")
                       
.repeat (flowRepeatCount) {
                           
exec(http("asdfg")
                           
.post("""/api/workflows""")
                           
.headers(headers_0)
                           
.body(StringBody("""{"definitionId":$definitionId}"""))) // I also want to get this value dynamic from CLI and put here
                           
.pause(holdEachUserToWait)
                       
}                  

                    setUp
(scn.inject(atOnceUsers(userCount))).protocols(httpProtocol)

               
}


Reply all
Reply to author
Forward
0 new messages