mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
3fd810417f
* test * WIP: Create v2 version * Update tests, remove conosole logs, refactor * Remove incorrect types * Update type * Rename legacy and new metrics * Update * Run request when Raw Data tto Raw Document switch * Fix size updating * Remove _source field from table results as we are showing each source field as column * Remove _source just for metrics, not logs * Revert "Remove _source just for metrics, not logs" This reverts commit611b6922f7
. * Revert "Remove _source field from table results as we are showing each source field as column" This reverts commit31a9d5f81b
. * Add vis preference for logs * Update visualisation to logs * Revert "Revert "Remove _source just for metrics"" This reverts commita102ab2894
. Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
118 lines
3.1 KiB
TypeScript
118 lines
3.1 KiB
TypeScript
import * as queryDef from '../query_def';
|
|
|
|
describe('ElasticQueryDef', () => {
|
|
describe('getPipelineAggOptions', () => {
|
|
describe('with zero targets', () => {
|
|
const response = queryDef.getPipelineAggOptions([]);
|
|
|
|
test('should return zero', () => {
|
|
expect(response.length).toBe(0);
|
|
});
|
|
});
|
|
|
|
describe('with count and sum targets', () => {
|
|
const targets = {
|
|
metrics: [
|
|
{ type: 'count', field: '@value' },
|
|
{ type: 'sum', field: '@value' },
|
|
],
|
|
};
|
|
|
|
const response = queryDef.getPipelineAggOptions(targets);
|
|
|
|
test('should return zero', () => {
|
|
expect(response.length).toBe(2);
|
|
});
|
|
});
|
|
|
|
describe('with count and moving average targets', () => {
|
|
const targets = {
|
|
metrics: [
|
|
{ type: 'count', field: '@value' },
|
|
{ type: 'moving_avg', field: '@value' },
|
|
],
|
|
};
|
|
|
|
const response = queryDef.getPipelineAggOptions(targets);
|
|
|
|
test('should return one', () => {
|
|
expect(response.length).toBe(1);
|
|
});
|
|
});
|
|
|
|
describe('with derivatives targets', () => {
|
|
const targets = {
|
|
metrics: [{ type: 'derivative', field: '@value' }],
|
|
};
|
|
|
|
const response = queryDef.getPipelineAggOptions(targets);
|
|
|
|
test('should return zero', () => {
|
|
expect(response.length).toBe(0);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('isPipelineMetric', () => {
|
|
describe('moving_avg', () => {
|
|
const result = queryDef.isPipelineAgg('moving_avg');
|
|
|
|
test('is pipe line metric', () => {
|
|
expect(result).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('count', () => {
|
|
const result = queryDef.isPipelineAgg('count');
|
|
|
|
test('is not pipe line metric', () => {
|
|
expect(result).toBe(false);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('isPipelineAggWithMultipleBucketPaths', () => {
|
|
describe('bucket_script', () => {
|
|
const result = queryDef.isPipelineAggWithMultipleBucketPaths('bucket_script');
|
|
|
|
test('should have multiple bucket paths support', () => {
|
|
expect(result).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('moving_avg', () => {
|
|
const result = queryDef.isPipelineAggWithMultipleBucketPaths('moving_avg');
|
|
|
|
test('should not have multiple bucket paths support', () => {
|
|
expect(result).toBe(false);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('pipeline aggs depending on esverison', () => {
|
|
describe('using esversion undefined', () => {
|
|
test('should not get pipeline aggs', () => {
|
|
expect(queryDef.getMetricAggTypes(undefined).length).toBe(11);
|
|
});
|
|
});
|
|
|
|
describe('using esversion 1', () => {
|
|
test('should not get pipeline aggs', () => {
|
|
expect(queryDef.getMetricAggTypes(1).length).toBe(11);
|
|
});
|
|
});
|
|
|
|
describe('using esversion 2', () => {
|
|
test('should get pipeline aggs', () => {
|
|
expect(queryDef.getMetricAggTypes(2).length).toBe(15);
|
|
});
|
|
});
|
|
|
|
describe('using esversion 5', () => {
|
|
test('should get pipeline aggs', () => {
|
|
expect(queryDef.getMetricAggTypes(5).length).toBe(15);
|
|
});
|
|
});
|
|
});
|
|
});
|