import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import io.gatling.jms.Predef._
import io.gatling.jms.protocol.JmsProtocolBuilderBase.connectionFactoryName
import scala.concurrent.duration._
class GPRSForwarderTest extends Simulation {
val JNDI_CONTEXT = "com.sun.jndi.fscontext.RefFSContextFactory"
val DEFAULT_QCF_NAME_MQ_HOST_1 = "GPRSF"
val DEFAULT_QCF_NAME_MQ_HOST_2 = "GPRSF2"
val DEFAULT_QCF_NAME_MQ_HOST_3 = "GPRSF3"
val message254 = "00001404020611100E033102C20EBB51CC1C036EFFFF00010002323802000200FE05001400000000FFFFFFFF01FFFFFFFFFFFFFFFFFFFFFF040010038B0D6912EB10CE070206110F37298C"
val message255 = "00001400020611101315310200006973D9BF002B002A00010002313902000200FF05001400FEE4E4000B874000004C77DE4B0007A5964A650A0001000C001704134420203438354C4951"
val message102 = "0000140413060E0E2816310203BA0342CB0A01E7FFFF0002000200662300260100230E017F13060E0E2500000013060E0E2537FFFFFFFF04C7005B14000E451BD1FFFFFFFF"
val message109 = "000014090A01120E02223102A73E1451DBCD0000000000020002006D2300260100230700010A01120E01330000000000000000000000000000000000000000000000000000"
// JMS configuration for MQ-HOST 1
val jmsConfigMQ1 = connectionFactoryName(DEFAULT_QCF_NAME_MQ_HOST_1)
.url("file:///Users/gniewosz/Documents")
.credentials("mqm", "mqm")
.contextFactory(JNDI_CONTEXT)
.listenerCount(1)
.usePersistentDeliveryMode
val scnMessageID254 = scenario("Load testing GPRS InboundQueue on MQ-HOST-1 with MessageID254").during(8 hour) {
exec(jms("F&F testing with MessageID 254").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message254)
)
}
val scnMessageID255 = scenario("Load testing GPRS InboundQueue on MQ-HOST-1 with MessageID255").during(8 hour) {
exec(jms("F&F testing with Message ID 255").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message255)
)
}
val scnMessageID102 = scenario("Load testing GPRS InboundQueue on MQ-HOST-1 with MessageID102").during(8 hour) {
exec(jms("F&F testing with Message ID 102").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message102)
)
}
val scnMessageID109 = scenario("Load testing GPRS InboundQueue on MQ-HOST-1 with MessageID109").during(8 hour) {
exec(jms("F&F testing with Message ID 109").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message109)
)
}
// JMS configuration for MQ-HOST 2
val jmsConfigMQ2 = connectionFactoryName(DEFAULT_QCF_NAME_MQ_HOST_2)
.url("file:///Users/gniewosz/Documents")
.credentials("mqm", "mqm")
.contextFactory(JNDI_CONTEXT)
.listenerCount(1)
.usePersistentDeliveryMode
val scnMessageID254MQHost2 = scenario("Load testing GPRS InboundQueue on MQ-HOST-2 with MessageID254").during(8 hour) {
exec(jms("F&F testing with MessageID 254").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message254)
)
}
val scnMessageID255MQHost2 = scenario("Load testing GPRS InboundQueue on MQ-HOST-2 with MessageID255").during(8 hour) {
exec(jms("F&F testing with Message ID 255").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message255)
)
}
val scnMessageID102MQHost2 = scenario("Load testing GPRS InboundQueue on MQ-HOST-2 with MessageID102").during(8 hour) {
exec(jms("F&F testing with Message ID 102").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message102)
)
}
val scnMessageID109MQHost2 = scenario("Load testing GPRS InboundQueue on MQ-HOST-2 with MessageID109").during(8 hour) {
exec(jms("F&F testing with Message ID 109").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message109)
)
}
// JMS configuration for MQ-HOST 3
val jmsConfigMQ3 = connectionFactoryName(DEFAULT_QCF_NAME_MQ_HOST_3)
.url("file:///Users/gniewosz/Documents")
.credentials("mqm", "mqm")
.contextFactory(JNDI_CONTEXT)
.listenerCount(1)
.usePersistentDeliveryMode
val scnMessageID254MQHost3 = scenario("Load testing GPRS InboundQueue on MQ-HOST-3 with MessageID254").during(8 hour) {
exec(jms("F&F testing with MessageID 254").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message254)
)
}
val scnMessageID255MQHost3 = scenario("Load testing GPRS InboundQueue on MQ-HOST-3 with MessageID255").during(8 hour) {
exec(jms("F&F testing with Message ID 255").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message255)
)
}
val scnMessageID102MQHost3 = scenario("Load testing GPRS InboundQueue on MQ-HOST-3 with MessageID102").during(8 hour) {
exec(jms("F&F testing with Message ID 102").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message102)
)
}
val scnMessageID109MQHost3 = scenario("Load testing GPRS InboundQueue on MQ-HOST-3 with MessageID109").during(8 hour) {
exec(jms("F&F testing with Message ID 109").send
.queue("FLEETBOARD.GPRS_MESSAGES.QUEUE")
.textMessage(message109)
)
}
/* define actual load test data sets (concurrent user/msgs and time frames) for given environment */
// configuration for MQ-HOST-1
setUp(scnMessageID254.inject(rampUsers(40) over(1 seconds))
.protocols(jmsConfigMQ1), scnMessageID255.inject(rampUsers(40) over(1 seconds))
.protocols(jmsConfigMQ1),scnMessageID102.inject(rampUsers(40) over(1 seconds))
.protocols(jmsConfigMQ1), scnMessageID109.inject(rampUsers(40) over(1 seconds)),
// configuration for MQ-HOST-2
scnMessageID254MQHost2.inject(rampUsers(40) over (1 seconds)).protocols(jmsConfigMQ2),
scnMessageID255MQHost2.inject(rampUsers(40) over(1 seconds)).protocols(jmsConfigMQ2),
scnMessageID102MQHost2.inject(rampUsers(40) over (1 seconds)).protocols(jmsConfigMQ2),
scnMessageID109MQHost2.inject(rampUsers(40) over (1 seconds)).protocols(jmsConfigMQ2),
// configuration for MQ-HOST-3
scnMessageID254MQHost3.inject(rampUsers(40) over (1 seconds)).protocols(jmsConfigMQ3),
scnMessageID255MQHost3.inject(rampUsers(40) over (1 seconds)).protocols(jmsConfigMQ3),
scnMessageID102MQHost3.inject(rampUsers(40) over (1 seconds)).protocols(jmsConfigMQ3),
scnMessageID109MQHost3.inject(rampUsers(40) over (1 seconds)).protocols(jmsConfigMQ3)
)
}