Class: MockServer::LoadThreshold

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

Overview

An in-run pass/fail threshold for a load scenario: a per-run metric compared with comparator against threshold. All thresholds must hold for the run verdict to be PASS; any breach makes it FAIL. metric is one of +LATENCY_P50+/+LATENCY_P95+/+LATENCY_P99+/+LATENCY_P999+/+ERROR_RATE+/ THROUGHPUT_RPS; comparator is one of +LESS_THAN+/+LESS_THAN_OR_EQUAL+/ +GREATER_THAN+/+GREATER_THAN_OR_EQUAL+.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric:, comparator:, threshold:) ⇒ LoadThreshold

Returns a new instance of LoadThreshold.



3029
3030
3031
3032
3033
# File 'lib/mockserver/models.rb', line 3029

def initialize(metric:, comparator:, threshold:)
  @metric = metric
  @comparator = comparator
  @threshold = threshold
end

Instance Attribute Details

#comparatorObject

Returns the value of attribute comparator.



3027
3028
3029
# File 'lib/mockserver/models.rb', line 3027

def comparator
  @comparator
end

#metricObject

Returns the value of attribute metric.



3027
3028
3029
# File 'lib/mockserver/models.rb', line 3027

def metric
  @metric
end

#thresholdObject

Returns the value of attribute threshold.



3027
3028
3029
# File 'lib/mockserver/models.rb', line 3027

def threshold
  @threshold
end

Class Method Details

.from_hash(data) ⇒ Object



3043
3044
3045
3046
3047
3048
3049
3050
3051
# File 'lib/mockserver/models.rb', line 3043

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

  new(
    metric:     data['metric'],
    comparator: data['comparator'],
    threshold:  data['threshold']
  )
end

Instance Method Details

#to_hObject



3035
3036
3037
3038
3039
3040
3041
# File 'lib/mockserver/models.rb', line 3035

def to_h
  MockServer.strip_none({
    'metric'     => @metric,
    'comparator' => @comparator,
    'threshold'  => @threshold
  })
end