Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
61dd3ada
Commit
61dd3ada
authored
Jul 15, 2020
by
Miguel Rincon
Committed by
Jose Vargas
Jul 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate heatmap mock data
This change allows the test suite to generate heatmap mock data.
parent
2ec919be
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
93 deletions
+38
-93
app/assets/javascripts/monitoring/components/charts/heatmap.vue
...sets/javascripts/monitoring/components/charts/heatmap.vue
+1
-1
spec/frontend/monitoring/components/charts/heatmap_spec.js
spec/frontend/monitoring/components/charts/heatmap_spec.js
+10
-8
spec/frontend/monitoring/components/dashboard_panel_spec.js
spec/frontend/monitoring/components/dashboard_panel_spec.js
+4
-5
spec/frontend/monitoring/graph_data.js
spec/frontend/monitoring/graph_data.js
+23
-2
spec/frontend/monitoring/mock_data.js
spec/frontend/monitoring/mock_data.js
+0
-77
No files found.
app/assets/javascripts/monitoring/components/charts/heatmap.vue
View file @
61dd3ada
...
...
@@ -36,7 +36,7 @@ export default {
);
},
xAxisName
()
{
return
this
.
graphData
.
x
_l
abel
||
''
;
return
this
.
graphData
.
x
L
abel
||
''
;
},
yAxisName
()
{
return
this
.
graphData
.
y_label
||
''
;
...
...
spec/frontend/monitoring/components/charts/heatmap_spec.js
View file @
61dd3ada
...
...
@@ -2,7 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import
{
GlHeatmap
}
from
'
@gitlab/ui/dist/charts
'
;
import
timezoneMock
from
'
timezone-mock
'
;
import
Heatmap
from
'
~/monitoring/components/charts/heatmap.vue
'
;
import
{
graphDataPrometheusQueryRangeMultiTrack
}
from
'
../../mock
_data
'
;
import
{
heatmapGraphData
}
from
'
../../graph
_data
'
;
describe
(
'
Heatmap component
'
,
()
=>
{
let
wrapper
;
...
...
@@ -10,10 +10,12 @@ describe('Heatmap component', () => {
const
findChart
=
()
=>
wrapper
.
find
(
GlHeatmap
);
const
graphData
=
heatmapGraphData
();
const
createWrapper
=
(
props
=
{})
=>
{
wrapper
=
shallowMount
(
Heatmap
,
{
propsData
:
{
graphData
:
graphDataPrometheusQueryRangeMultiTrack
,
graphData
:
heatmapGraphData
()
,
containerWidth
:
100
,
...
props
,
},
...
...
@@ -38,11 +40,11 @@ describe('Heatmap component', () => {
});
it
(
'
should display a label on the x axis
'
,
()
=>
{
expect
(
wrapper
.
vm
.
xAxisName
).
toBe
(
graphData
PrometheusQueryRangeMultiTrack
.
x_l
abel
);
expect
(
wrapper
.
vm
.
xAxisName
).
toBe
(
graphData
.
xL
abel
);
});
it
(
'
should display a label on the y axis
'
,
()
=>
{
expect
(
wrapper
.
vm
.
yAxisName
).
toBe
(
graphData
PrometheusQueryRangeMultiTrack
.
y_label
);
expect
(
wrapper
.
vm
.
yAxisName
).
toBe
(
graphData
.
y_label
);
});
// According to the echarts docs https://echarts.apache.org/en/option.html#series-heatmap.data
...
...
@@ -54,24 +56,24 @@ describe('Heatmap component', () => {
const
row
=
wrapper
.
vm
.
chartData
[
0
];
expect
(
row
.
length
).
toBe
(
3
);
expect
(
wrapper
.
vm
.
chartData
.
length
).
toBe
(
30
);
expect
(
wrapper
.
vm
.
chartData
.
length
).
toBe
(
6
);
});
it
(
'
returns a series of labels for the x axis
'
,
()
=>
{
const
{
xAxisLabels
}
=
wrapper
.
vm
;
expect
(
xAxisLabels
.
length
).
toBe
(
5
);
expect
(
xAxisLabels
.
length
).
toBe
(
2
);
});
describe
(
'
y axis labels
'
,
()
=>
{
const
gmtLabels
=
[
'
3:00 PM
'
,
'
4:00 PM
'
,
'
5:00 PM
'
,
'
6:00 PM
'
,
'
7:00 PM
'
,
'
8:00
PM
'
];
const
gmtLabels
=
[
'
8:10 PM
'
,
'
8:12 PM
'
,
'
8:14
PM
'
];
it
(
'
y-axis labels are formatted in AM/PM format
'
,
()
=>
{
expect
(
findChart
().
props
(
'
yAxisLabels
'
)).
toEqual
(
gmtLabels
);
});
describe
(
'
when in PT timezone
'
,
()
=>
{
const
ptLabels
=
[
'
8:00 AM
'
,
'
9:00 AM
'
,
'
10:00 AM
'
,
'
11:00 AM
'
,
'
12:00 PM
'
,
'
1:00
PM
'
];
const
ptLabels
=
[
'
1:10 PM
'
,
'
1:12 PM
'
,
'
1:14
PM
'
];
const
utcLabels
=
gmtLabels
;
// Identical in this case
beforeAll
(()
=>
{
...
...
spec/frontend/monitoring/components/dashboard_panel_spec.js
View file @
61dd3ada
...
...
@@ -14,11 +14,10 @@ import {
mockNamespace
,
mockNamespacedData
,
mockTimeRange
,
graphDataPrometheusQueryRangeMultiTrack
,
barMockData
,
}
from
'
../mock_data
'
;
import
{
dashboardProps
,
graphData
,
graphDataEmpty
}
from
'
../fixture_data
'
;
import
{
anomalyGraphData
,
singleStatGraphData
}
from
'
../graph_data
'
;
import
{
anomalyGraphData
,
singleStatGraphData
,
heatmapGraphData
}
from
'
../graph_data
'
;
import
{
panelTypes
}
from
'
~/monitoring/constants
'
;
...
...
@@ -235,7 +234,7 @@ describe('Dashboard Panel', () => {
${
anomalyGraphData
()}
|
${
MonitorAnomalyChart
}
|
${
false
}
${
dataWithType
(
panelTypes
.
COLUMN
)}
|
${
MonitorColumnChart
}
|
${
false
}
${
dataWithType
(
panelTypes
.
STACKED_COLUMN
)}
|
${
MonitorStackedColumnChart
}
|
${
false
}
${
graphDataPrometheusQueryRangeMultiTrack
}
|
${
MonitorHeatmapChart
}
|
${
false
}
${
heatmapGraphData
()}
|
${
MonitorHeatmapChart
}
|
${
false
}
${
barMockData
}
|
${
MonitorBarChart
}
|
${
false
}
`
(
'
when $data.type data is provided
'
,
({
data
,
component
,
hasCtxMenu
})
=>
{
const
attrs
=
{
attr1
:
'
attr1Value
'
,
attr2
:
'
attr2Value
'
};
...
...
@@ -523,7 +522,7 @@ describe('Dashboard Panel', () => {
});
it
(
'
displays a heatmap in local timezone
'
,
()
=>
{
createWrapper
({
graphData
:
graphDataPrometheusQueryRangeMultiTrack
});
createWrapper
({
graphData
:
heatmapGraphData
()
});
expect
(
wrapper
.
find
(
MonitorHeatmapChart
).
props
(
'
timezone
'
)).
toBe
(
'
LOCAL
'
);
});
...
...
@@ -538,7 +537,7 @@ describe('Dashboard Panel', () => {
});
it
(
'
displays a heatmap with UTC
'
,
()
=>
{
createWrapper
({
graphData
:
graphDataPrometheusQueryRangeMultiTrack
});
createWrapper
({
graphData
:
heatmapGraphData
()
});
expect
(
wrapper
.
find
(
MonitorHeatmapChart
).
props
(
'
timezone
'
)).
toBe
(
'
UTC
'
);
});
});
...
...
spec/frontend/monitoring/graph_data.js
View file @
61dd3ada
import
{
mapPanelToViewModel
,
normalizeQueryResponseData
}
from
'
~/monitoring/stores/utils
'
;
import
{
panelTypes
,
metricStates
}
from
'
~/monitoring/constants
'
;
const
initTime
=
1435781451.781
;
const
initTime
=
1435781450
;
// "Wed, 01 Jul 2015 20:10:50 GMT"
const
intervalSeconds
=
120
;
const
makeValue
=
val
=>
[
initTime
,
val
];
const
makeValues
=
vals
=>
vals
.
map
((
val
,
i
)
=>
[
initTime
+
15
*
i
,
val
]);
const
makeValues
=
vals
=>
vals
.
map
((
val
,
i
)
=>
[
initTime
+
intervalSeconds
*
i
,
val
]);
// Normalized Prometheus Responses
...
...
@@ -162,3 +163,23 @@ export const anomalyGraphData = (panelOptions = {}, dataOptions = {}) => {
...
panelOptions
,
});
};
/**
* Generate mock graph data for heatmaps according to options
*/
export
const
heatmapGraphData
=
(
panelOptions
=
{},
dataOptions
=
{})
=>
{
const
{
metricCount
=
1
}
=
dataOptions
;
return
mapPanelToViewModel
({
title
:
'
Heatmap Panel
'
,
type
:
panelTypes
.
HEATMAP
,
x_label
:
'
X Axis
'
,
y_label
:
'
Y Axis
'
,
metrics
:
Array
.
from
(
Array
(
metricCount
),
(
_
,
i
)
=>
({
label
:
`Metric
${
i
+
1
}
`
,
state
:
metricStates
.
OK
,
result
:
matrixMultiResult
(),
})),
...
panelOptions
,
});
};
spec/frontend/monitoring/mock_data.js
View file @
61dd3ada
...
...
@@ -244,83 +244,6 @@ export const metricsResult = [
},
];
export
const
graphDataPrometheusQueryRangeMultiTrack
=
{
title
:
'
Super Chart A3
'
,
type
:
'
heatmap
'
,
weight
:
3
,
x_label
:
'
Status Code
'
,
y_label
:
'
Time
'
,
metrics
:
[
{
metricId
:
'
1_metric_b
'
,
id
:
'
response_metrics_nginx_ingress_throughput_status_code
'
,
query_range
:
'
sum(rate(nginx_upstream_responses_total{upstream=~"%{kube_namespace}-%{ci_environment_slug}-.*"}[60m])) by (status_code)
'
,
unit
:
'
req / sec
'
,
label
:
'
Status Code
'
,
prometheus_endpoint_path
:
'
/root/rails_nodb/environments/3/prometheus/api/v1/query_range?query=sum%28rate%28nginx_upstream_responses_total%7Bupstream%3D~%22%25%7Bkube_namespace%7D-%25%7Bci_environment_slug%7D-.%2A%22%7D%5B2m%5D%29%29+by+%28status_code%29
'
,
result
:
[
{
metric
:
{
status_code
:
'
1xx
'
},
values
:
[
[
'
2019-08-30T15:00:00.000Z
'
,
0
],
[
'
2019-08-30T16:00:00.000Z
'
,
2
],
[
'
2019-08-30T17:00:00.000Z
'
,
0
],
[
'
2019-08-30T18:00:00.000Z
'
,
0
],
[
'
2019-08-30T19:00:00.000Z
'
,
0
],
[
'
2019-08-30T20:00:00.000Z
'
,
3
],
],
},
{
metric
:
{
status_code
:
'
2xx
'
},
values
:
[
[
'
2019-08-30T15:00:00.000Z
'
,
1
],
[
'
2019-08-30T16:00:00.000Z
'
,
3
],
[
'
2019-08-30T17:00:00.000Z
'
,
6
],
[
'
2019-08-30T18:00:00.000Z
'
,
10
],
[
'
2019-08-30T19:00:00.000Z
'
,
8
],
[
'
2019-08-30T20:00:00.000Z
'
,
6
],
],
},
{
metric
:
{
status_code
:
'
3xx
'
},
values
:
[
[
'
2019-08-30T15:00:00.000Z
'
,
1
],
[
'
2019-08-30T16:00:00.000Z
'
,
2
],
[
'
2019-08-30T17:00:00.000Z
'
,
3
],
[
'
2019-08-30T18:00:00.000Z
'
,
3
],
[
'
2019-08-30T19:00:00.000Z
'
,
2
],
[
'
2019-08-30T20:00:00.000Z
'
,
1
],
],
},
{
metric
:
{
status_code
:
'
4xx
'
},
values
:
[
[
'
2019-08-30T15:00:00.000Z
'
,
2
],
[
'
2019-08-30T16:00:00.000Z
'
,
0
],
[
'
2019-08-30T17:00:00.000Z
'
,
0
],
[
'
2019-08-30T18:00:00.000Z
'
,
2
],
[
'
2019-08-30T19:00:00.000Z
'
,
0
],
[
'
2019-08-30T20:00:00.000Z
'
,
2
],
],
},
{
metric
:
{
status_code
:
'
5xx
'
},
values
:
[
[
'
2019-08-30T15:00:00.000Z
'
,
0
],
[
'
2019-08-30T16:00:00.000Z
'
,
1
],
[
'
2019-08-30T17:00:00.000Z
'
,
0
],
[
'
2019-08-30T18:00:00.000Z
'
,
0
],
[
'
2019-08-30T19:00:00.000Z
'
,
0
],
[
'
2019-08-30T20:00:00.000Z
'
,
2
],
],
},
],
},
],
};
export
const
stackedColumnMockedData
=
{
title
:
'
memories
'
,
type
:
'
stacked-column
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment