Performance Tool(4)CSV File Data Feeder

Performance Tool(4)CSV File Data Feeder

Using CSV File Feeder
val callbackDevice = exec(http("push_callback_events")
    .post("/api/brands/"+ brand + "/events")
    .body(EventJSONEntities.pushCallbackEventJson("${deviceId}", "${latitude}","${longitude}", appId, campaignId))
    .headers(headers)
    .check(status.is(200))
    .check(bodyString))

val latlngFeed = csv("latlng_information.csv”)
val multiScn = scenario("Push Callback Events Scenario")
    .repeat(repeatTimes){ feed(latlngFeed).feed(deviceRegFeed).exec(callbackDevice) }


Content of latlng_information.csv
latitude,longitude
-97.741921,30.359960
-97.732911,30.341110
-92.934343,31.313434

Generate CSV File
package apps

import base.Environment
import com.excilys.ebi.gatling.core.Predef._
import events.EventFeeds
import java.util.concurrent.atomic.AtomicInteger
import org.joda.time.DateTime
import java.io.File
import scala.io.Source

/**
 * Created by carl on 7/28/14.
 */
object FailDeviceFinder extends Environment {

  def main(args: Array[String]) {
  val deviceRegFeed = EventFeeds.deviceStableFeeder(5)

  val src = Source.fromFile(new File("userfiles/data/serveraws1_device.csv")).getLines
  //val headerLine = src.take(1).next

  val csvMap = src.toList

  printToFile(new File("userfiles/data/serveraws1_fails.csv"))( p =>{
    p.println("deviceId,regKey")
    while(deviceRegFeed.hasNext) {
    val n = deviceRegFeed.next
    val deviceId = n.getOrElse("deviceId","null")
    val regKey = n.getOrElse("regKey","null")
    if(!csvMap.contains(deviceId)){
      p.println(deviceId + "," + regKey)
    }
    }
  })

  }


  def printToFile(f: java.io.File)(op: java.io.PrintWriter => Unit) {
    val p = new java.io.PrintWriter(f)
    try { op(p) } finally { p.close() }
  }

}

All the example is here:
https://github.com/luohuazju/sillycat-gatling/tree/gatling-1.5.6


References:
http://sillycat.iteye.com/blog/2096198



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值