Commit 946f41b4 authored by Miguel Rincon's avatar Miguel Rincon

Generate stacked column data mock data

Instead of having hardcoded data for the stacked column test,
this change takes generated data in prometheus format.
parent b6b55f1d
......@@ -3,13 +3,15 @@ import timezoneMock from 'timezone-mock';
import { cloneDeep } from 'lodash';
import { GlStackedColumnChart, GlChartLegend } from '@gitlab/ui/dist/charts';
import StackedColumnChart from '~/monitoring/components/charts/stacked_column.vue';
import { stackedColumnMockedData } from '../../mock_data';
import { stackedColumnGraphData } from '../../graph_data';
jest.mock('~/lib/utils/icon_utils', () => ({
getSvgIconPathContent: jest.fn().mockImplementation(icon => Promise.resolve(`${icon}-content`)),
}));
describe('Stacked column chart component', () => {
const stackedColumnMockedData = stackedColumnGraphData();
let wrapper;
const findChart = () => wrapper.find(GlStackedColumnChart);
......@@ -63,9 +65,9 @@ describe('Stacked column chart component', () => {
const groupBy = findChart().props('groupBy');
expect(groupBy).toEqual([
'2020-01-30T12:00:00.000Z',
'2020-01-30T12:01:00.000Z',
'2020-01-30T12:02:00.000Z',
'2015-07-01T20:10:50.000Z',
'2015-07-01T20:12:50.000Z',
'2015-07-01T20:14:50.000Z',
]);
});
......
......@@ -246,3 +246,16 @@ export const gaugeChartGraphData = (panelOptions = {}) => {
],
});
};
/**
* Generates stacked mock graph data according to options
*
* @param {Object} panelOptions - Panel options as in YML.
* @param {Object} dataOptions
*/
export const stackedColumnGraphData = (panelOptions = {}, dataOptions = {}) => {
return {
...timeSeriesGraphData(panelOptions, dataOptions),
type: panelTypes.STACKED_COLUMN,
};
};
......@@ -245,51 +245,6 @@ export const metricsResult = [
},
];
export const stackedColumnMockedData = {
title: 'memories',
type: 'stacked-column',
x_label: 'x label',
y_label: 'y label',
metrics: [
{
label: 'memory_1024',
unit: 'count',
series_name: 'group 1',
prometheus_endpoint_path:
'/root/autodevops-deploy-6/-/environments/24/prometheus/api/v1/query_range?query=avg%28sum%28container_memory_usage_bytes%7Bcontainer_name%21%3D%22POD%22%2Cpod_name%3D~%22%5E%25%7Bci_environment_slug%7D-%28%5B%5Ec%5D.%2A%7Cc%28%5B%5Ea%5D%7Ca%28%5B%5En%5D%7Cn%28%5B%5Ea%5D%7Ca%28%5B%5Er%5D%7Cr%5B%5Ey%5D%29%29%29%29.%2A%7C%29-%28.%2A%29%22%2Cnamespace%3D%22%25%7Bkube_namespace%7D%22%7D%29+by+%28job%29%29+without+%28job%29+%2F+count%28avg%28container_memory_usage_bytes%7Bcontainer_name%21%3D%22POD%22%2Cpod_name%3D~%22%5E%25%7Bci_environment_slug%7D-%28%5B%5Ec%5D.%2A%7Cc%28%5B%5Ea%5D%7Ca%28%5B%5En%5D%7Cn%28%5B%5Ea%5D%7Ca%28%5B%5Er%5D%7Cr%5B%5Ey%5D%29%29%29%29.%2A%7C%29-%28.%2A%29%22%2Cnamespace%3D%22%25%7Bkube_namespace%7D%22%7D%29+without+%28job%29%29+%2F1024%2F1024',
metricId: 'NO_DB_metric_of_ages_1024',
result: [
{
metric: {},
values: [
['2020-01-30T12:00:00.000Z', '5'],
['2020-01-30T12:01:00.000Z', '10'],
['2020-01-30T12:02:00.000Z', '15'],
],
},
],
},
{
label: 'memory_1000',
unit: 'count',
series_name: 'group 2',
prometheus_endpoint_path:
'/root/autodevops-deploy-6/-/environments/24/prometheus/api/v1/query_range?query=avg%28sum%28container_memory_usage_bytes%7Bcontainer_name%21%3D%22POD%22%2Cpod_name%3D~%22%5E%25%7Bci_environment_slug%7D-%28%5B%5Ec%5D.%2A%7Cc%28%5B%5Ea%5D%7Ca%28%5B%5En%5D%7Cn%28%5B%5Ea%5D%7Ca%28%5B%5Er%5D%7Cr%5B%5Ey%5D%29%29%29%29.%2A%7C%29-%28.%2A%29%22%2Cnamespace%3D%22%25%7Bkube_namespace%7D%22%7D%29+by+%28job%29%29+without+%28job%29+%2F+count%28avg%28container_memory_usage_bytes%7Bcontainer_name%21%3D%22POD%22%2Cpod_name%3D~%22%5E%25%7Bci_environment_slug%7D-%28%5B%5Ec%5D.%2A%7Cc%28%5B%5Ea%5D%7Ca%28%5B%5En%5D%7Cn%28%5B%5Ea%5D%7Ca%28%5B%5Er%5D%7Cr%5B%5Ey%5D%29%29%29%29.%2A%7C%29-%28.%2A%29%22%2Cnamespace%3D%22%25%7Bkube_namespace%7D%22%7D%29+without+%28job%29%29+%2F1024%2F1024',
metricId: 'NO_DB_metric_of_ages_1000',
result: [
{
metric: {},
values: [
['2020-01-30T12:00:00.000Z', '20'],
['2020-01-30T12:01:00.000Z', '25'],
['2020-01-30T12:02:00.000Z', '30'],
],
},
],
},
],
};
export const barMockData = {
title: 'SLA Trends - Primary Services',
type: 'bar',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment