Skip to content

About

IMAP Support for Gatling

Topics

Resources

Stars

8 stars

Watchers

20 watching

Forks

Repository files navigation

IMAP support for Gatling

The goal of this project is to be able to support IMAP protocol into Gatling.

Supported commands

For now only the following commands are supported:

  • APPEND

  • CAPABILITY

  • CHECK

  • CLOSE

  • ENABLE

  • EXPUNGE

  • FETCH

  • GETACL (RFC-4314)

  • GETQUOTAROOT (RFC-2087)

  • IDLE (RFC-2177)

  • LIST

  • LOGIN

  • LOGOUT

  • LSUB

  • MYRIGHTS (RFC-4314)

  • NAMESPACE (RFC-2342)

  • NOOP

  • SEARCH

  • SELECT

  • STATUS

  • STORE

  • UID FETCH

  • UID SEARCH

  • UNSELECT (RFC-3691)

  • SUBSCRIBE

  • UNSUBSCRIBE

  • CREATE FOLDER

  • DELETE FOLDER

  • RENAME FOLDER

  • EXAMINE FOLDER

  • MOVE (RFC-6851)

  • COPY

  • GETQUOTA (RFC-2087)

  • SETQUOTA (RFC-2087)

  • UID COPY

  • UID EXPUNGE

  • UID MOVE

  • UID STORE

  • COMPRESS (RFC-4978)

Supported checks

  • ok: last response is OK

  • no: last response is NO

  • bad: last response is BAD

  • hasFolder(String): one LIST response contains the folder

  • hasRecent(Int): one response contains xxx RECENT

  • hasNoRecent: one response contains 0 RECENT

  • hasUid(Uid): one response contains UID xxx

  • contains(String): one response contains the provided string

  • debug: print current responses on standard output

Example

You can find a full example into ImapAuthenticationScenario. Here is the interesting part:

  val feeder = Array(Map("username"->"user1", "password"->"password")).circular
  val UserCount: Int = 10

  val scn = scenario("ImapAuthentication").feed(feeder)
    .exec(imap("Connect").connect()).exitHereIfFailed
    .exec(imap("login").login("${username}","${password}").check(ok))
    .exec(imap("list").list("", "*").check(ok, hasFolder("INBOX")))
    .exec(imap("select").select("INBOX").check(ok, hasRecent(0)))
    .exec(imap("append").append("INBOX", Some(Seq("\\Flagged")), Option.empty[Calendar],
     """From: expeditor@example.com
       |To: recipient@example.com
       |Subject: test subject
       |
       |Test content""".stripMargin).check(ok))
    .exec(imap("fetch").fetch(Seq(One(1), One(2), Range(3,5), From(3), One(8), To(1)), AttributeList("BODY", "UID")).check(ok, hasUid(Uid(1)), contains("TEXT")))


  setUp(scn.inject(constantUsersPerSec(UserCount).during(2.seconds))).protocols(imap.host("localhost"))

Configuration

You can set up the following system properties:

  • TARGET_HOSTNAME which is set to localhost by default

  • IMAP_PORT which is set to 143 by default

  • IMAP_PROTOCOL (imap or imaps) which is set to imap by default.

Tests

Launch tests

Some simple integration tests are available via:

$ sbt GatlingIt/test

Finally, execute your gatling scenarios:

$ sbt gatling:test

Or only the specified one:

$ sbt "gatling:testOnly com.linagora.gatling.imap.scenario.ImapAuthenticationScenario"

You can also pass parameter to scenario that accept it like that:

$ JAVA_OPTS="-DnumberOfMailInInbox=15 -DpercentageOfMailToExpunge=30 -DmaxDuration=20" sbt "gatling:testOnly com.linagora.gatling.imap.scenario.ImapExpungeScenario"

In the case of expunge scenario the maxDuration parameter is in minutes

Building with a local jenkins runner

You can use a custom local jenkins runner with the Jenkinsfile at the root of this project to build the project. This will automatically do for you:

  • checkout and compile the latest code of Gatling-imap project

  • launch Gatling integration tests

To launch it you need to have docker installed. From the root of this project, you can build the Jenkins runner locally yourself:

docker build -t local-jenkins-runner dockerfiles/jenkins-runner

And then you need to launch it with the Jenkinsfile:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}/dockerfiles/jenkins-runner/Jenkinsfile:/workspace/Jenkinsfile
--network=host local-jenkins-runner

If you don’t want the build to redownload everytime all the sbt dependencies (it can be heavy) you can mount your local sbt repository as a volume by adding -v $HOME/.ivy2/cache:/root/.ivy2/cache to the above command.

About

IMAP Support for Gatling

Topics

Resources

Stars

8 stars

Watchers

20 watching

Forks

Releases

Packages

Used by

Contributors

Languages