Dynamic injection profile

258 views
Skip to first unread message

Michelle Burrows

unread,
Jul 22, 2014, 4:53:38 PM7/22/14
to gat...@googlegroups.com
I'm trying to create a simulation where the scenarios executed and the injection profiles for them are passed in as a system property in the form of a JSON string. Here's a gist of what I have so far.

I'm getting the following compile errors:

type mismatch;
 found   : io.gatling.core.controller.inject.RampInjection
 required: Nothing
 case "rampUsers" => rampUsers(stepArgs.getInt(0)) over(stepArgs.getInt(1))
                                                   ^

type mismatch;
 found   : io.gatling.core.structure.PopulatedScenarioBuilder
 required: Nothing
 scnList(i) = scenarioNames(testCase.getString("case")).inject(injectStepList:_*)
                                                              ^

Anyone have any ideas as to what's wrong/how to fix it? (Other comments/suggestions not related to the errors are also welcome.)

PS The format of the JSON looks like this:

[{'case':'ScenarioMapKey', 'inject':[{'type':'injectionStepType', 'args':[arg1(,arg2(,arg3)))]}]}]

Example:

[
    {
        'case': 'Login',
        'inject': [
            {
                'type': 'nothingFor',
                'args': [
                    5
                ]
            },
            {
                'type': 'constantUsersPerSec',
                'args': [
                    1,
                    10
                ]
            }
        ]
    },
    {
        'case': 'Register',
        'inject': [
            {
                'type': 'atOnceUsers',
                'args': [
                    3
                ]
            }
        ]
    }
]

Which should translate to:

  setUp(LoginScenario.scn.inject(nothingFor(5), constantUsersPerSec(1) during(10)), 
    RegisterScenario.scn.inject(atOnceUsers(3))).protocols(httpConf)

Stéphane Landelle

unread,
Jul 22, 2014, 5:10:33 PM7/22/14
to gat...@googlegroups.com
Please provide a full gist that should compile, except for your problem.
What is JSONArray? Certainly not scala.util.parsing.json.JSONArray.


--
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.

Michelle Burrows

unread,
Jul 23, 2014, 8:21:38 AM7/23/14
to gat...@googlegroups.com
Updated.

The JSON library is json.org, jar available here. 

Stéphane Landelle

unread,
Jul 23, 2014, 8:34:04 AM7/23/14
to gat...@googlegroups.com
o_O I wasn't aware of a Java reference implementation. How does it perform, compared to something like Jackson? Is it just a toy, or is it production ready? You know that Gatling already ships Jackson and Boon, right?

Michelle Burrows

unread,
Jul 23, 2014, 8:44:53 AM7/23/14
to gat...@googlegroups.com
I was already using the reference implementation in the Java app that's writing the JSON, so I picked it test-side over the built-in Scala package or Jackson just for consistency. It's the least of my concerns w.r.t. performance, so no clue on that front.

Michelle Burrows

unread,
Jul 23, 2014, 10:06:36 AM7/23/14
to gat...@googlegroups.com
Well, I fixed it and added the working version to the gist. That said, I have no clue why it works now. All I did was pull the match statement that turns the injection step name into an InjectionStep into its own function.

Stéphane Landelle

unread,
Jul 23, 2014, 4:43:21 PM7/23/14
to gat...@googlegroups.com
What was your problem with the first version in the first place? It seems to be compiling just fine.
Could it be that you're using IntelliJ? Beware, its compiler is quite buggy...

Michelle Burrows

unread,
Jul 24, 2014, 8:32:26 AM7/24/14
to gat...@googlegroups.com
The type mismatch errors in the first post. I'm just using gatling.sh from the command line. I guess I'll just call it gremlins in my computer and move on?

Stéphane Landelle

unread,
Jul 24, 2014, 8:49:34 AM7/24/14
to gat...@googlegroups.com
I tried with eclipse w/ latest Gatling and it compiles just fine...
Whatever...

Please ping if you still hit something.
Reply all
Reply to author
Forward
0 new messages