简体   繁体   中英

How can I exec shell scripts from within a Gatling simulation?

I want to add a scenario that runs in parallel to my main http-based scenarios to introduce errors into the environment (by deleting application instances etc.)

I can't see a way to do this from Gatling. What I want is something that looks a little like this:

exec({
  "chaos.sh" !
}).pause(10)
.exec({
  "firewallService.sh enable" !
})

etc.

Is this possible with Gatling?

I found a workaround to this problem that avoids trying to write a custom Action and ActionBuilder. It boils down to putting it within a code block elsewhere, like a session builder element:

exec(session => {
  val scriptOutput = "/My/Chaos/Script.sh".!!
  println(s"""Chaos invoked: ${scriptOutput} """)
  session
})

I picked this because it keeps the test simple, and because all the examples I found for actually writing Actions etc. used Gatling code that had since been refactored. There doesn't seem to be an up-to-date documentation page for this feature

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM