Class DslDefaultThreadGroup

    • Field Detail

    • Method Detail

      • rampTo

        public DslDefaultThreadGroup rampTo​(int threadCount,
                                            Duration duration)
        Allows ramping up or down threads with a given duration.

        It is usually advised to use this method when working with considerable amount of threads to avoid load of creating all the threads at once to affect test results.

        JMeter will create (or remove) a thread every rampUp.seconds * 1000 / threadCount milliseconds.

        If you specify a thread duration time (instead of iterations), take into consideration that ramp up is not considered as part of thread duration time. For example: if you have a thread group duration of 10 seconds, and a ramp-up of 10 seconds, the last threads (and the test plan run) will run at least (duration may vary depending on test plan contents) after 20 seconds of starting the test.

        You can use this method multiple times in a thread group and in conjunction with holdFor(Duration) and rampToAndHold(int, Duration, Duration) to elaborate complex test plan profiles.

        Eg:

        
          threadGroup()
            .rampTo(10, Duration.ofSeconds(10))
            .rampTo(5, Duration.ofSeconds(10))
            .rampToAndHold(20, Duration.ofSeconds(5), Duration.ofSeconds(10))
            .rampTo(0, Duration.ofSeconds(5))
            .children(...)
         
        Parameters:
        threadCount - specifies the final number of threads after the given period.
        duration - duration taken to reach the given threadCount and move to the next stage or end the test plan. Since JMeter only supports specifying times in seconds, if you specify a smaller granularity (like milliseconds) it will be rounded up to seconds.
        Returns:
        the thread group for further configuration or usage.
        Throws:
        IllegalStateException - if used after an iterations stage, since JMeter does not provide built-in thread group to support such scenario.
        Since:
        0.18
      • rampTo

        public DslDefaultThreadGroup rampTo​(String threadCount,
                                            String duration)
        Same as rampTo(int, Duration) but allowing to use JMeter expressions (variables or functions) to solve the actual parameter values.

        This is usually used in combination with properties to define values that change between environments or different test runs. Eg:

        rampTo("${THREADS}", "${RAMP}"
        .

        This method can only be used for simple thread group configurations. Allowed combinations are: rampTo, rampTo + holdFor, holdFor + rampTo + holdFor, rampTo + holdIterating, holdFor + rampTo + holdIterating.

        Parameters:
        threadCount - a JMeter expression that returns the number of threads to ramp to.
        duration - a JMeter expression that returns the number of seconds to take for the ramp.
        Returns:
        the thread group for further configuration or usage.
        Since:
        0.57
        See Also:
        rampTo(int, Duration)
      • holdFor

        public DslDefaultThreadGroup holdFor​(Duration duration)
        Specifies to keep current number of threads for a given duration.

        This method is usually used in combination with rampTo(int, Duration) to define the profile of the test plan.

        Parameters:
        duration - duration to hold the current number of threads until moving to next stage or ending the test plan. Since JMeter only supports specifying times in seconds, if you specify a smaller granularity (like milliseconds) it will be rounded up to seconds.
        Returns:
        the thread group for further configuration or usage.
        Since:
        0.18
        See Also:
        rampTo(int, Duration)
      • holdFor

        public DslDefaultThreadGroup holdFor​(String duration)
        Same as holdFor(Duration) but allowing to use JMeter expressions (variables or functions) to solve the duration.

        This is usually used in combination with properties to define values that change between environments or different test runs. Eg:

        holdFor("${DURATION}"
        .

        This method can only be used for simple thread group configurations. Allowed combinations are: rampTo, rampTo + holdFor, holdFor + rampTo + holdFor, rampTo + holdIterating, holdFor + rampTo + holdIterating.

        Parameters:
        duration - a JMeter expression that returns the number of seconds to hold current thread groups.
        Returns:
        the thread group for further configuration or usage.
        Since:
        0.57
        See Also:
        holdFor(Duration)
      • holdIterating

        public DslDefaultThreadGroup holdIterating​(int iterations)
        Specifies to keep current number of threads until they execute the given number of iterations each.

        Warning: holding for iterations can be added to a thread group that has an initial stage with 0 threads followed by a stage ramping up, or only a stage ramping up, or no stages at all.

        Parameters:
        iterations - number of iterations to execute the test plan steps each thread.

        If you specify -1, then threads will iterate until test plan execution is interrupted (you manually stop the running process, there is an error and thread group is configured to stop on error, or some other explicit termination condition).

        Setting this property to -1 is in general not advised, since you might inadvertently end up running a test plan without limits consuming unnecessary computing power. Prefer specifying a big value as a safe limit for iterations or duration instead.

        Returns:
        the thread group for further configuration or usage.
        Throws:
        IllegalStateException - when adding iterations would result in not supported JMeter thread group.
        Since:
        0.18
      • holdIterating

        public DslDefaultThreadGroup holdIterating​(String iterations)
        Same as holdIterating(int) but allowing to use JMeter expressions (variables or functions) to solve the iterations.

        This is usually used in combination with properties to define values that change between environments or different test runs. Eg:

        holdIterating("${ITERATIONS}"
        .

        This method can only be used for simple thread group configurations. Allowed combinations are: rampTo, rampTo + holdFor, holdFor + rampTo + holdFor, rampTo + holdIterating, holdFor + rampTo + holdIterating.

        Parameters:
        iterations - a JMeter expression that returns the number of iterations for current threads to execute.
        Returns:
        the thread group for further configuration or usage.
        Since:
        0.57
        See Also:
        holdIterating(int)
      • upTo

        public DslDefaultThreadGroup upTo​(Duration duration)
        Specifies to stop thread group if iterations take more than specified duration.

        Note: This method should only be used after specifying iterations.

        Parameters:
        duration - specifies a maximum duration for thread execution when threads are iterating.
        Returns:
        the thread group for further configuration or usage.
        Since:
        1.24
      • rampToAndHold

        public DslDefaultThreadGroup rampToAndHold​(int threads,
                                                   Duration rampDuration,
                                                   Duration holdDuration)
        simply combines rampTo(int, Duration) and holdFor(Duration) which are usually used in combination.
        Parameters:
        threads - number of threads to ramp threads up/down to.
        rampDuration - duration taken to reach the given threadCount to start holding that number of threads.
        holdDuration - duration to hold the given number of threads, after the ramp, until moving to next stage or ending the test plan.
        Returns:
        the thread group for further configuration or usage.
        Since:
        0.18
        See Also:
        rampTo(int, Duration), holdFor(Duration)
      • rampToAndHold

        public DslDefaultThreadGroup rampToAndHold​(String threads,
                                                   String rampDuration,
                                                   String holdDuration)
        Same as rampToAndHold(int, Duration, Duration) but allowing to use JMeter expressions (variables or functions) to solve the actual parameter values.

        This is usually used in combination with properties to define values that change between environments or different test runs. Eg:

        rampToAndHold("${THREADS}", "${RAMP}" ,"${DURATION}"
        .

        This method can only be used for simple thread group configurations. Allowed combinations are: rampTo, rampTo + holdFor, holdFor + rampTo + holdFor, rampTo + holdIterating, holdFor + rampTo + holdIterating.

        Parameters:
        threads - a JMeter expression that returns the number of threads to ramp to.
        rampDuration - a JMeter expression that returns the number of seconds to take for the ramp.
        holdDuration - a JMeter expression that returns the number of seconds to hold current thread groups.
        Returns:
        the thread group for further configuration or usage.
        Since:
        0.57
        See Also:
        rampToAndHold(int, Duration, Duration)
      • children

        public DslDefaultThreadGroup children​(BaseThreadGroup.ThreadGroupChild... children)
        Allows specifying thread group children elements (samplers, listeners, post processors, etc.).

        This method is just an alternative to the constructor specification of children, and is handy when you want to keep general thread group settings together and then specify children (instead of specifying threadCount & duration/iterations, then children, and at the end alternative settings like ramp-up period).

        Overrides:
        children in class BaseThreadGroup<DslDefaultThreadGroup>
        Parameters:
        children - list of test elements to add as children of the thread group.
        Returns:
        the thread group for further configuration or usage.
        Since:
        0.12
      • showTimeline

        public void showTimeline()
        Shows a graph with a timeline of planned threads count execution for this test plan.

        The graph will be displayed in a popup window.

        This method is provided mainly to ease test plan designing when working with complex thread group profiles (several stages with ramps and holds).

        Since:
        0.26