2020-06-30 08:08:57 -04:00
|
|
|
import { stateAndPropsFromDataset } from '~/monitoring/utils';
|
2020-04-16 02:09:39 -04:00
|
|
|
import { mapToDashboardViewModel } from '~/monitoring/stores/utils';
|
2020-04-21 11:21:10 -04:00
|
|
|
import { metricStates } from '~/monitoring/constants';
|
2020-07-01 17:08:51 -04:00
|
|
|
import { convertObjectProps } from '~/lib/utils/common_utils';
|
|
|
|
import { convertToCamelCase } from '~/lib/utils/text_utility';
|
2020-04-21 11:21:10 -04:00
|
|
|
|
2020-04-16 02:09:39 -04:00
|
|
|
import { metricsResult } from './mock_data';
|
|
|
|
|
|
|
|
// Use globally available `getJSONFixture` so this file can be imported by both karma and jest specs
|
|
|
|
export const metricsDashboardResponse = getJSONFixture(
|
|
|
|
'metrics_dashboard/environment_metrics_dashboard.json',
|
|
|
|
);
|
|
|
|
export const metricsDashboardPayload = metricsDashboardResponse.dashboard;
|
2020-06-30 08:08:57 -04:00
|
|
|
|
2020-07-01 17:08:51 -04:00
|
|
|
const datasetState = stateAndPropsFromDataset(
|
|
|
|
// It's preferable to have props in snake_case, this will be addressed at:
|
|
|
|
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/33574
|
|
|
|
convertObjectProps(
|
|
|
|
// Some props use kebab-case, convert to snake_case first
|
|
|
|
key => convertToCamelCase(key.replace(/-/g, '_')),
|
|
|
|
metricsDashboardResponse.metrics_data,
|
|
|
|
),
|
2020-06-30 08:08:57 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
export const dashboardProps = datasetState.dataProps;
|
|
|
|
|
2020-04-16 02:09:39 -04:00
|
|
|
export const metricsDashboardViewModel = mapToDashboardViewModel(metricsDashboardPayload);
|
|
|
|
|
|
|
|
export const metricsDashboardPanelCount = 22;
|
|
|
|
export const metricResultStatus = {
|
|
|
|
// First metric in fixture `metrics_dashboard/environment_metrics_dashboard.json`
|
|
|
|
metricId: 'NO_DB_response_metrics_nginx_ingress_throughput_status_code',
|
2020-06-17 08:08:42 -04:00
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: metricsResult,
|
|
|
|
},
|
2020-04-16 02:09:39 -04:00
|
|
|
};
|
|
|
|
export const metricResultPods = {
|
|
|
|
// Second metric in fixture `metrics_dashboard/environment_metrics_dashboard.json`
|
|
|
|
metricId: 'NO_DB_response_metrics_nginx_ingress_latency_pod_average',
|
2020-06-17 08:08:42 -04:00
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: metricsResult,
|
|
|
|
},
|
2020-04-16 02:09:39 -04:00
|
|
|
};
|
|
|
|
export const metricResultEmpty = {
|
|
|
|
metricId: 'NO_DB_response_metrics_nginx_ingress_16_throughput_status_code',
|
2020-06-17 08:08:42 -04:00
|
|
|
data: {
|
|
|
|
resultType: 'matrix',
|
|
|
|
result: [],
|
|
|
|
},
|
2020-04-16 02:09:39 -04:00
|
|
|
};
|
2020-04-21 11:21:10 -04:00
|
|
|
|
|
|
|
// Graph data
|
|
|
|
|
|
|
|
const firstPanel = metricsDashboardViewModel.panelGroups[0].panels[0];
|
|
|
|
|
|
|
|
export const graphData = {
|
|
|
|
...firstPanel,
|
|
|
|
metrics: firstPanel.metrics.map(metric => ({
|
|
|
|
...metric,
|
|
|
|
result: metricsResult,
|
|
|
|
state: metricStates.OK,
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
|
|
|
|
export const graphDataEmpty = {
|
|
|
|
...firstPanel,
|
|
|
|
metrics: firstPanel.metrics.map(metric => ({
|
|
|
|
...metric,
|
|
|
|
result: [],
|
|
|
|
state: metricStates.NO_DATA,
|
|
|
|
})),
|
|
|
|
};
|