...
 
Commits (1)
package de.thm.arsnova
import de.thm.arsnova.auditor.BasicAuditorSimulation
import de.thm.arsnova.tutor.BasicTutorSimulation
import de.thm.arsnova.auditor.BasicAuditorScenario
import de.thm.arsnova.tutor.BasicTutorScenario
import io.gatling.core.Predef._ // 2
import io.gatling.http.Predef._
......@@ -20,23 +20,8 @@ class Stresstest extends Simulation {
.doNotTrackHeader("1")
.userAgentHeader("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0")
val headers_0 = Map("Upgrade-Insecure-Requests" -> "1")
val uri1 = "http://localhost:9000/session/1"
val auditorScn = scenario("Test").exec(
BasicAuditorSimulation.joinSession.pause(3),
BasicAuditorSimulation.getAllPrepQuestions.pause(3),
BasicAuditorSimulation.answerToMCQuestion
)
val tutorScn = scenario("Basic Tutor").exec(
BasicTutorSimulation.createSession.pause(3),
BasicTutorSimulation.createQuestion
)
setUp(
auditorScn.inject(rampUsers(1000) over (5 seconds)),
tutorScn.inject(rampUsers(100) over (5 seconds))
BasicTutorScenario.scn.inject(rampUsers(100) over (5 seconds)),
BasicAuditorScenario.scn.inject(rampUsers(1000) over (5 seconds))
).protocols(httpProtocol)
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import scala.concurrent.duration._
import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
object BasicAuditorSimulation {
object BasicAuditorScenario {
import de.thm.arsnova.mappings.ChoiceAnswerJsonProtocol._
val joinSession = exec(http("Auditor joins session")
......@@ -25,4 +25,10 @@ object BasicAuditorSimulation {
.post("/question/5/choiceAnswer")
.header("Content-Type", "application/json")
.body(StringBody(newAnswer.toJson.toString)).asJSON)
val scn = scenario("Test").exec(
joinSession.pause(3),
getAllPrepQuestions.pause(3),
answerToMCQuestion
)
}
\ No newline at end of file
package de.thm.arsnova.tutor
import de.thm.arsnova.models.{AnswerOption, Question, Session}
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import java.util.Calendar
object BasicTutorScenario extends TutorScenario {
val mcAnswerOptions = Seq(
AnswerOption(None, None, false, "12", -10),
AnswerOption(None, None, true, "13", 10),
AnswerOption(None, None, false, "14", -10),
AnswerOption(None, None, true, "thirteen", 10)
)
val newMCQuestion = Question(None, 0, "new Question Subject", "This is an MC question for stress testing",
"preparation", "mc", Some("This is the hint!"), Some("The answer is 13"), true, false, true, true, false, None, Some(mcAnswerOptions))
val scn = scenario("Basic Tutor").exec(
createSession(basicNewSession),
createQuestion(newMCQuestion, "mc")
)
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import java.util.Calendar
object BasicTutorSimulation {
object FlashcardTutorScenario {
import de.thm.arsnova.mappings.QuestionJsonProtocol._
import de.thm.arsnova.mappings.SessionJsonProtocol._
......@@ -22,17 +22,20 @@ object BasicTutorSimulation {
AnswerOption(None, None, false, "14", -10),
AnswerOption(None, None, true, "thirteen", 10)
)
val newMCQuestion = Question(None, 1, "new Question Subject", "This is an MC question for stress testing",
"preparation", "mc", Some("This is the hint!"), Some("The answer is 13"), true, false, true, true, false, None, Some(mcAnswerOptions))
val createSession = exec(http("Tutor creates session")
.post("/session/")
.header("Content-Type", "application/json")
.body(StringBody(newSession.toJson.toString)).asJSON)
val newMCQuestion = Question(None, 0, "new Question Subject", "This is an MC question for stress testing",
"preparation", "mc", Some("This is the hint!"), Some("The answer is 13"), true, false, true, true, false, None, Some(mcAnswerOptions))
val createQuestion = exec(http("Tutor creates mc question")
.post("/question/")
.header("Content-Type", "application/json")
.body(StringBody(newMCQuestion.toJson.toString)).asJSON
val scn = scenario("Flashcard Tutor").exec(
http("Tutor creates session")
.post("/session/")
.header("Content-Type", "application/json")
.body(StringBody(newSession.toJson.toString)).asJSON
.check(bodyString.saveAs("sessionId"))
).pause(4).exec(
http("Tutor creates mc question")
.post("/session/${sessionId}/question")
.header("Content-Type", "application/json")
.body(StringBody(newMCQuestion.toJson.toString)).asJSON
)
}
\ No newline at end of file
package de.thm.arsnova.tutor
import de.thm.arsnova.models.{AnswerOption, Question, Session}
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import spray.json._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import java.util.Calendar
trait TutorScenario {
import de.thm.arsnova.mappings.QuestionJsonProtocol._
import de.thm.arsnova.mappings.SessionJsonProtocol._
val now = Calendar.getInstance.getTime.toString
val basicNewSession = Session(None, "12312312", 1, "A new Session", "ans", now, now, true, false, false, None)
def createSession(session: Session) = exec(
http("Tutor creates session")
.post("/session/")
.header("Content-Type", "application/json")
.body(StringBody(session.toJson.toString)).asJSON
.check(bodyString.saveAs("sessionId"))
).pause(4)
def createQuestion(question: Question, name: String) = exec(
http(s"Tutor creates ${name} question")
.post("/session/${sessionId}/question")
.header("Content-Type", "application/json")
.body(StringBody(question.toJson.toString)).asJSON
).pause(4)
}
\ No newline at end of file