Sha256: 3316c9884f657f6670fbb87e2c9a1c007504f86ba2361a876f965f2d5981718c

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

module JmeterPerf
  class DSL
    # DSL method synonymous with the JMeter Element ThreadGroup
    # @see https://github.com/jlurena/jmeter_perf/wiki/1.-DSL-Documentation#threadgroup
    # @param [Hash] params Parameters for the ThreadGroup element (default: `{}`).
    # @yield block to attach to the ThreadGroup element
    # @return [JmeterPerf::ThreadGroup], a subclass of JmeterPerf::DSL that can be chained with other DSL methods.
    def thread_group(params = {}, &)
      node = JmeterPerf::ThreadGroup.new(params)
      attach_node(node, &)
    end
  end

  class ThreadGroup
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "ThreadGroup" : (params[:name] || "ThreadGroup")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="#{testname}" enabled="true">
          <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
          <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="#{testname}" enabled="true">
            <boolProp name="LoopController.continue_forever">false</boolProp>
            <intProp name="LoopController.loops">-1</intProp>
          </elementProp>
          <stringProp name="ThreadGroup.num_threads">1</stringProp>
          <stringProp name="ThreadGroup.ramp_time">1</stringProp>
          <longProp name="ThreadGroup.start_time">1366415241000</longProp>
          <longProp name="ThreadGroup.end_time">1366415241000</longProp>
          <boolProp name="ThreadGroup.scheduler">true</boolProp>
          <stringProp name="ThreadGroup.duration"/>
          <stringProp name="ThreadGroup.delay"/>
          <boolProp name="ThreadGroup.delayedStart">true</boolProp>
        </ThreadGroup>
      EOS
      update params
      update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jmeter_perf-0.0.7 lib/jmeter_perf/dsl/thread_group.rb