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
c4deeaed
Commit
c4deeaed
authored
May 26, 2017
by
kushalpandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add memory delta support
parent
1ae57c83
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
13 deletions
+74
-13
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_memory_usage.js
...merge_request_widget/components/mr_widget_memory_usage.js
+25
-11
spec/javascripts/vue_mr_widget/components/mr_widget_memory_usage_spec.js
...s/vue_mr_widget/components/mr_widget_memory_usage_spec.js
+49
-2
No files found.
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_memory_usage.js
View file @
c4deeaed
...
...
@@ -9,8 +9,8 @@ export default {
},
data
()
{
return
{
//
memoryFrom: 0,
//
memoryTo: 0,
memoryFrom
:
0
,
memoryTo
:
0
,
memoryMetrics
:
[],
deploymentTime
:
0
,
hasMetrics
:
false
,
...
...
@@ -35,18 +35,32 @@ export default {
shouldShowMetricsUnavailable
()
{
return
!
this
.
loadingMetrics
&&
!
this
.
hasMetrics
&&
!
this
.
loadFailed
;
},
memoryChangeType
()
{
if
(
this
.
memoryTo
>
this
.
memoryFrom
)
{
return
'
increased
'
;
}
else
if
(
this
.
memoryTo
<
this
.
memoryFrom
)
{
return
'
decreased
'
;
}
return
'
unchanged
'
;
},
},
methods
:
{
getMegabytes
(
bytesString
)
{
const
valueInBytes
=
Number
(
bytesString
).
toFixed
(
2
);
return
(
valueInBytes
/
(
1024
*
1024
)).
toFixed
(
2
);
},
computeGraphData
(
metrics
,
deploymentTime
)
{
this
.
loadingMetrics
=
false
;
const
{
memory_values
}
=
metrics
;
// if (memory_previous.length > 0) {
// this.memoryFrom = Number(memory_previous[0].value[1]).toFixed(2);
// }
//
// if (memory_current.length > 0) {
// this.memoryTo = Number(memory_current[0].value[1]).toFixed(2);
// }
const
{
memory_before
,
memory_after
,
memory_values
}
=
metrics
;
if
(
memory_before
.
length
>
0
)
{
this
.
memoryFrom
=
this
.
getMegabytes
(
memory_before
[
0
].
value
[
1
]);
}
if
(
memory_after
.
length
>
0
)
{
this
.
memoryTo
=
this
.
getMegabytes
(
memory_after
[
0
].
value
[
1
]);
}
if
(
memory_values
.
length
>
0
)
{
this
.
hasMetrics
=
true
;
...
...
@@ -102,7 +116,7 @@ export default {
<p
v-if="shouldShowMemoryGraph"
class="usage-info js-usage-info">
Deployment memory usage:
Memory usage <b>{{memoryChangeType}}</b> from {{memoryFrom}}MB to {{memoryTo}}MB
</p>
<p
v-if="shouldShowLoadFailure"
...
...
spec/javascripts/vue_mr_widget/components/mr_widget_memory_usage_spec.js
View file @
c4deeaed
...
...
@@ -7,6 +7,18 @@ const url = '/root/acets-review-apps/environments/15/deployments/1/metrics';
const
metricsMockData
=
{
success
:
true
,
metrics
:
{
memory_before
:
[
{
metric
:
{},
value
:
[
1495785220.607
,
'
9572875.906976745
'
],
},
],
memory_after
:
[
{
metric
:
{},
value
:
[
1495787020.607
,
'
4485853.130206379
'
],
},
],
memory_values
:
[
{
metric
:
{},
...
...
@@ -39,7 +51,7 @@ const createComponent = () => {
const
messages
=
{
loadingMetrics
:
'
Loading deployment statistics.
'
,
hasMetrics
:
'
Deployment memory usage:
'
,
hasMetrics
:
'
Memory usage unchanged from 0MB to 0MB
'
,
loadFailed
:
'
Failed to load deployment statistics.
'
,
metricsUnavailable
:
'
Deployment statistics are not available currently.
'
,
};
...
...
@@ -89,17 +101,52 @@ describe('MemoryUsage', () => {
});
});
describe
(
'
computed
'
,
()
=>
{
describe
(
'
memoryChangeType
'
,
()
=>
{
it
(
'
should return "increased" if memoryFrom value is less than memoryTo value
'
,
()
=>
{
vm
.
memoryFrom
=
4.28
;
vm
.
memoryTo
=
9.13
;
expect
(
vm
.
memoryChangeType
).
toEqual
(
'
increased
'
);
});
it
(
'
should return "decreased" if memoryFrom value is less than memoryTo value
'
,
()
=>
{
vm
.
memoryFrom
=
9.13
;
vm
.
memoryTo
=
4.28
;
expect
(
vm
.
memoryChangeType
).
toEqual
(
'
decreased
'
);
});
it
(
'
should return "unchanged" if memoryFrom value equal to memoryTo value
'
,
()
=>
{
vm
.
memoryFrom
=
1
;
vm
.
memoryTo
=
1
;
expect
(
vm
.
memoryChangeType
).
toEqual
(
'
unchanged
'
);
});
});
});
describe
(
'
methods
'
,
()
=>
{
const
{
metrics
,
deployment_time
}
=
metricsMockData
;
describe
(
'
getMegabytes
'
,
()
=>
{
it
(
'
should return Megabytes from provided Bytes value
'
,
()
=>
{
const
memoryInBytes
=
'
9572875.906976745
'
;
expect
(
vm
.
getMegabytes
(
memoryInBytes
)).
toEqual
(
'
9.13
'
);
});
});
describe
(
'
computeGraphData
'
,
()
=>
{
it
(
'
should populate sparkline graph
'
,
()
=>
{
vm
.
computeGraphData
(
metrics
,
deployment_time
);
const
{
hasMetrics
,
memoryMetrics
,
deploymentTime
}
=
vm
;
const
{
hasMetrics
,
memoryMetrics
,
deploymentTime
,
memoryFrom
,
memoryTo
}
=
vm
;
expect
(
hasMetrics
).
toBeTruthy
();
expect
(
memoryMetrics
.
length
>
0
).
toBeTruthy
();
expect
(
deploymentTime
).
toEqual
(
deployment_time
);
expect
(
memoryFrom
).
toEqual
(
'
9.13
'
);
expect
(
memoryTo
).
toEqual
(
'
4.28
'
);
});
});
...
...
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