Using Variable for Thread group Ramp up time

后端 未结 3 930
挽巷
挽巷 2020-12-16 06:46

how to configure the thread group ramp up time with a jmeter variable, I tried for both number of threads and ramp up time. No of threads is working fine, but ramp up time t

相关标签:
3条回答
  • 2020-12-16 07:19

    You cannot use variables in Thread Group setting as Thread Groups are initialised during startup, before any variables are read.

    If you need to make number of threads and/or ramp-up period configurable use __P() function like:

    • ${__P(threads,)}
    • ${__P(rampup,)}

    Aforementioned threads and rampup properties can be defined in several ways:

    1. If you run JMeter in command-line non-GUI mode you can pass the properties via -J command line key as

      jmeter -Jthreads=50 -Jrampup=30 -n -t /path/to/your/testplan.jmx
      

      The same approach will work for GUI mode, however it is not recommended to use GUI for load test execution as it is quite resource consuming and may ruin your test.

    2. You can define these properties in user.properties file (located in /bin folder of your JMeter installation) as:

      threads=50
      rampup=30
      

      After restart JMeter will pick the properties up and you will be able to refer them via __P() function as described above.

    See Apache JMeter Properties Customization Guide for comprehensive information on various JMeter properties and ways of working with them

    0 讨论(0)
  • 2020-12-16 07:25

    You cannot use variables for those values, only properties:

    • http://jmeter.apache.org/usermanual/functions.html

    Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.

    0 讨论(0)
  • 2020-12-16 07:33

    There is no reason why it works for # of threads but doesn't work for ramp-up time. I've been using configurable properties for both with success.

    1 is the default value in JMeter if variable can't be resolved properly. You likely made a typo. To investigate the problem, you may want to use 'Property Display' element (right-click WorkBench / Add / Non-Test Element / Property Display).

    If this doesn't help, please post link to the screenshot of thread group, and relevant part of your config where you define the ramp-up time variable.

    EDIT : example

    This is the way I usually work with configurable properties stored in external files (and it works for ramp-up as well):

    • define user defined variable on test plan level, e.g. someVarName is ${__P(someVarName)}
    • then use this var e.g. in ramp-up as ${someVarName}
    0 讨论(0)
提交回复
热议问题