Skip to content

Instantly share code, notes, and snippets.

@ctcarrier
Created April 23, 2012 16:09
Show Gist options
  • Save ctcarrier/2471958 to your computer and use it in GitHub Desktop.
Save ctcarrier/2471958 to your computer and use it in GitHub Desktop.
Gatling scenario
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import scala.util.Random
import com.excilys.ebi.gatling.core.feeder.Feeder
class ServiceSimulation extends Simulation {
def apply = {
val random = new Random
random.setSeed(System.currentTimeMillis)
val urlBase = "http://internalservice.com:8080"
val httpConf = httpConfig.baseURL(urlBase)
val customFeeder = new Feeder() {
def next = {
val email = "%s%s%s" format("SERVICETESTtwo", random.nextInt.toString, "@example.com")
Map("userEmail" -> email)
}
}
val headers_93 = Map(
"Accept" -> """application/json,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5""",
"Accept-Encoding" -> """gzip, deflate""",
"Accept-Language" -> """en-us""",
"Connection" -> """keep-alive""",
"Pragma" -> """no-cache""",
"User-Agent" -> """Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/531.21.11 (KHTML, like Gecko) Version"""
)
val saveIdChain = chain.exec(
http("postId")
.post("/internal/path/to/resource")
.fileBody("idBody", Map("email" -> "${userEmail}")).asJSON
.check(status.is(201))
)
val scn = scenario("ServiceTest1").feed(customFeeder)
.insertChain( saveIdChain )
List(
scn.configure.users(TestSettings.userCount).ramp(TestSettings.ramp).protocolConfig(httpConf)
)
}
}
object TestSettings {
val userCount = 25000
val ramp = 60
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment