Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions mod_test/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
url_for)
from sqlalchemy import and_, func
from sqlalchemy.sql import label
from sqlalchemy import func


from decorators import template_renderer
from exceptions import TestNotFoundException
Expand Down Expand Up @@ -447,3 +449,44 @@ def stop_test(test_id):
g.db.commit()
g.log.info(f"test with id: {test_id} stopped")
return redirect(url_for('.by_id', test_id=test.id))


@mod_regression.route('/progress', methods=['GET'])
def progress():
"""
Get regression test progress stats
Optional: filter by run or sample
Default: global progress
"""
run = request.args.get('run')

total = RegressionTest.query.filter(RegressionTest.active == True).count()
done = 0
try:
if run:
if hasattr(TestResultFile, 'run_uuid'):
done = TestResultFile.query.filter(
TestResultFile.run_uuid == run,
TestResultFile.got.isnot(None)
).count()
elif hasattr(TestResultFile, 'run_id'):
done = TestResultFile.query.filter(
TestResultFile.run_id == run,
TestResultFile.got.isnot(None)
).count()
else:
done = TestResultFile.query.filter(
TestResultFile.got.isnot(None)
).distinct(TestResultFile.regression_test_id).count()

except Exception:
done = TestResultFile.query.filter(TestResultFile.got.isnot(None)).count()

pct = 100 if total == 0 else int((done / total) * 100)

return jsonify({
'status': 'success',
'total': total,
'completed': done,
'percent': pct
})
28 changes: 28 additions & 0 deletions templates/test/by_id.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ <h1>Test progress for {{ title }}</h1>
{%- endfor %}
</ol>
<br class="clear" />

<!-- LIVE testing progress UI-->
<div id="testing-progress-container" style="display:none; margin-top:12px;">
<div style="margin-bottom:6px;">
<strong id="testing-progress-label">Testing: 0/0 (0%)</strong>
</div>
<progress id="testing-progress-bar" value="0" max="100" style="width:100%; height:16px;"></progress>
</div>

{% if test.progress|length > 0 %}
<input type="button" id="progress_button" class="button" value="Show test progress" />
{% if test.finished %}
Expand Down Expand Up @@ -178,6 +187,25 @@ <h6>There are no tests executed in this category.</h6>
window.location.reload();
}
val = data.progress_array;

if (typeof data.progress_percent !== 'undefined') {
try {
var pct = parseInt(data.progress_percent,10);
var total = parseInt(data.total_tests || 0,10);
var done = parseInt(data.completed_tests || 0, 10);

if(total>0 || pct>0){
$('#testing-progress-container').show();
$('#testing-progress-bar').attr('value', pct);
$('#testing-progress-label').text('Testing: ' + done + '/' + total + ' (' + pct + '%)');
} else{
$('#testing-progress-container').hide();
}
}
catch(e){
console.log('progress update error',e);
}
}
if (testprogress === 0 && val.length !== 0) {
window.location.reload();
}
Expand Down
Loading