Commit af728d53 authored by Luis Araujo's avatar Luis Araujo

Add page to submit manual tests results for image type

Add the page to submit the manual tests results for specific images types.

It renames some routes and methods to clearly state the function of the
pages and also adds a 'submitted' page to show a message after the tests
results submission.

The commit only includes the pages and forms but it doesn't enable the
functionality to submit tests results yet.
Signed-off-by: Luis Araujo's avatarLuis Araujo <luis.araujo@collabora.co.uk>
parent de72c51c
Pipeline #4111 passed with stage
in 2 minutes and 2 seconds
......@@ -43,6 +43,19 @@ from subprocess import run, SubprocessError
test_cases_repo = '/tmp/apertis-test-cases'
test_cases_files = os.path.join(test_cases_repo, 'test-cases')
priority_int_table = { 'critical': 0, 'high': 1, 'medium': 2, 'low': 3 }
# Keep track of OSTree images.
# TODO: This information should be available fronm the test cases files.
OSTreeImages = [
'minimal-armhf-internal',
'minimal-armhf-public',
'minimal-arm64-public',
'minimal-amd64-public',
'target-armhf-internal',
'target-amd64-public'
]
class TestCasesTable(object):
"""
......@@ -58,8 +71,21 @@ class TestCasesTable(object):
def set(self):
self._testcases_table = copy.deepcopy(sorted(self._tmp_table))
def get(self):
return self._testcases_table
def get(self, image_deployment_and_type=None):
# Filter manual test cases using image_type and image_deployment
if image_deployment_and_type:
imgdeployment, imgtype = image_deployment_and_type
# Checking OSTree tests for non-ostree images returns empty list []
if imgdeployment == 'ostree' and imgtype not in OSTreeImages:
return []
tmp_lst = [ e for e in self._testcases_table if \
e[1] in ['manual', 'all'] and \
imgdeployment in e[3] and imgtype in e[4] ]
# Sort test cases by priority.
return sorted(tmp_lst, key=lambda tc: priority_int_table[tc[2]])
else:
return self._testcases_table
def pull(self):
"""Method to pull git repository updates"""
......
......@@ -26,9 +26,20 @@ from wtforms import StringField, SelectField
from wtforms.validators import DataRequired
class SubmitForm(FlaskForm):
class SelectImageForm(FlaskForm):
release = StringField('Release', validators=[DataRequired()])
version = StringField('Version', validators=[DataRequired()])
deployment = SelectField('Deployment',
choices=[('apt', 'APT'), ('ostree', 'OSTree')])
image_release = StringField('Release', validators=[DataRequired()])
image_version = StringField('Version', validators=[DataRequired()])
image_deployment = SelectField('Deployment',
choices=[('apt', 'APT'), ('ostree', 'OSTree')])
image_type = SelectField('Image Type',
choices=[('minimal-armhf-public', 'Minimal ARM'),
('minimal-arm64-public', 'Minimal ARM64'),
('minimal-amd64-public', 'Minimal AMD64'),
('target-amd64-public', 'Target AMD64'),
('basesdk-amd64-public', 'BaseSDK AMD64'),
('sdk-amd64-public', 'SDK AMD64')])
class SubmitReportForm(FlaskForm):
# Form is dynamically generated from the submit_image_report.html template.
pass
......@@ -47,8 +47,23 @@ def generate_index(username=None):
key=lambda e: e[1],
reverse=True))
def generate_submit(username, form):
return render_template('submit.html', username=username, form=form)
def generate_select_image(username, form):
return render_template('select_image.html', username=username, form=form)
def generate_submit_report(username, form, image_release, image_version,
image_type, manual_testcases_table):
return render_template('submit_report.html',
username=username,
image_release=image_release,
image_version=image_version,
image_type=image_type,
testcases_table=manual_testcases_table,
priority_color_table=priority_color_table,
test_cases_url=config['test-cases-url'],
form=form)
def generate_submitted():
return render_template('submitted.html')
def generate_report(image_release, image_version,
image_deployment, testcases_table):
......
......@@ -13,7 +13,7 @@
<div class="col">
{% if username %}
Logged in as {{ username }}
<a href="/submit" role="button" class="btn btn-info">Submit Manual Test Report</a>
<a href="/select_image" role="button" class="btn btn-info">Submit Manual Test Report</a>
{% else %}
<a href="/login" class="btn btn-primary" role="button">Login</a>
{% endif %}
......
......@@ -15,18 +15,24 @@
<hr />
<div class="card-body mx-auto" style="width: 25rem;">
<h4>Submit Manual Test Report</h4>
<h4>Select Image Report</h4>
<hr />
<form method="post">
<div class="form-group">
{{ form.release.label }} {{ form.release(class_='form-control') }}
{{ form.image_release.label }}
{{ form.image_release(class_='form-control') }}
</div>
<div class="form-group">
{{ form.version.label }} {{ form.version(class_='form-control') }}
{{ form.image_version.label }}
{{ form.image_version(class_='form-control') }}
</div>
<div class="form-group">
{{ form.deployment.label }}
{{ form.deployment(class_='form-control') }}
{{ form.image_deployment.label }}
{{ form.image_deployment(class_='form-control') }}
</div>
<div class="form-group">
{{ form.image_type.label }}
{{ form.image_type(class_='form-control') }}
</div>
<button type="submit" class="btn btn-primary">Submit</button>
{{ form.csrf_token }}
......
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}" />
<title>Test Report Submission</title>
</head>
<body>
<main role="main" class="container" style="margin-top: 40px; margin-bottom: 40px">
<h2>Manual Test Report Submission</h2>
<hr />
<div class="container mb-md-3">
<p>
Build: <b>{{ image_version }}</b> / Release: <b>{{ image_release }}</b>
</p>
</div>
<form method="post" id="tests_results">
<div class="row">
<div class="col"><h3>{{ image_type }}</h3> <em class="text-muted">{{ testcases_table|count }} test cases</em></div>
<div class="col text-right"><button type="submit" class="btn btn-primary">Submit All Results</button></div>
</div>
{% for test_case, exec_type, priority, deployments, platforms in testcases_table %}
<div class="card" style="border: none">
<div class="card-body">
<div class="row">
<!-- Test results selection -->
<div class="col">
<h5 class="card-title"><a href="{{test_cases_url}}/{{ test_case }}.html">{{ test_case }}</a></h5>
<h5><span class="badge table-{{ priority_color_table[priority] }}">{{ priority }}</span></h5>
</div>
<div class="col">
<div class="form-group" style="margin-bottom: 0px">
<label class="radio-inline" style="margin-right: 10px;"><input type="radio" name="{{ test_case }}" value="pass"> PASS</label>
<label class="radio-inline" style="margin-right: 10px;"><input type="radio" name="{{ test_case }}" value="fail"> FAIL</label>
<label class="radio-inline" style="margin-right: 10px;"><input type="radio" name="{{ test_case }}" value="not_tested" checked> NOT TESTED</label>
</div>
</div>
<!-- Text Area -->
<div class="col text-right">
<textarea id="{{ test_case }}_notes" name="{{ test_case }}_notes" class="form-control" style="height: 40px; margin-bottom: 10px" placeholder="Notes ..."></textarea>
</div>
</div>
</div>
<!-- Close card body -->
</div>
{% endfor %}
{{ form.csrf_token }}
</form>
</main>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}" />
<title>Test Report Submission</title>
</head>
<body>
<main role="main" class="container" style="margin-top: 40px; margin-bottom: 40px">
<h2>Manual Test Report Submission</h2>
<hr />
<div class="container mb-md-3">
<h4>Manual Tests Result Submitted</h4>
<p>Submit a new image report or check submitted report from the Main page</p>
<a href="/select_image" role="button" class="btn btn-info">Submit Manual Test Report</a> or <a href="/" role="button" class="btn btn-info">Go Back to Main Page</a>
</div>
</main>
</body>
</html>
......@@ -36,8 +36,9 @@ from taskmanager import connect_to_phab, process_results
from testobjects import TestJob
from models import db
from save import save_job
from pages import generate_index, generate_submit, generate_report
from forms import SubmitForm
from pages import generate_index, generate_report, \
generate_select_image, generate_submit_report, generate_submitted
from forms import SelectImageForm, SubmitReportForm
from apscheduler.schedulers.background import BackgroundScheduler
from data.testcases_table import TestCasesTable
......@@ -112,17 +113,38 @@ def index():
logging.error(e)
return 'Reports list error', HTTPStatus.NOT_FOUND
@app.route('/submit', methods=['GET', 'POST'])
def submit():
@app.route('/select_image', methods=['GET', 'POST'])
def select_image():
if not gitlab.authorized:
return redirect(url_for('login'))
form = SubmitForm()
form = SelectImageForm()
if form.validate_on_submit():
# TODO: Process received data here
return redirect(url_for('index'))
return redirect(url_for('submit_report',
image_release=request.form['image_release'],
image_version=request.form['image_version'],
image_type=request.form['image_type'],
image_deployment=request.form['image_deployment']))
return generate_select_image(session['username'], form)
@app.route('/submit_report/<image_release>/<image_version>/'
'<image_type>/<image_deployment>',
methods=['GET', 'POST'])
def submit_report(image_release, image_version, image_type, image_deployment):
if not gitlab.authorized:
return redirect(url_for('login'))
return generate_submit(session['username'], form)
form = SubmitReportForm()
if form.validate_on_submit():
return generate_submitted()
# Generate a submit report page with only manual test cases for the specified
# image type and deployment.
return \
generate_submit_report(session['username'], form,
image_release, image_version, image_type,
testcases_table.get((image_deployment, image_type)))
@app.route('/', methods=['POST'])
@app.route('/lava/post', methods=['POST'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment