I want to store returned values from scenerio1 to list and use the same stored values in another scenerio .
I tried to do like below . but in get scenerio this gives error id not found . I also noticed that feeder is initialized before scenerio execution itself.
Could some one please help on this .
var l: List[String] = List()
var ids = l.map(id => Map(“id” -> id)).iterator
val install = scenario(" Install")
.during(Configuration.duration) {
group("installTest") {
exec(
testChain.installApplication()
).exec(session=>{
l = session(“id”).as[String].trim :: l
print(l)
session
})
}
}
val get = scenario(“get”)
.during(Configuration.duration) {
group(“getTest”) {
feed(ids)
exec(
session=>{
print(session(“id”).as[String])
session
}
)
}
}
setUp(
warmupScenario.inject(constantConcurrentUsers(1) during(1))
.andThen(
install.inject(nothingFor(10 seconds), (rampUsers(Configuration.users) during (Configuration.ramp seconds))))
.andThen(
get.inject(nothingFor(Configuration.duration seconds), (rampUsers(Configuration.users) during (Configuration.ramp seconds))))
)
.assertions(details("installTest").successfulRequests.percent.gte(Configuration.passPercentage))
.protocols(HTTP_PROTOCOL)
Related
val airportCodeToTimezoneMap = Map("MAA" -> "Asia/Kolkata" , "SHJ" -> "Asia/Dubai")
val boardPoint = "MAA"
if( airportCodeToTimezoneMap.contains( boardPoint )) {
println("Code exists with value :" + airportCodeToTimezoneMap(boardPoint))
} else {
println("Code Not exist")
}
val tempValue = airportCodeToTimezoneMap(boardPoint)
println(tempValue)
Here instead of
MAP i want to configure in JSON File in HDFS path and use it .
Say For E.G
{
"airportCode": "AAL",
"zoneId": "Europe/Copenhagen"
},
{
"airportCode": "AAM",
"zoneId": "Africa/Johannesburg"
}
Please tell me how to write it .
I have an .exec which for some values in my parameter list results in KO (value does not exists in the SUT).
I further have the need to print these values to a file so I later can remove them from the parameter list in order to not get KO`s.
I have a writer defined
val writer = {
val fos = new java.io.FileOutputStream("testresultater.txt")
new java.io.PrintWriter(fos,true)
}
and wonder how I could do this just for KOs inside the .exec resulting in KOs for some values like this:
.exec(http("request_lagDokument")
.post("/proxy/dokumenter/api/v1/SaveDokumentFil?IsDebug=true")
.headers(headers_3)
.body(ElFileBody("magnus/LagDokument.json"))
.check(status.is(expected = 200))
.check(jsonPath("$.DokumentGuid").saveAs("DokumentGuid")))
//if KO then:
.exec((s: Session) => {
writer.println(s.attributes("pnr"))
s
})
Is this possible?
You can do this by having a session function that is always executed with the conditional logic inside
.exec(session = {
if (session.isFailed) {
writer.println(s.attributes("pnr"))
}
session
})
or you can use the dsl's doIf
.doIf(session => session.isFailed) {
exec(session => {
writer.println(s.attributes("pnr"))
session
}
}
case class takes 3 parameters id, applied by and internal name. Trying to make the result lenght return 3. internal name was a newly added field/parameter so that is why it is returning 0 instead of 3.
I was think to use
result.topics.find(_.topicId == "urn:emmet:1234567").get.appliedBy should be ("human") &
result.topics.find(_.topicId == "urn:emmet:2345678").get.internalName should be ("")
it's giving me syntax error, please advice thanks in advance
it should "dedup topics by id, keeping those applied by human if possible" in {
val doc = Document.empty.copy(
topics = Array(
Topic("urn:emmet:1234567", appliedBy = "machine" , internalName = ""),
Topic("urn:emmet:2345678", appliedBy = "human", internalName = ""),
Topic("urn:emmet:1234567", appliedBy = "human", internalName = ""),
Topic("urn:emmet:2345678", appliedBy = "machine", internalName = ""),
Topic("urn:emmet:3456789", appliedBy = "machine", internalName = ""),
Topic("urn:emmet:3456789", appliedBy = "machine", internalName = "")
)
)
val result = DocumentTransform.dedupSubRecords(doc)
result.topics.length should be (3)
result.topics.find(_.topicId == "urn:emmet:1234567").get.appliedBy should be ("human")
result.topics.find(_.topicId == "urn:emmet:2345678").get.appliedBy should be ("human")
result.topics.find(_.topicId == "urn:emmet:3456789").get.appliedBy should be ("machine")
}
Multiple test statements are already an 'and', because if any one of them fails the whole test fails.
val e1234567 = result.topics.find(_.topicId == "urn:emmet:1234567").get
e1234567.appliedBy shouldEqual "human"
e1234567.internalName shouldEqual ""
I want submit a form and want to show the user the process with spinner and reload the new information.
#JSExport
def addToCart(form: html.Form): Unit = {
form.onsubmit = (e: dom.Event) => {
e.preventDefault()
}
val waitSpan = span(
`class` := Waiting.glyphIconWaitClass
)
val waiting = form.getElementsByTagName("button").head.appendChild(waitSpan.render)
dom.window.alert(JSON.stringify( form.elements.namedItem("quantity") ))
Ajax.InputData
Ajax.post(form.action,withCredentials = true).map{q =>
//
}
}
I have no access to form data. Also I cannot execute an ajax call to proof the form and execute it. I have found no way. Someone has an idea?
jQuery helps. I used them now to serialize the form. But now I have no longer the ability of play forms with bindOfRequest()
val jForm = $("#"+form.id)
val serialized = jForm.serialize()
Ajax.post(s"/js/api/form/${UUID.randomUUID().toString}",withCredentials = false,timeout = 12000,data = serialized,headers = Map("X-CSRFToken"->"nocheck","Csrf-Token"->"nocheck"))
I get always:
occurrence%5B%5D=400g&quantity=1&csrfToken=c1606da9a261a7f3284518d4f1fd63eaa8bbb59e-1483472204854-1c5af366c62520883474c160
But now I don´t know what I have to do. Sorry.
def executeAddToCartForm(articleId: UUID) = silhouette.UserAwareAction.async{implicit req =>
val form = complexCartForm.bindFromRequest()
Try(form.get) match {
case Success((i,seq)) => println("article: " + i)
case _ => println(form.errors.mkString + " " + req.body.asText + " " + URLDecoder.decode(req.body.asText.get,"UTF-8"))
}
Future.successful(Ok("danke"))
}
Always get failure :( I will have a look at react.
ADDED
Sometimes I need more sleep!
Ajax.post(
url = form.action,
withCredentials = true,
timeout = 12000,
data = serialized,
headers = Map("Content-Type" -> "application/x-www-form-urlencoded")
)
with this: headers = Map("Content-Type" -> "application/x-www-form-urlencoded") I can use the bindFromRequest() as usually :)
Coffee I need more
Using Squeryl ORM and Scala. For the first time I did a JOIN statement that used grouping. Admittedly, I can't figure out how to start iterating through the contents.
Here's the JOIN:
join(DB.jobs, DB.users.leftOuter, DB.clients.leftOuter, DB.projects.leftOuter)((j,u,c,p) =>
where((j.teamId === teamId)
and (j.startTime > yesterdayBegin))
groupBy(j.userId)
on(j.userId === u.map(_.id), j.clientId === c.map(_.id), j.projectId === p.map(_.id)))
How do I print out its contents?
I tried:
Job.teamTimeline( teamId(request) ).map{ user => Map(
"name" -> user._1.map(_.name).getOrElse("Pending")
)}
But got the compiler error:
value _1 is not a member of org.squeryl.dsl.Group[Option[org.squeryl.PrimitiveTypeMode.LongType]]
Max the great was able to help out on the mailing list. I almost had the syntax right.
His response:
replace :
groupBy(j.userId)
by:
groupBy(j.userId, j.name)
then :
timelineLookup.map{ group => Map(
"name" -> group.key._2.getOrElse("Pending")
)}
Source: https://groups.google.com/forum/?fromgroups#!topic/squeryl/sJ05He-4F3I