BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
5d8891fb
Commit
5d8891fb
authored
Apr 18, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests
parent
da2a7823
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
12 deletions
+128
-12
deployments.js
app/assets/javascripts/monitoring/deployments.js
+2
-2
prometheus_graph.js
app/assets/javascripts/monitoring/prometheus_graph.js
+9
-9
metrics.html.haml
spec/javascripts/fixtures/environments/metrics.html.haml
+1
-1
deployments_spec.js
spec/javascripts/monitoring/deployments_spec.js
+116
-0
No files found.
app/assets/javascripts/monitoring/deployments.js
View file @
5d8891fb
...
@@ -30,9 +30,9 @@ export default class Deployments {
...
@@ -30,9 +30,9 @@ export default class Deployments {
this
.
data
=
[];
this
.
data
=
[];
data
.
deployments
.
forEach
((
deployment
)
=>
{
data
.
deployments
.
forEach
((
deployment
)
=>
{
const
coeff
=
1000
*
60
;
const
minInSeconds
=
1000
*
60
;
let
time
=
new
Date
(
deployment
.
created_at
);
let
time
=
new
Date
(
deployment
.
created_at
);
time
=
new
Date
(
Math
.
round
(
time
.
getTime
()
/
coeff
)
*
coeff
);
time
=
new
Date
(
Math
.
round
(
time
.
getTime
()
/
minInSeconds
)
*
minInSeconds
);
time
.
setSeconds
(
this
.
chartData
[
0
].
time
.
getSeconds
());
time
.
setSeconds
(
this
.
chartData
[
0
].
time
.
getSeconds
());
const
xPos
=
Math
.
floor
(
this
.
x
(
time
));
const
xPos
=
Math
.
floor
(
this
.
x
(
time
));
...
...
app/assets/javascripts/monitoring/prometheus_graph.js
View file @
5d8891fb
...
@@ -222,15 +222,6 @@ class PrometheusGraph {
...
@@ -222,15 +222,6 @@ class PrometheusGraph {
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.circle-metric`
).
remove
();
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.circle-metric`
).
remove
();
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.rect-text-metric:not(.deploy-info-rect)`
).
remove
();
d3
.
selectAll
(
`
${
prometheusGraphContainer
}
.rect-text-metric:not(.deploy-info-rect)`
).
remove
();
chart
.
append
(
'circle'
)
.
attr
(
'class'
,
'circle-metric'
)
.
attr
(
'fill'
,
graphSpecifics
.
line_color
)
.
attr
(
'cx'
,
currentTimeCoordinate
)
.
attr
(
'cy'
,
y
(
currentData
.
value
))
.
attr
(
'r'
,
this
.
commonGraphProperties
.
circle_radius_metric
);
if
(
shouldHideTextMetric
)
return
;
chart
.
append
(
'line'
)
chart
.
append
(
'line'
)
.
attr
(
'class'
,
'selected-metric-line'
)
.
attr
(
'class'
,
'selected-metric-line'
)
.
attr
({
.
attr
({
...
@@ -240,6 +231,15 @@ class PrometheusGraph {
...
@@ -240,6 +231,15 @@ class PrometheusGraph {
y2
:
maxValueMetric
,
y2
:
maxValueMetric
,
});
});
chart
.
append
(
'circle'
)
.
attr
(
'class'
,
'circle-metric'
)
.
attr
(
'fill'
,
graphSpecifics
.
line_color
)
.
attr
(
'cx'
,
currentTimeCoordinate
)
.
attr
(
'cy'
,
y
(
currentData
.
value
))
.
attr
(
'r'
,
this
.
commonGraphProperties
.
circle_radius_metric
);
if
(
shouldHideTextMetric
)
return
;
// The little box with text
// The little box with text
const
rectTextMetric
=
chart
.
append
(
'svg'
)
const
rectTextMetric
=
chart
.
append
(
'svg'
)
.
attr
(
'class'
,
'rect-text-metric'
)
.
attr
(
'class'
,
'rect-text-metric'
)
...
...
spec/javascripts/fixtures/environments/metrics.html.haml
View file @
5d8891fb
%div
#js-metrics
{
data:
{
endpoint:
'/test'
}
}
%svg
.graph-line-shadow
%svg
.graph-line-shadow
.top-area
.top-area
.row
.row
...
...
spec/javascripts/monitoring/deployments_spec.js
0 → 100644
View file @
5d8891fb
import
d3
from
'd3'
;
import
PrometheusGraph
from
'~/monitoring/prometheus_graph'
;
import
Deployments
from
'~/monitoring/deployments'
;
import
{
prometheusMockData
}
from
'./prometheus_mock_data'
;
fdescribe
(
'Metrics deployments'
,
()
=>
{
const
fixtureName
=
'static/environments/metrics.html.raw'
;
let
deployment
;
let
prometheusGraph
;
const
createDeploymentMockData
=
(
done
)
=>
{
return
{
deployments
:
[{
id
:
1
,
created_at
:
deployment
.
chartData
[
10
].
time
,
sha
:
'testing'
,
tag
:
false
,
ref
:
{
name
:
'testing'
,
},
},
{
id
:
2
,
created_at
:
deployment
.
chartData
[
15
].
time
,
sha
:
''
,
tag
:
true
,
ref
:
{
name
:
'tag'
,
},
}],
};
};
const
graphElement
=
()
=>
document
.
querySelector
(
'.prometheus-graph'
);
preloadFixtures
(
fixtureName
);
beforeEach
((
done
)
=>
{
// Setup the view
loadFixtures
(
fixtureName
);
d3
.
selectAll
(
'.prometheus-graph'
)
.
append
(
'g'
)
.
attr
(
'class'
,
'graph-container'
);
prometheusGraph
=
new
PrometheusGraph
();
deployment
=
new
Deployments
(
1000
,
500
);
spyOn
(
prometheusGraph
,
'init'
);
spyOn
(
$
,
'ajax'
).
and
.
callFake
(()
=>
{
const
d
=
$
.
Deferred
();
d
.
resolve
(
createDeploymentMockData
());
setTimeout
(
done
);
return
d
.
promise
();
});
prometheusGraph
.
transformData
(
prometheusMockData
.
metrics
);
deployment
.
init
(
prometheusGraph
.
data
.
memory_values
);
});
it
(
'creates line on graph for deploment'
,
()
=>
{
expect
(
graphElement
().
querySelectorAll
(
'.deployment-line'
).
length
,
).
toBe
(
2
);
});
it
(
'creates hidden deploy boxes'
,
()
=>
{
expect
(
graphElement
().
querySelectorAll
(
'.prometheus-graph .js-deploy-info-box'
).
length
,
).
toBe
(
2
);
});
it
(
'hides the info boxes by default'
,
()
=>
{
expect
(
graphElement
().
querySelectorAll
(
'.prometheus-graph .js-deploy-info-box.hidden'
).
length
,
).
toBe
(
2
);
});
it
(
'shows sha short code when tag is false'
,
()
=>
{
expect
(
graphElement
().
querySelector
(
'.deploy-info-1 .js-deploy-info-box'
).
textContent
.
trim
(),
).
toContain
(
'testin'
);
});
it
(
'shows ref name when tag is true'
,
()
=>
{
expect
(
graphElement
().
querySelector
(
'.deploy-info-2 .js-deploy-info-box'
).
textContent
.
trim
(),
).
toContain
(
'tag'
);
});
it
(
'shows info box when moving mouse over line'
,
()
=>
{
deployment
.
mouseOverDeployInfo
(
deployment
.
data
[
0
].
xPos
);
expect
(
graphElement
().
querySelectorAll
(
'.prometheus-graph .js-deploy-info-box.hidden'
).
length
,
).
toBe
(
1
);
expect
(
graphElement
().
querySelector
(
'.deploy-info-1 .js-deploy-info-box.hidden'
),
).
toBeNull
();
});
it
(
'hides previously visible info box when moving mouse away'
,
()
=>
{
deployment
.
mouseOverDeployInfo
(
500
);
expect
(
graphElement
().
querySelectorAll
(
'.prometheus-graph .js-deploy-info-box.hidden'
).
length
,
).
toBe
(
2
);
expect
(
graphElement
().
querySelector
(
'.deploy-info-1 .js-deploy-info-box.hidden'
),
).
not
.
toBeNull
();
});
});
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