Skip to content

Commit 8f8fea4

Browse files
committed
Some more small fixes and adding helper description
1 parent d98ae2c commit 8f8fea4

3 files changed

Lines changed: 63 additions & 100 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ If no `config.json` is found, all tests are run locally and are not submitted to
3030

3131
If a `config.json` is provided, it requires the specification of the URL at which the regression server is located, the hardware string under which the test images are submitted, and a runner id that has to be provided by the administrator of the regression test server. If all these values are correct, test images are directly submitted to the regression server and be can used to compare against a reference image.
3232

33+
### Helper scripts
34+
The runner folder also contains useful helper scripts that can be used to communicate with the image testing server.
35+
36+
### copy_server
37+
This script can be used to copy the results from an existing image testing (source) server to a new instance (destination). The existing results will be submitted to the destination server as if they had been done by running a test, so the result will be indistinguishable for the destination server. The commandline arguments are `--source` for the URL of the server from which the results should be copied, `--destination` for the URL to which the results should be copied, and `--runner` which is a valid runner id for the **destination** server. No credentials for the source server are needed.
38+
39+
Example: `python copy_server.py --source https://regression.openspaceproject.com --destination http://localhost:8000 --runner runner-id`
40+
3341

3442
## Backend
3543
The _backend_ is a Typescript-based server that is receiving individual tests, creating comparison images, and making past tests available via a website. By default this server is located at [https://regression.openspaceproject.com](https://regression.openspaceproject.com), but it is also possible to run a local copy of it.

backend/public/compare/functions.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ async function generateComparison() {
22
const records = await fetch("/api/test-records").then(res => res.json());
33

44
// Get a unique list of all hardwares used in the tests
5-
const hardwares = []
5+
let hardwares = []
66
for (const record of records) {
77
if (!hardwares.includes(record.hardware)) {
88
hardwares.push(record.hardware);
@@ -30,31 +30,36 @@ async function generateComparison() {
3030
table.removeChild(table.lastElementChild);
3131
}
3232

33-
for (const i = 0; i < hardwares.length; i++) {
33+
for (let i = 0; i < hardwares.length; i++) {
3434
const tr = document.createElement("tr");
3535

3636
// First add the empty elements to the left of the diagonal
37-
for (const j = 0; j < i; j++) {
37+
for (let j = 0; j < i; j++) {
3838
tr.appendChild(document.createElement("td"));
3939
}
4040

4141
// Second, add the diagonal element
42-
const a = document.createElement("a");
43-
a.href = `/api/result/${type}/${group}/${name}/${hardwares[i]}`;
44-
a.target = "_blank";
45-
td.appendChild(a);
42+
{
43+
const td = document.createElement("td");
44+
td.className = "comparison";
45+
const a = document.createElement("a");
46+
a.href = `/api/result/${type}/${group}/${name}/${hardwares[i]}`;
47+
a.target = "_blank";
48+
td.appendChild(a);
4649

47-
const img = document.createElement("img");
48-
img.src = `/api/result/${type}-thumbnail/${group}/${name}/${hardwares[i]}`;
49-
a.appendChild(img);
50+
const img = document.createElement("img");
51+
img.src = `/api/result/${type}-thumbnail/${group}/${name}/${hardwares[i]}`;
52+
a.appendChild(img);
5053

51-
const div = document.createElement("div");
52-
div.className = "info";
53-
div.appendChild(document.createTextNode(hardwares[i]));
54-
td.appendChild(div);
54+
const div = document.createElement("div");
55+
div.className = "info";
56+
div.appendChild(document.createTextNode(hardwares[i]));
57+
td.appendChild(div);
58+
tr.appendChild(td);
59+
}
5560

5661
// Third, add the comparison elements to the right of the diagonal
57-
for (const j = i + 1; j < hardwares.length; j++) {
62+
for (let j = i + 1; j < hardwares.length; j++) {
5863
const td = document.createElement("td");
5964
td.className = "comparison";
6065

@@ -63,7 +68,7 @@ async function generateComparison() {
6368
const compareUrl = `/api/compare/${type}/${group}/${name}/${hardwares[i]}/${hardwares[j]}`;
6469
const response = await fetch(compareUrl);
6570
console.assert(response.status === 200);
66-
const pixelError = response.headers.get("result");
71+
const pixelError = Number(response.headers.get("result"));
6772

6873
const a = document.createElement("a");
6974
a.href = compareUrl;

backend/public/functions.js

Lines changed: 34 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,23 @@ function createHeader(ul) {
140140

141141
function createRows(record, ul) {
142142
function createHead(divHead, divBody, record, data) {
143+
function createImageDiv(className, type, record) {
144+
const div = document.createElement("div");
145+
div.className = `cell ${className}`;
146+
147+
const a = document.createElement("a");
148+
a.href = `/api/result/${type}/${record.group}/${record.name}/${record.hardware}`;
149+
a.target = "_blank";
150+
div.appendChild(a);
151+
152+
const img = document.createElement("img");
153+
img.src = `/api/result/${type}-thumbnail/${record.group}/${record.name}/${record.hardware}`;
154+
img.className = "overview";
155+
img.loading = "lazy";
156+
a.appendChild(img);
157+
return div;
158+
}
159+
143160
divHead.className = "head";
144161
divHead.onclick = () => divBody.classList.toggle("hidden");
145162

@@ -185,61 +202,30 @@ function createRows(record, ul) {
185202
);
186203
divHead.appendChild(timestamp);
187204

188-
{
189-
const div = document.createElement("div");
190-
div.className = "cell candidate";
191-
192-
const a = document.createElement("a");
193-
a.href = `/api/result/candidate/${record.group}/${record.name}/${record.hardware}`;
194-
a.target = "_blank";
195-
div.appendChild(a);
196-
197-
const img = document.createElement("img");
198-
img.src = `/api/result/candidate-thumbnail/${record.group}/${record.name}/${record.hardware}`;
199-
img.className = "overview";
200-
img.loading = "lazy";
201-
a.appendChild(img);
202-
divHead.appendChild(div);
203-
}
204-
205-
{
206-
const div = document.createElement("div");
207-
div.className = "cell reference";
208-
209-
const a = document.createElement("a");
210-
a.href = `/api/result/reference/${record.group}/${record.name}/${record.hardware}`;
211-
a.target = "_blank";
212-
div.appendChild(a);
205+
divHead.appendChild(createImageDiv("candidate", "candidate", record));
206+
divHead.appendChild(createImageDiv("reference", "reference", record));
207+
divHead.appendChild(createImageDiv("difference", "difference", record));
213208

214-
const img = document.createElement("img");
215-
img.src = `/api/result/reference-thumbnail/${record.group}/${record.name}/${record.hardware}`;
216-
img.className = "overview";
217-
img.loading = "lazy";
218-
a.appendChild(img);
219-
divHead.appendChild(div);
220-
}
209+
return divHead;
210+
} // function createHead(divHead, divBody, record, data)
221211

222-
{
223-
const div = document.createElement("div");
224-
div.className = "cell difference";
212+
function createBody(divBody, record, testData) {
213+
function createImageTd(className, type, record, timestamp) {
214+
const td = document.createElement("td");
215+
td.className = className;
225216

226217
const a = document.createElement("a");
227-
a.href = `/api/result/difference/${record.group}/${record.name}/${record.hardware}`;
218+
a.href = `/api/result/${type}/${record.group}/${record.name}/${record.hardware}/${timestamp}`;
228219
a.target = "_blank";
229-
div.appendChild(a);
220+
td.appendChild(a);
230221

231222
const img = document.createElement("img");
232-
img.src = `/api/result/difference-thumbnail/${record.group}/${record.name}/${record.hardware}`;
233-
img.className = "overview";
223+
img.src = `/api/result/${type}-thumbnail/${record.group}/${record.name}/${record.hardware}/${timestamp}`;
234224
img.loading = "lazy";
235225
a.appendChild(img);
236-
divHead.appendChild(div);
226+
return td;
237227
}
238228

239-
return divHead;
240-
} // function createHead(divHead, divBody, record, data)
241-
242-
function createBody(divBody, record, testData) {
243229
divBody.className = "body hidden";
244230

245231
const table = document.createElement("table");
@@ -324,19 +310,7 @@ function createRows(record, ul) {
324310
trCandidate.appendChild(td);
325311
}
326312
for (const data of testData) {
327-
const td = document.createElement("td");
328-
td.className = "candidate";
329-
trCandidate.appendChild(td);
330-
331-
const a = document.createElement("a");
332-
a.href = `/api/result/candidate/${record.group}/${record.name}/${record.hardware}/${data.timeStamp}`;
333-
a.target = "_blank";
334-
td.appendChild(a);
335-
336-
const img = document.createElement("img");
337-
img.src = `/api/result/candidate-thumbnail/${record.group}/${record.name}/${record.hardware}/${data.timeStamp}`;
338-
img.loading = "lazy";
339-
a.appendChild(img);
313+
trCandidate.appendChild(createImageTd("candidate", "candidate", record, data.timeStamp));
340314
}
341315
table.appendChild(trCandidate);
342316

@@ -348,19 +322,7 @@ function createRows(record, ul) {
348322
trReference.appendChild(td);
349323
}
350324
for (const data of testData) {
351-
const td = document.createElement("td");
352-
td.className = "reference";
353-
trReference.appendChild(td);
354-
355-
const a = document.createElement("a");
356-
a.href = `/api/result/reference/${record.group}/${record.name}/${record.hardware}/${data.timeStamp}`;
357-
a.target = "_blank";
358-
td.appendChild(a);
359-
360-
const img = document.createElement("img");
361-
img.src = `/api/result/reference-thumbnail/${record.group}/${record.name}/${record.hardware}/${data.timeStamp}`;
362-
img.loading = "lazy";
363-
a.appendChild(img);
325+
trReference.appendChild(createImageTd("reference", "reference", record, data.timeStamp));
364326
}
365327
table.appendChild(trReference);
366328

@@ -372,19 +334,7 @@ function createRows(record, ul) {
372334
trDifference.appendChild(td);
373335
}
374336
for (const data of testData) {
375-
const td = document.createElement("td");
376-
td.className = "difference";
377-
trDifference.appendChild(td);
378-
379-
const a = document.createElement("a");
380-
a.href = `/api/result/difference/${record.group}/${record.name}/${record.hardware}/${data.timeStamp}`;
381-
a.target = "_blank";
382-
td.appendChild(a);
383-
384-
const img = document.createElement("img");
385-
img.src = `/api/result/difference-thumbnail/${record.group}/${record.name}/${record.hardware}/${data.timeStamp}`;
386-
img.loading = "lazy";
387-
a.appendChild(img);
337+
trDifference.appendChild(createImageTd("difference", "difference", record, data.timeStamp));
388338
}
389339
table.appendChild(trDifference);
390340

@@ -400,7 +350,7 @@ function createRows(record, ul) {
400350
trUpdate.appendChild(td);
401351
table.appendChild(trUpdate);
402352

403-
for (const i = 0; i < testData.length - 1; i++) {
353+
for (let i = 0; i < testData.length - 1; i++) {
404354
trUpdate.appendChild(document.createElement("td"));
405355
}
406356
}

0 commit comments

Comments
 (0)