Commit 36b441cf authored by Aurélien Campéas's avatar Aurélien Campéas
Browse files

test: track monitors tab output

parent a9c1268396d4
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<br>
<table class="table table-sm table-bordered table-striped table-hover">
<thead class="thead-inverse"><tr>
<th>#</th>
<th>domain</th>
<th>seen last</th>
<th>options</th>
</tr></thead>
<tr>
<td><x></x></td>
<td>default</td>
<td style="color: DarkGreen"><x>-<x>-<x> <x>:<x>:<x>+<x></x></x></x></x></x></x></x></td>
<td>debugport=<x>, maxmem=<x>, maxruns=<x>, maxworkers=<x>, minworkers=<x></x></x></x></x></x>
</td>
</tr>
</table>
<table class="table table-sm table-bordered table-striped table-hover">
<thead class="thead-inverse"><tr>
<th>#</th>
<th>pid@host</th>
<th>domain</th>
<th>memory (Mb)</th>
<th>debug port</th>
<th>action</th>
</tr></thead>
<tr>
<th scope="row"><x></x></th>
<td><x>@<x>.<x>.<x>.<x></x></x></x></x></x></td>
<td>default</td>
<td><x></x></td>
<td></td>
<td>
<button type="button" class="btn btn-warning btn-sm" onclick="shutdown_worker(&lt;X&gt;)">shutdown</button><span> </span><button type="button" class="btn btn-danger btn-sm" onclick="kill_worker(&lt;X&gt;)">kill</button>
</td>
</tr>
</table>
</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<br>
<table class="table table-sm table-bordered table-striped table-hover">
<thead class="thead-inverse"><tr>
<th>#</th>
<th>domain</th>
<th>seen last</th>
<th>options</th>
</tr></thead>
<tr>
<td><x></x></td>
<td>default</td>
<td style="color: DarkGreen"><x>-<x>-<x> <x>:<x>:<x>+<x></x></x></x></x></x></x></x></td>
<td>debugport=<x>, maxmem=<x>, maxruns=<x>, maxworkers=<x>, minworkers=<x></x></x></x></x></x>
</td>
</tr>
</table>
<table class="table table-sm table-bordered table-striped table-hover">
<thead class="thead-inverse"><tr>
<th>#</th>
<th>pid@host</th>
<th>domain</th>
<th>memory (Mb)</th>
<th>debug port</th>
<th>action</th>
</tr></thead>
<tr>
<th scope="row"><x></x></th>
<td><x>@<x>.<x>.<x>.<x></x></x></x></x></x></td>
<td>default</td>
<td><x></x></td>
<td></td>
<td>
<button type="button" class="btn btn-warning btn-sm" onclick="shutdown_worker(&lt;X&gt;)">shutdown</button><span> </span><button type="button" class="btn btn-danger btn-sm" onclick="kill_worker(&lt;X&gt;)">kill</button>
</td>
</tr>
</table>
</body></html>
......@@ -14,6 +14,12 @@ DATADIR = Path(__file__).parent / 'data'
# html editor
def normalize(htmlstr):
tree = etree.fromstring(htmlstr, parser=etree.HTMLParser())
return etree.tostring(tree.getroottree(),
pretty_print=True, method='html')
def edittag(tag, editor, anstr):
if isinstance(tag, str):
tags = [tag]
......@@ -146,6 +152,30 @@ def test_task_life_cycle(engine, client, refresh):
assert html == refpath.read_bytes()
def test_monitors_table(engine, client, refresh):
with engine.begin() as cn:
cn.execute('delete from rework.monitor')
cn.execute('delete from rework.worker')
with workers(engine):
res = client.get('/workers-table')
html = normalize(scrub(res.text))
refpath = DATADIR / 'monitors-table.html'
if refresh:
refpath.write_bytes(html)
assert html == refpath.read_bytes()
t = api.schedule(engine, 'abortme')
t.join('running')
res = client.get('/workers-table')
html = normalize(scrub(res.text))
refpath = DATADIR / 'monitors-table-1-task.html'
if refresh:
refpath.write_bytes(html)
assert html == refpath.read_bytes()
def test_tasks_table(engine, client, refresh):
with engine.begin() as cn:
cn.execute('delete from rework.task')
......@@ -213,7 +243,7 @@ def test_tasks_table(engine, client, refresh):
t.join()
taskstable.refresh_tasks_file(engine)
res = client.get('/tasks-table-hash?domain=uranus')
assert res.text == '98cc14b1de9bdd660aaa61f8b2ac4144'
assert res.text == 'cbcf36e551ad8fdc0aef16fbefd7c6be'
res = client.get('/tasks-table?domain=uranus')
refpath = DATADIR / 'tasks-table-uranus.html'
if refresh:
......
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