Timestamp Gatling

1,845 views
Skip to first unread message

Maxime Tual

unread,
Apr 17, 2014, 12:48:06 PM4/17/14
to gat...@googlegroups.com
Hi,

I'm trying to get an unique email for each of my created user with Gatling.
So when i create the user I use this function:

def emailUnique(email: String): String = {
      var emailUnique = "testGatling" + "+" + System.currentTimeMillis+ "@example.com"
      return emailUnique
  }

When my first user is created he got this email : testGatling+2...@example.com BUT
when my second user is created he got the same email: testGatling+2...@example.com

The timestamp has not change between the two users. Here's my simulation:
setUp(
ProvisioningUser.scn.inject(
atOnceUsers(1),
  nothingFor(4 seconds),
            atOnceUsers(1)
           ).protocols(httpConf)
    )

Why the timestamp did not change ? Or how can I've got unique email every time (without clear the database) ? 

nicolas...@gmail.com

unread,
Apr 17, 2014, 1:03:20 PM4/17/14
to gat...@googlegroups.com, gat...@googlegroups.com
Use a UUID. 

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stéphane Landelle

unread,
Apr 17, 2014, 2:16:43 PM4/17/14
to gat...@googlegroups.com
My2cents: you're calling emailUnique directly instead of calling it from a function, so it's only called once.

Maxime Tual

unread,
Apr 18, 2014, 3:46:26 AM4/18/14
to gat...@googlegroups.com
I try with UUID but i've got exactly the same issue, the two users have the same UUID.

I think it's about what Stéphane say but I don't understand your Answer Stéphane. Why my function is called once ? How can i do ?


Le jeudi 17 avril 2014 20:16:43 UTC+2, Stéphane Landelle a écrit :
My2cents: you're calling emailUnique directly instead of calling it from a function, so it's only called once.
2014-04-17 19:03 GMT+02:00 <nicolas...@gmail.com>:
Use a UUID. 


On Thu, Apr 17, 2014 at 6:48 PM, Maxime Tual <maxim...@gmail.com> wrote:

Hi,

I'm trying to get an unique email for each of my created user with Gatling.
So when i create the user I use this function:

def emailUnique(email: String): String = {
      var emailUnique = "testGatling" + "+" + System.currentTimeMillis+ "@example.com"
      return emailUnique
  }

When my first user is created he got this email : testGatling+2...@example.com BUT
when my second user is created he got the same email: testGatling+2928430...@example.com

The timestamp has not change between the two users. Here's my simulation:
setUp(
ProvisioningUser.scn.inject(
atOnceUsers(1),
  nothingFor(4 seconds),
            atOnceUsers(1)
           ).protocols(httpConf)
    )

Why the timestamp did not change ? Or how can I've got unique email every time (without clear the database) ? 

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stéphane Landelle

unread,
Apr 18, 2014, 3:51:30 AM4/18/14
to gat...@googlegroups.com
Call you show the way you're using your emailUnique method, please?

Maxime Tual

unread,
Apr 18, 2014, 3:52:41 AM4/18/14
to gat...@googlegroups.com
Maybe I've got an idea. How can I store a static variable for all my users ? A variable starting to System.currentTimeMillis and I will increment each time a user is created ? 

Maxime Tual

unread,
Apr 18, 2014, 3:56:22 AM4/18/14
to gat...@googlegroups.com
 /**
     * Provision the base with a new user base on user_provisioning feeder
     * param access_token_basic 
     * return access_token Auth token for the created user
     */
    val provisioning = exec().feed(provisioningUsers)
        .exec(http("Create a new user")
        .post("/users")
        .header("Content-Type", "application/json")
        .header("Authorization", "Bearer ${access_token_basic}")
        .body(StringBody("""{"login": """" + emailUnique("${login}") + """", "password": "${password}", "user": {"firstname": "${firstname}", "lastname": "${lastname}", "gender": "${gender}", "locale": "${locale}", "country": {"code": "${country_code}"}, "facebookID": """" + fbIdUnique("${facebookID}") + """"}}"""))
        .check(status.is(201), jsonPath("$.accessToken").saveAs("access_token")))


    //Return unique email base on timestamp
    def emailUnique(email: String): String = {
        var emailUnique = "testGatling" + "+" + System.currentTimeMillis + "@example.com"
        return emailUnique
    }

Stéphane Landelle

unread,
Apr 18, 2014, 4:07:14 AM4/18/14
to gat...@googlegroups.com
OK, so that will never work. read this: https://github.com/excilys/gatling/blob/master/src/sphinx/session/expression_el.rst

One solution would be:

val provisioning =feed(provisioningUsers)
.exec(session => session.set("email", emailUnique(session("login").as[String]))
....
.body(StringBody("""{"login": "${email}", "password": "${password}", ...

Same thing goes with fbIdUnique.


Maxime Tual

unread,
Apr 18, 2014, 4:17:06 AM4/18/14
to gat...@googlegroups.com
Thanx you very much ! It works ! :)

I found this old post related answer: https://groups.google.com/forum/#!msg/gatling/ycR9LtoU1_c/eoJDXyQ-BgUJ 
Reply all
Reply to author
Forward
0 new messages