diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-05 12:32:56 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-05 12:37:07 +0300 |
commit | ae5268ce8cc533be4086a11d9d89fa726136d59d (patch) | |
tree | e61b5177d712bf8a6807efce3cf32da55863abbc /spec/support | |
parent | 6a70509a2763717e592c603249855bfb43519d2f (diff) |
Additional Metrics tests
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/prometheus/additional_metrics_query_helper.rb | 51 | ||||
-rw-r--r-- | spec/support/prometheus/matched_metrics_query_helper.rb | 6 |
2 files changed, 54 insertions, 3 deletions
diff --git a/spec/support/prometheus/additional_metrics_query_helper.rb b/spec/support/prometheus/additional_metrics_query_helper.rb new file mode 100644 index 00000000000..d80beb066ff --- /dev/null +++ b/spec/support/prometheus/additional_metrics_query_helper.rb @@ -0,0 +1,51 @@ +module Prometheus + module AdditionalMetricsQueryHelper + def metric_names + %w{metric_a metric_b} + end + + def simple_queries + [{ query_range: 'query_range_a' }, { query_range: 'query_range_b', label: 'label', unit: 'unit' }] + end + + def simple_query(suffix = 'a') + [{ query_range: "query_range_#{suffix}" }] + end + + def simple_metrics + [ + Gitlab::Prometheus::Metric.new('title', %w(metric_a metric_b), nil, nil, simple_queries), + Gitlab::Prometheus::Metric.new('title', %w{metric_a}, nil, nil, simple_query('empty')), + Gitlab::Prometheus::Metric.new('title', %w{metric_c}, nil, nil) + ] + end + + def simple_metric_group(name = 'name', metrics = simple_metrics) + Gitlab::Prometheus::MetricGroup.new(name, 1, metrics) + end + + def query_result + [ + { + 'metric': {}, + 'value': [ + 1488772511.004, + '0.000041021495238095323' + ] + } + ] + end + + def query_range_result + [ + { + 'metric': {}, + 'values': [ + [1488758662.506, '0.00002996364761904785'], + [1488758722.506, '0.00003090239047619091'] + ] + } + ] + end + end +end diff --git a/spec/support/prometheus/matched_metrics_query_helper.rb b/spec/support/prometheus/matched_metrics_query_helper.rb index ecaf85e3338..86e874fb295 100644 --- a/spec/support/prometheus/matched_metrics_query_helper.rb +++ b/spec/support/prometheus/matched_metrics_query_helper.rb @@ -5,12 +5,12 @@ module Prometheus end def simple_metrics(metric_name = 'metric_a') - [metric_class.new('title', %W(#{metric_name} metric_b), nil, nil), - metric_class.new('title', [metric_name], nil, nil)] + [Gitlab::Prometheus::Metric.new('title', %W(#{metric_name} metric_b), nil, nil), + Gitlab::Prometheus::Metric.new('title', [metric_name], nil, nil)] end def simple_metric_group(name = 'name', metrics = simple_metrics) - metric_group_class.new(name, 1, metrics) + Gitlab::Prometheus::MetricGroup.new(name, 1, metrics) end def series_info_with_environment(*more_metrics) |