Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
truenas-rk3588
truenas
Commits
c7c74c4f
Commit
c7c74c4f
authored
10 years ago
by
William Grzybowski
Browse files
Options
Download
Email Patches
Plain Diff
Add a Performance Test button
Ticket: #5466 (cherry picked from commit
ff7497b4
)
parent
ced2c7de
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
gui/system/urls.py
+3
-0
gui/system/urls.py
gui/system/views.py
+101
-0
gui/system/views.py
gui/templates/system/advanced_edit.html
+6
-0
gui/templates/system/advanced_edit.html
gui/templates/system/perftest.html
+33
-0
gui/templates/system/perftest.html
with
143 additions
and
0 deletions
+143
-0
gui/system/urls.py
View file @
c7c74c4f
...
...
@@ -53,6 +53,9 @@ urlpatterns = patterns('freenasUI.system.views',
url
(
r
'^clear-cache/$'
,
'clearcache'
,
name
=
"system_clearcache"
),
url
(
r
'^lsdir/(?P<path>.*)$'
,
'directory_browser'
,
name
=
"system_dirbrowser"
),
url
(
r
'^lsfiles/(?P<path>.*)$'
,
'file_browser'
,
name
=
"system_filebrowser"
),
url
(
r
'^perftest/$'
,
'perftest'
,
name
=
'system_perftest'
),
url
(
r
'^perftest/download/$'
,
'perftest_download'
,
name
=
'system_perftest_download'
),
url
(
r
'^perftest/progress/$'
,
'perftest_progress'
,
name
=
'system_perftest_progress'
),
url
(
r
'^restart-httpd/$'
,
'restart_httpd'
,
name
=
"system_restart_httpd"
),
url
(
r
'^reload-httpd/$'
,
'reload_httpd'
,
name
=
"system_reload_httpd"
),
url
(
r
'^terminal/$'
,
'terminal'
,
name
=
"system_terminal"
),
...
...
This diff is collapsed.
Click to expand it.
gui/system/views.py
View file @
c7c74c4f
...
...
@@ -53,6 +53,7 @@ from freenasUI.common.system import get_sw_name, get_sw_version, send_mail
from
freenasUI.common.pipesubr
import
pipeopen
from
freenasUI.freeadmin.apppool
import
appPool
from
freenasUI.freeadmin.views
import
JsonResp
from
freenasUI.middleware.exceptions
import
MiddlewareError
from
freenasUI.middleware.notifier
import
notifier
from
freenasUI.network.models
import
GlobalConfiguration
from
freenasUI.storage.models
import
MountPoint
...
...
@@ -63,6 +64,7 @@ VERSION_FILE = '/etc/version'
PGFILE
=
'/tmp/.extract_progress'
DDFILE
=
'/tmp/.upgrade_dd'
RE_DD
=
re
.
compile
(
r
"^(\d+) bytes"
,
re
.
M
|
re
.
S
)
PERFTEST_SIZE
=
40
*
1024
*
1024
*
1024
# 40 GiB
log
=
logging
.
getLogger
(
'system.views'
)
...
...
@@ -523,6 +525,105 @@ def firmware_progress(request):
return
HttpResponse
(
content
,
content_type
=
'application/json'
)
def
perftest
(
request
):
systemdataset
,
volume
,
basename
=
notifier
().
system_dataset_settings
()
if
request
.
method
==
'GET'
:
return
render
(
request
,
'system/perftest.html'
)
if
not
basename
:
raise
MiddlewareError
(
_
(
'System dataset is required to perform this action.'
)
)
dump
=
'/mnt/%s/perftest.txz'
%
basename
perftestdataset
=
'%s/perftest'
%
basename
with
mntlock
(
mntpt
=
'/mnt/%s'
%
basename
):
_n
=
notifier
()
rv
,
errmsg
=
_n
.
create_zfs_dataset
(
path
=
perftestdataset
,
props
=
{
'primarycache'
:
'metadata'
,
'secondarycache'
:
'metadata'
,
'compression'
:
'off'
,
},
_restart_collectd
=
False
,
)
currdir
=
os
.
getcwd
()
os
.
chdir
(
'/mnt/%s'
%
perftestdataset
)
with
open
(
'/mnt/%s/iozone.txt'
%
perftestdataset
,
'w'
)
as
f
:
p1
=
subprocess
.
Popen
(
'/usr/local/bin/iozone -r 128 -s %sk -i 0 -i 1'
%
(
PERFTEST_SIZE
/
1024
,
),
stdout
=
f
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
,
)
p1
.
communicate
()
os
.
chdir
(
'..'
)
p1
=
pipeopen
(
'tar -cJf %s perftest'
%
dump
)
p1
.
communicate
()
os
.
chdir
(
currdir
)
_n
.
destroy_zfs_dataset
(
perftestdataset
)
return
JsonResp
(
request
,
message
=
'Performance test has completed.'
,
events
=
[
'window.location=
\'
%s
\'
'
%
reverse
(
'system_perftest_download'
),
],
)
def
perftest_download
(
request
):
systemdataset
,
volume
,
basename
=
notifier
().
system_dataset_settings
()
dump
=
'/mnt/%s/perftest.txz'
%
basename
wrapper
=
FileWrapper
(
file
(
dump
))
response
=
StreamingHttpResponse
(
wrapper
,
content_type
=
'application/octet-stream'
,
)
response
[
'Content-Length'
]
=
os
.
path
.
getsize
(
dump
)
response
[
'Content-Disposition'
]
=
\
'attachment; filename=perftest-%s-%s.tgz'
%
(
socket
.
gethostname
(),
time
.
strftime
(
'%Y%m%d%H%M%S'
))
return
response
def
perftest_progress
(
request
):
systemdataset
,
volume
,
basename
=
notifier
().
system_dataset_settings
()
iozonefile
=
'/mnt/%s/perftest/iozone.tmp'
%
basename
percent
=
0
step
=
1
indeterminate
=
False
if
os
.
path
.
exists
(
iozonefile
):
size
=
os
.
stat
(
iozonefile
).
st_size
percent
=
int
((
float
(
size
)
/
PERFTEST_SIZE
)
*
100.0
)
if
percent
==
100
:
step
=
2
percent
=
0
indeterminate
=
True
content
=
json
.
dumps
({
'step'
:
step
,
'percent'
:
percent
,
'indeterminate'
:
indeterminate
,
})
return
HttpResponse
(
content
,
content_type
=
'application/json'
)
def
restart_httpd
(
request
):
""" restart httpd """
notifier
().
restart
(
"http"
)
...
...
This diff is collapsed.
Click to expand it.
gui/templates/system/advanced_edit.html
View file @
c7c74c4f
...
...
@@ -14,6 +14,12 @@
window
.
location
=
'
{% url "system_debug" %}
'
;
</script>
</button>
<button
id=
"btn_{% cls_name form %}_PerfTest"
data-dojo-type=
"dijit.form.Button"
type=
"button"
>
{% trans "Performance Test" %}
<script
type=
"dojo/method"
data-dojo-event=
"onClick"
data-dojo-args=
"evt"
>
editScaryObject
(
'
{% trans "Performance Test"|escapejs %}
'
,
'
{% url "system_perftest" %}
'
);
</script>
</button>
<button
id=
"btn_{% cls_name form %}_FwUpdate"
data-dojo-type=
"dijit.form.Button"
type=
"button"
>
{% trans "Firmware Update" %}
<script
type=
"dojo/method"
data-dojo-event=
"onClick"
data-dojo-args=
"evt"
>
...
...
This diff is collapsed.
Click to expand it.
gui/templates/system/perftest.html
0 → 100644
View file @
c7c74c4f
{% extends "freeadmin/generic_form.html" %}
{% block onSubmit %}
console.log("here");
doSubmit({
form: this,
event: e,
url: '{{ request.path }}',
progressbar: {
steps: [
{"label": gettext("Writing file")},
{"label": gettext("Reading file")}
],
poolUrl: '{% url "system_perftest_progress" %}',
fileUpload: false
}
});
{% endblock %}
{% block form %}
<p>
{% trans "You are about to start a performance test." %}
<br
/>
{% trans "Are you sure you want to proceed?" %}
</p>
{% endblock %}
{% block buttons %}
<button
id=
"btn_PerfTest_Ok"
data-dojo-type=
"dijit.form.Button"
type=
"submit"
>
{% trans "Yes" %}
</button>
<button
id=
"btn_PerfTest_Cancel"
data-dojo-type=
"dijit.form.Button"
type=
"button"
>
<script
type=
"dojo/method"
data-dojo-event=
"onClick"
data-dojo-args=
"evt"
>
cancelDialog
(
this
);
</script>
{% trans "No" %}
</button>
{% endblock %}
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help