Class: MockServer::LoadStep
- Inherits:
-
Object
- Object
- MockServer::LoadStep
- Defined in:
- lib/mockserver/models.rb
Overview
A single step within a load scenario. Each step fires request (an HttpRequest)
against the target, optionally pausing for think_time (a Delay) afterwards.
captures binds values from this step's response for later steps in the same
iteration; weight is the relative selection weight when the scenario's
step_selection is WEIGHTED.
Instance Attribute Summary collapse
-
#captures ⇒ Object
Returns the value of attribute captures.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#name ⇒ Object
Returns the value of attribute name.
-
#request ⇒ Object
Returns the value of attribute request.
-
#think_time ⇒ Object
Returns the value of attribute think_time.
-
#weight ⇒ Object
Returns the value of attribute weight.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(request:, name: nil, labels: nil, think_time: nil, captures: nil, weight: nil) ⇒ LoadStep
constructor
A new instance of LoadStep.
- #to_h ⇒ Object
Constructor Details
#initialize(request:, name: nil, labels: nil, think_time: nil, captures: nil, weight: nil) ⇒ LoadStep
Returns a new instance of LoadStep.
3127 3128 3129 3130 3131 3132 3133 3134 |
# File 'lib/mockserver/models.rb', line 3127 def initialize(request:, name: nil, labels: nil, think_time: nil, captures: nil, weight: nil) @request = request @name = name @labels = labels @think_time = think_time @captures = captures @weight = weight end |
Instance Attribute Details
#captures ⇒ Object
Returns the value of attribute captures.
3125 3126 3127 |
# File 'lib/mockserver/models.rb', line 3125 def captures @captures end |
#labels ⇒ Object
Returns the value of attribute labels.
3125 3126 3127 |
# File 'lib/mockserver/models.rb', line 3125 def labels @labels end |
#name ⇒ Object
Returns the value of attribute name.
3125 3126 3127 |
# File 'lib/mockserver/models.rb', line 3125 def name @name end |
#request ⇒ Object
Returns the value of attribute request.
3125 3126 3127 |
# File 'lib/mockserver/models.rb', line 3125 def request @request end |
#think_time ⇒ Object
Returns the value of attribute think_time.
3125 3126 3127 |
# File 'lib/mockserver/models.rb', line 3125 def think_time @think_time end |
#weight ⇒ Object
Returns the value of attribute weight.
3125 3126 3127 |
# File 'lib/mockserver/models.rb', line 3125 def weight @weight end |
Class Method Details
.from_hash(data) ⇒ Object
3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 |
# File 'lib/mockserver/models.rb', line 3147 def self.from_hash(data) return nil if data.nil? captures_data = data['captures'] new( name: data['name'], labels: data['labels'], think_time: Delay.from_hash(data['thinkTime']), request: HttpRequest.from_hash(data['request']), captures: captures_data ? captures_data.map { |c| LoadCapture.from_hash(c) } : nil, weight: data['weight'] ) end |
Instance Method Details
#to_h ⇒ Object
3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 |
# File 'lib/mockserver/models.rb', line 3136 def to_h MockServer.strip_none({ 'name' => @name, 'labels' => @labels, 'thinkTime' => @think_time&.to_h, 'request' => @request&.to_h, 'captures' => @captures.nil? ? nil : @captures.map(&:to_h), 'weight' => @weight }) end |