Class: MockServer::LoadScenario
- Inherits:
-
Object
- Object
- MockServer::LoadScenario
- Defined in:
- lib/mockserver/models.rb
Overview
A load-injection scenario: a named set of steps driven by a traffic profile. template_type selects the templating engine (VELOCITY or MUSTACHE) used to render step requests; max_requests caps the total requests issued.
Instance Attribute Summary collapse
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#max_requests ⇒ Object
Returns the value of attribute max_requests.
-
#name ⇒ Object
Returns the value of attribute name.
-
#profile ⇒ Object
Returns the value of attribute profile.
-
#start_delay_millis ⇒ Object
Returns the value of attribute start_delay_millis.
-
#steps ⇒ Object
Returns the value of attribute steps.
-
#template_type ⇒ Object
Returns the value of attribute template_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, profile:, steps:, template_type: nil, labels: nil, max_requests: nil, start_delay_millis: nil) ⇒ LoadScenario
constructor
A new instance of LoadScenario.
- #to_h ⇒ Object
Constructor Details
#initialize(name:, profile:, steps:, template_type: nil, labels: nil, max_requests: nil, start_delay_millis: nil) ⇒ LoadScenario
Returns a new instance of LoadScenario.
2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 |
# File 'lib/mockserver/models.rb', line 2433 def initialize(name:, profile:, steps:, template_type: nil, labels: nil, max_requests: nil, start_delay_millis: nil) @name = name @profile = profile @steps = steps @template_type = template_type @labels = labels @max_requests = max_requests @start_delay_millis = start_delay_millis end |
Instance Attribute Details
#labels ⇒ Object
Returns the value of attribute labels.
2431 2432 2433 |
# File 'lib/mockserver/models.rb', line 2431 def labels @labels end |
#max_requests ⇒ Object
Returns the value of attribute max_requests.
2431 2432 2433 |
# File 'lib/mockserver/models.rb', line 2431 def max_requests @max_requests end |
#name ⇒ Object
Returns the value of attribute name.
2431 2432 2433 |
# File 'lib/mockserver/models.rb', line 2431 def name @name end |
#profile ⇒ Object
Returns the value of attribute profile.
2431 2432 2433 |
# File 'lib/mockserver/models.rb', line 2431 def profile @profile end |
#start_delay_millis ⇒ Object
Returns the value of attribute start_delay_millis.
2431 2432 2433 |
# File 'lib/mockserver/models.rb', line 2431 def start_delay_millis @start_delay_millis end |
#steps ⇒ Object
Returns the value of attribute steps.
2431 2432 2433 |
# File 'lib/mockserver/models.rb', line 2431 def steps @steps end |
#template_type ⇒ Object
Returns the value of attribute template_type.
2431 2432 2433 |
# File 'lib/mockserver/models.rb', line 2431 def template_type @template_type end |
Class Method Details
.from_hash(data) ⇒ Object
2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 |
# File 'lib/mockserver/models.rb', line 2456 def self.from_hash(data) return nil if data.nil? steps_data = data['steps'] new( name: data['name'], template_type: data['templateType'], labels: data['labels'], max_requests: data['maxRequests'], start_delay_millis: data['startDelayMillis'], profile: LoadProfile.from_hash(data['profile']), steps: steps_data ? steps_data.map { |s| LoadStep.from_hash(s) } : nil ) end |
Instance Method Details
#to_h ⇒ Object
2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 |
# File 'lib/mockserver/models.rb', line 2444 def to_h MockServer.strip_none({ 'name' => @name, 'templateType' => @template_type, 'labels' => @labels, 'maxRequests' => @max_requests, 'startDelayMillis' => @start_delay_millis, 'profile' => @profile&.to_h, 'steps' => @steps&.map(&:to_h) }) end |