Class: MockServer::LoadProfile

Inherits:
Object
  • Object
show all
Defined in:
lib/mockserver/models.rb

Overview

The traffic-shaping profile of a load scenario: an ordered list of LoadStage objects run in sequence, each holding or ramping a setpoint (virtual users, an arrival rate, or a pause) for its duration. The total run length is the sum of the stage durations.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stages: []) ⇒ LoadProfile

Returns a new instance of LoadProfile.



2378
2379
2380
# File 'lib/mockserver/models.rb', line 2378

def initialize(stages: [])
  @stages = stages || []
end

Instance Attribute Details

#stagesObject

Returns the value of attribute stages.



2376
2377
2378
# File 'lib/mockserver/models.rb', line 2376

def stages
  @stages
end

Class Method Details

.from_hash(data) ⇒ Object



2386
2387
2388
2389
2390
2391
# File 'lib/mockserver/models.rb', line 2386

def self.from_hash(data)
  return nil if data.nil?

  stages_data = data['stages'] || []
  new(stages: stages_data.map { |s| LoadStage.from_hash(s) })
end

Instance Method Details

#to_hObject



2382
2383
2384
# File 'lib/mockserver/models.rb', line 2382

def to_h
  { 'stages' => @stages.map(&:to_h) }
end