@mailwoman/ogc 11.2.0 → 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +167 -28
- package/cli/geocoder.ts +50 -0
- package/cli/main.ts +303 -49
- package/lib/app.ts +9 -1
- package/lib/bbox.ts +69 -0
- package/lib/collections.ts +63 -9
- package/lib/engine.ts +72 -0
- package/lib/html.ts +64 -2
- package/lib/index.ts +4 -0
- package/lib/items.ts +169 -0
- package/lib/projection.ts +28 -8
- package/lib/provenance.ts +86 -0
- package/lib/refusal.ts +34 -0
- package/lib/routes.ts +326 -61
- package/lib/schema.ts +164 -3
- package/out/app.d.ts +8 -0
- package/out/app.d.ts.map +1 -1
- package/out/app.js +1 -1
- package/out/app.js.map +1 -1
- package/out/bbox.d.ts +23 -0
- package/out/bbox.d.ts.map +1 -0
- package/out/bbox.js +54 -0
- package/out/bbox.js.map +1 -0
- package/out/cli/geocoder.d.ts +24 -0
- package/out/cli/geocoder.d.ts.map +1 -0
- package/out/cli/geocoder.js +28 -0
- package/out/cli/geocoder.js.map +1 -0
- package/out/cli/main.js +225 -46
- package/out/cli/main.js.map +1 -1
- package/out/collections.d.ts +31 -4
- package/out/collections.d.ts.map +1 -1
- package/out/collections.js +32 -3
- package/out/collections.js.map +1 -1
- package/out/engine.d.ts +68 -0
- package/out/engine.d.ts.map +1 -1
- package/out/html.d.ts +11 -1
- package/out/html.d.ts.map +1 -1
- package/out/html.js +49 -2
- package/out/html.js.map +1 -1
- package/out/index.d.ts +4 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +4 -0
- package/out/index.js.map +1 -1
- package/out/items.d.ts +38 -0
- package/out/items.d.ts.map +1 -0
- package/out/items.js +136 -0
- package/out/items.js.map +1 -0
- package/out/projection.d.ts +15 -1
- package/out/projection.d.ts.map +1 -1
- package/out/projection.js +21 -8
- package/out/projection.js.map +1 -1
- package/out/provenance.d.ts +41 -0
- package/out/provenance.d.ts.map +1 -0
- package/out/provenance.js +60 -0
- package/out/provenance.js.map +1 -0
- package/out/refusal.d.ts +18 -0
- package/out/refusal.d.ts.map +1 -0
- package/out/refusal.js +30 -0
- package/out/refusal.js.map +1 -0
- package/out/routes.d.ts +24 -22
- package/out/routes.d.ts.map +1 -1
- package/out/routes.js +246 -51
- package/out/routes.js.map +1 -1
- package/out/schema.d.ts +157 -2
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js +140 -3
- package/out/schema.js.map +1 -1
- package/out/tools/ets.run.d.ts +2 -0
- package/out/tools/ets.run.d.ts.map +1 -0
- package/out/tools/ets.run.js +187 -0
- package/out/tools/ets.run.js.map +1 -0
- package/package.json +32 -10
- package/tools/ets.run.ts +258 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
/**
|
|
4
|
+
* Runs the OGC API Features Part 1 executable test suite, `ets-ogcapi-features10`,
|
|
5
|
+
* against `mailwoman-ogc serve` on this machine and prints the result.
|
|
6
|
+
*
|
|
7
|
+
* Without `--iut` the tool starts the server on 127.0.0.1 with the data root's gazetteer
|
|
8
|
+
* and `--serve-items`, because the suite needs a feature collection to test.
|
|
9
|
+
* It runs the suite and stops the server it started by its own process.
|
|
10
|
+
*
|
|
11
|
+
* With `--iut` it tests that URL instead and leaves the server to the caller.
|
|
12
|
+
*
|
|
13
|
+
* The suite runs from OGC's published container image under Podman.
|
|
14
|
+
* The container shares the host's network as a client and opens no port,
|
|
15
|
+
* so the server stays bound to 127.0.0.1.
|
|
16
|
+
*
|
|
17
|
+
* The suite writes its TestNG and EARL reports under `--out`, and the tool prints
|
|
18
|
+
* the counts and every failed or skipped test with its message.
|
|
19
|
+
* It exits 1 when a test failed.
|
|
20
|
+
*
|
|
21
|
+
* Run from the repository root:
|
|
22
|
+
*
|
|
23
|
+
* ```sh
|
|
24
|
+
* node packages/ogc/tools/ets.run.ts [--port 8195] [--out <dir>] [--iut <url>] [--image <ref>]
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import { dataRootPath } from "@mailwoman/core/data-root";
|
|
28
|
+
import { readLocalTextFile, sortedGlob } from "@mailwoman/core/fs/readers";
|
|
29
|
+
import { statPath } from "@mailwoman/core/fs/readers/stat";
|
|
30
|
+
import { makeDirectories, writeLocalJSONFile, writeLocalTextFile } from "@mailwoman/core/fs/writers";
|
|
31
|
+
import { fileURLToPath } from "@mailwoman/core/module/file-url";
|
|
32
|
+
import { parseArguments } from "@mailwoman/core/scripting/arguments";
|
|
33
|
+
import { ProcessTask, runProcess } from "@mailwoman/core/scripting/process";
|
|
34
|
+
import { isoSeconds } from "@mailwoman/core/utils";
|
|
35
|
+
import { sleep } from "@mailwoman/core/utils/sleep";
|
|
36
|
+
import { PathBuilder } from "path-ts";
|
|
37
|
+
/**
|
|
38
|
+
* The published image of suite revision 1.9, the newest release.
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_IMAGE = "docker.io/ogccite/ets-ogcapi-features10:1.9-teamengine-6.0.0-RC2";
|
|
41
|
+
/**
|
|
42
|
+
* The image's TEAM Engine web application holds the suite and its dependencies,
|
|
43
|
+
* and Tomcat's library directory holds the JAX-RS client the suite loads.
|
|
44
|
+
* The suite runs from both without Tomcat.
|
|
45
|
+
*/
|
|
46
|
+
const SUITE_CLASSPATH = "/usr/local/tomcat/webapps/teamengine/WEB-INF/lib/*:/usr/local/tomcat/lib/*";
|
|
47
|
+
const SUITE_MAIN = "org.opengis.cite.ogcapifeatures10.TestNGController";
|
|
48
|
+
/**
|
|
49
|
+
* How long the server may take to load the classifier and gazetteer before the tool gives up.
|
|
50
|
+
*/
|
|
51
|
+
const SERVER_READY_TIMEOUT_MS = 300_000;
|
|
52
|
+
/**
|
|
53
|
+
* The interval between the tool's requests to the starting server.
|
|
54
|
+
*/
|
|
55
|
+
const SERVER_POLL_INTERVAL_MS = 1000;
|
|
56
|
+
const { values } = parseArguments({
|
|
57
|
+
options: {
|
|
58
|
+
port: { type: "string", default: "8195" },
|
|
59
|
+
out: { type: "string" },
|
|
60
|
+
iut: { type: "string" },
|
|
61
|
+
image: { type: "string", default: DEFAULT_IMAGE },
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const out = PathBuilder.from(values.out ?? dataRootPath("audits", "ogc-ets", isoSeconds().replaceAll(":", "")).toString());
|
|
65
|
+
await makeDirectories(out);
|
|
66
|
+
async function waitForServer(url, server) {
|
|
67
|
+
const deadline = Date.now() + SERVER_READY_TIMEOUT_MS;
|
|
68
|
+
const state = { exited: false };
|
|
69
|
+
void server.result.finally(() => {
|
|
70
|
+
state.exited = true;
|
|
71
|
+
});
|
|
72
|
+
while (Date.now() < deadline) {
|
|
73
|
+
if (state.exited)
|
|
74
|
+
throw new Error(`the server exited before answering ${url}`);
|
|
75
|
+
try {
|
|
76
|
+
if ((await fetch(url)).ok)
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// The server isn't listening yet.
|
|
81
|
+
}
|
|
82
|
+
await sleep(SERVER_POLL_INTERVAL_MS);
|
|
83
|
+
}
|
|
84
|
+
throw new Error(`no answer from ${url} within ${SERVER_READY_TIMEOUT_MS} ms`);
|
|
85
|
+
}
|
|
86
|
+
function attribute(attributes, name) {
|
|
87
|
+
return new RegExp(`\\b${name}="([^"]*)"`).exec(attributes)?.[1] ?? "";
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Read the counts and the failed and skipped tests from a `testng-results.xml`.
|
|
91
|
+
*/
|
|
92
|
+
function summarizeReport(xml) {
|
|
93
|
+
const header = /<testng-results([^>]*)>/.exec(xml)?.[1];
|
|
94
|
+
if (header == null)
|
|
95
|
+
throw new Error("the report has no <testng-results> element");
|
|
96
|
+
const tests = [];
|
|
97
|
+
for (const match of xml.matchAll(/<test-method([^>]*)>([\s\S]*?)<\/test-method>/g)) {
|
|
98
|
+
const attributes = match[1];
|
|
99
|
+
const status = attribute(attributes, "status");
|
|
100
|
+
if (status !== "FAIL" && status !== "SKIP")
|
|
101
|
+
continue;
|
|
102
|
+
const body = match[2];
|
|
103
|
+
tests.push({
|
|
104
|
+
status,
|
|
105
|
+
name: attribute(attributes, "name"),
|
|
106
|
+
description: attribute(attributes, "description"),
|
|
107
|
+
parameters: [...body.matchAll(/<value[^>]*>\s*<!\[CDATA\[([\s\S]*?)\]\]>/g)].map((value) => value[1].trim()),
|
|
108
|
+
message: /<message>\s*<!\[CDATA\[([\s\S]*?)\]\]>/.exec(body)?.[1]?.trim() ?? "",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
total: Number(attribute(header, "total")),
|
|
113
|
+
passed: Number(attribute(header, "passed")),
|
|
114
|
+
failed: Number(attribute(header, "failed")),
|
|
115
|
+
skipped: Number(attribute(header, "skipped")),
|
|
116
|
+
tests,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
async function runSuite(iut) {
|
|
120
|
+
await writeLocalTextFile(`<?xml version="1.0" encoding="UTF-8"?>
|
|
121
|
+
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
|
122
|
+
<properties version="1.0">
|
|
123
|
+
<entry key="iut">${iut}</entry>
|
|
124
|
+
</properties>
|
|
125
|
+
`, out("test-run-props.xml"));
|
|
126
|
+
const suite = await runProcess("podman", [
|
|
127
|
+
"run",
|
|
128
|
+
"--rm",
|
|
129
|
+
"--network=host",
|
|
130
|
+
"-v",
|
|
131
|
+
`${out}:/run:Z`,
|
|
132
|
+
"--entrypoint",
|
|
133
|
+
"java",
|
|
134
|
+
values.image,
|
|
135
|
+
"-cp",
|
|
136
|
+
SUITE_CLASSPATH,
|
|
137
|
+
SUITE_MAIN,
|
|
138
|
+
"-o",
|
|
139
|
+
"/run",
|
|
140
|
+
"-h",
|
|
141
|
+
"true",
|
|
142
|
+
"/run/test-run-props.xml",
|
|
143
|
+
], { reject: false });
|
|
144
|
+
await writeLocalTextFile(`${suite.stdout}${suite.stderr}\nEXIT=${suite.exitCode}\n`, out("ets.log"));
|
|
145
|
+
if (suite.exitCode !== 0)
|
|
146
|
+
throw new Error(`the suite exited ${suite.exitCode}; see ${out("ets.log")}`);
|
|
147
|
+
const reports = await Promise.all((await sortedGlob(out, "testng/*/testng-results.xml")).map(async (path) => ({
|
|
148
|
+
path,
|
|
149
|
+
modified: (await statPath(path)).mtimeMs,
|
|
150
|
+
})));
|
|
151
|
+
const newest = reports.toSorted((a, b) => b.modified - a.modified)[0]?.path;
|
|
152
|
+
if (!newest)
|
|
153
|
+
throw new Error(`the suite wrote no testng-results.xml under ${out("testng")}`);
|
|
154
|
+
return { iut, image: values.image, report: newest, ...summarizeReport(await readLocalTextFile(newest)) };
|
|
155
|
+
}
|
|
156
|
+
let summary;
|
|
157
|
+
if (values.iut) {
|
|
158
|
+
summary = await runSuite(values.iut);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const iut = `http://127.0.0.1:${values.port}/`;
|
|
162
|
+
await using server = new ProcessTask(process.execPath, [
|
|
163
|
+
fileURLToPath(import.meta.resolve("#cli/main")),
|
|
164
|
+
"serve",
|
|
165
|
+
"--host",
|
|
166
|
+
"127.0.0.1",
|
|
167
|
+
"--port",
|
|
168
|
+
values.port,
|
|
169
|
+
"--serve-items",
|
|
170
|
+
], { stdout: "ignore", stderr: "inherit", reject: false });
|
|
171
|
+
await waitForServer(`${iut}conformance`, server);
|
|
172
|
+
summary = await runSuite(iut);
|
|
173
|
+
}
|
|
174
|
+
await writeLocalJSONFile(summary, out("summary.json"));
|
|
175
|
+
console.log(`ets-ogcapi-features10 (${summary.image}) against ${summary.iut}`);
|
|
176
|
+
console.log(`total ${summary.total}, passed ${summary.passed}, failed ${summary.failed}, skipped ${summary.skipped}`);
|
|
177
|
+
console.log(`report: ${summary.report}`);
|
|
178
|
+
for (const test of summary.tests) {
|
|
179
|
+
const parameters = test.parameters.length
|
|
180
|
+
? ` [${test.parameters.map((value) => value.slice(0, 80)).join(" | ")}]`
|
|
181
|
+
: "";
|
|
182
|
+
console.log(`\n${test.status} ${test.name}${parameters}\n ${test.description}\n ${test.message.slice(0, 500)}`);
|
|
183
|
+
}
|
|
184
|
+
if (summary.failed > 0) {
|
|
185
|
+
process.exitCode = 1;
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=ets.run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ets.run.js","sourceRoot":"","sources":["../../tools/ets.run.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC;;GAEG;AACH,MAAM,aAAa,GAAG,kEAAkE,CAAA;AAExF;;;;GAIG;AACH,MAAM,eAAe,GAAG,4EAA4E,CAAA;AAEpG,MAAM,UAAU,GAAG,oDAAoD,CAAA;AAEvE;;GAEG;AACH,MAAM,uBAAuB,GAAG,OAAO,CAAA;AAEvC;;GAEG;AACH,MAAM,uBAA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,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/ogc",
|
|
3
|
-
"version": "11.
|
|
4
|
-
"description": "OGC API adapter for the Mailwoman engine. Serves the OGC API Common landing page, conformance declaration, API definition and collections, and forward geocoding at /search in the form of PDOK's Location API. Run it with `npx @mailwoman/ogc serve`.",
|
|
3
|
+
"version": "11.3.0",
|
|
4
|
+
"description": "OGC API adapter for the Mailwoman engine. Serves the OGC API Common landing page, conformance declaration, API definition and collections, gazetteer places as OGC API Features items, and forward geocoding at /search in the form of PDOK's Location API. Run it with `npx @mailwoman/ogc serve`.",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"lib/**/*.ts",
|
|
19
19
|
"lib/**/*.tsx",
|
|
20
20
|
"cli/**/*.ts",
|
|
21
|
+
"tools/**/*.ts",
|
|
21
22
|
"!**/*.test.ts",
|
|
22
23
|
"!**/*.test.tsx"
|
|
23
24
|
],
|
|
@@ -28,6 +29,11 @@
|
|
|
28
29
|
"node": "./out/cli/*.js",
|
|
29
30
|
"default": "./out/cli/*.js"
|
|
30
31
|
},
|
|
32
|
+
"#tools/*": {
|
|
33
|
+
"types": "./out/tools/*.d.ts",
|
|
34
|
+
"node": "./out/tools/*.js",
|
|
35
|
+
"default": "./out/tools/*.js"
|
|
36
|
+
},
|
|
31
37
|
"#*": {
|
|
32
38
|
"types": "./out/*.d.ts",
|
|
33
39
|
"node": "./out/*.js",
|
|
@@ -41,6 +47,11 @@
|
|
|
41
47
|
"node": "./out/index.js",
|
|
42
48
|
"default": "./out/index.js"
|
|
43
49
|
},
|
|
50
|
+
"./tools/*": {
|
|
51
|
+
"types": "./out/tools/*.d.ts",
|
|
52
|
+
"node": "./out/tools/*.js",
|
|
53
|
+
"default": "./out/tools/*.js"
|
|
54
|
+
},
|
|
44
55
|
"./cli/*": {
|
|
45
56
|
"types": "./out/cli/*.d.ts",
|
|
46
57
|
"node": "./out/cli/*.js",
|
|
@@ -61,6 +72,11 @@
|
|
|
61
72
|
"node": "./out/index.js",
|
|
62
73
|
"default": "./out/index.js"
|
|
63
74
|
},
|
|
75
|
+
"./tools/*": {
|
|
76
|
+
"types": "./out/tools/*.d.ts",
|
|
77
|
+
"node": "./out/tools/*.js",
|
|
78
|
+
"default": "./out/tools/*.js"
|
|
79
|
+
},
|
|
64
80
|
"./cli/*": {
|
|
65
81
|
"types": "./out/cli/*.d.ts",
|
|
66
82
|
"node": "./out/cli/*.js",
|
|
@@ -78,6 +94,11 @@
|
|
|
78
94
|
"node": "./out/cli/*.js",
|
|
79
95
|
"default": "./out/cli/*.js"
|
|
80
96
|
},
|
|
97
|
+
"#tools/*": {
|
|
98
|
+
"types": "./out/tools/*.d.ts",
|
|
99
|
+
"node": "./out/tools/*.js",
|
|
100
|
+
"default": "./out/tools/*.js"
|
|
101
|
+
},
|
|
81
102
|
"#*": {
|
|
82
103
|
"types": "./out/*.d.ts",
|
|
83
104
|
"node": "./out/*.js",
|
|
@@ -87,15 +108,16 @@
|
|
|
87
108
|
},
|
|
88
109
|
"dependencies": {
|
|
89
110
|
"@hono/zod-openapi": "^1.6.3",
|
|
90
|
-
"@mailwoman/api": "11.
|
|
91
|
-
"@mailwoman/api-kit": "11.
|
|
92
|
-
"@mailwoman/codex": "11.
|
|
93
|
-
"@mailwoman/core": "11.
|
|
94
|
-
"@mailwoman/
|
|
95
|
-
"@mailwoman/resolver-wof-sqlite": "11.
|
|
96
|
-
"@mailwoman/spatial": "11.
|
|
111
|
+
"@mailwoman/api": "11.3.0",
|
|
112
|
+
"@mailwoman/api-kit": "11.3.0",
|
|
113
|
+
"@mailwoman/codex": "11.3.0",
|
|
114
|
+
"@mailwoman/core": "11.3.0",
|
|
115
|
+
"@mailwoman/license": "11.3.0",
|
|
116
|
+
"@mailwoman/resolver-wof-sqlite": "11.3.0",
|
|
117
|
+
"@mailwoman/spatial": "11.3.0",
|
|
97
118
|
"hono": "^4.13.14",
|
|
98
|
-
"mailwoman": "11.
|
|
119
|
+
"mailwoman": "11.3.0",
|
|
120
|
+
"path-ts": "^2.5.0",
|
|
99
121
|
"zod": "^4.6.7"
|
|
100
122
|
}
|
|
101
123
|
}
|
package/tools/ets.run.ts
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runs the OGC API Features Part 1 executable test suite, `ets-ogcapi-features10`,
|
|
6
|
+
* against `mailwoman-ogc serve` on this machine and prints the result.
|
|
7
|
+
*
|
|
8
|
+
* Without `--iut` the tool starts the server on 127.0.0.1 with the data root's gazetteer
|
|
9
|
+
* and `--serve-items`, because the suite needs a feature collection to test.
|
|
10
|
+
* It runs the suite and stops the server it started by its own process.
|
|
11
|
+
*
|
|
12
|
+
* With `--iut` it tests that URL instead and leaves the server to the caller.
|
|
13
|
+
*
|
|
14
|
+
* The suite runs from OGC's published container image under Podman.
|
|
15
|
+
* The container shares the host's network as a client and opens no port,
|
|
16
|
+
* so the server stays bound to 127.0.0.1.
|
|
17
|
+
*
|
|
18
|
+
* The suite writes its TestNG and EARL reports under `--out`, and the tool prints
|
|
19
|
+
* the counts and every failed or skipped test with its message.
|
|
20
|
+
* It exits 1 when a test failed.
|
|
21
|
+
*
|
|
22
|
+
* Run from the repository root:
|
|
23
|
+
*
|
|
24
|
+
* ```sh
|
|
25
|
+
* node packages/ogc/tools/ets.run.ts [--port 8195] [--out <dir>] [--iut <url>] [--image <ref>]
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { dataRootPath } from "@mailwoman/core/data-root"
|
|
30
|
+
import { readLocalTextFile, sortedGlob } from "@mailwoman/core/fs/readers"
|
|
31
|
+
import { statPath } from "@mailwoman/core/fs/readers/stat"
|
|
32
|
+
import { makeDirectories, writeLocalJSONFile, writeLocalTextFile } from "@mailwoman/core/fs/writers"
|
|
33
|
+
import { fileURLToPath } from "@mailwoman/core/module/file-url"
|
|
34
|
+
import { parseArguments } from "@mailwoman/core/scripting/arguments"
|
|
35
|
+
import { ProcessTask, runProcess } from "@mailwoman/core/scripting/process"
|
|
36
|
+
import { isoSeconds } from "@mailwoman/core/utils"
|
|
37
|
+
import { sleep } from "@mailwoman/core/utils/sleep"
|
|
38
|
+
import { PathBuilder } from "path-ts"
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The published image of suite revision 1.9, the newest release.
|
|
42
|
+
*/
|
|
43
|
+
const DEFAULT_IMAGE = "docker.io/ogccite/ets-ogcapi-features10:1.9-teamengine-6.0.0-RC2"
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The image's TEAM Engine web application holds the suite and its dependencies,
|
|
47
|
+
* and Tomcat's library directory holds the JAX-RS client the suite loads.
|
|
48
|
+
* The suite runs from both without Tomcat.
|
|
49
|
+
*/
|
|
50
|
+
const SUITE_CLASSPATH = "/usr/local/tomcat/webapps/teamengine/WEB-INF/lib/*:/usr/local/tomcat/lib/*"
|
|
51
|
+
|
|
52
|
+
const SUITE_MAIN = "org.opengis.cite.ogcapifeatures10.TestNGController"
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* How long the server may take to load the classifier and gazetteer before the tool gives up.
|
|
56
|
+
*/
|
|
57
|
+
const SERVER_READY_TIMEOUT_MS = 300_000
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The interval between the tool's requests to the starting server.
|
|
61
|
+
*/
|
|
62
|
+
const SERVER_POLL_INTERVAL_MS = 1000
|
|
63
|
+
|
|
64
|
+
const { values } = parseArguments({
|
|
65
|
+
options: {
|
|
66
|
+
port: { type: "string", default: "8195" },
|
|
67
|
+
out: { type: "string" },
|
|
68
|
+
iut: { type: "string" },
|
|
69
|
+
image: { type: "string", default: DEFAULT_IMAGE },
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const out = PathBuilder.from(
|
|
74
|
+
values.out ?? dataRootPath("audits", "ogc-ets", isoSeconds().replaceAll(":", "")).toString()
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
await makeDirectories(out)
|
|
78
|
+
|
|
79
|
+
async function waitForServer(url: string, server: ProcessTask): Promise<void> {
|
|
80
|
+
const deadline = Date.now() + SERVER_READY_TIMEOUT_MS
|
|
81
|
+
const state = { exited: false }
|
|
82
|
+
|
|
83
|
+
void server.result.finally(() => {
|
|
84
|
+
state.exited = true
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
while (Date.now() < deadline) {
|
|
88
|
+
if (state.exited) throw new Error(`the server exited before answering ${url}`)
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
if ((await fetch(url)).ok) return
|
|
92
|
+
} catch {
|
|
93
|
+
// The server isn't listening yet.
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
await sleep(SERVER_POLL_INTERVAL_MS)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
throw new Error(`no answer from ${url} within ${SERVER_READY_TIMEOUT_MS} ms`)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* One failed or skipped test from the TestNG report.
|
|
104
|
+
*/
|
|
105
|
+
interface ReportedTest {
|
|
106
|
+
status: "FAIL" | "SKIP"
|
|
107
|
+
name: string
|
|
108
|
+
description: string
|
|
109
|
+
parameters: string[]
|
|
110
|
+
message: string
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface SuiteSummary {
|
|
114
|
+
iut: string
|
|
115
|
+
image: string
|
|
116
|
+
report: string
|
|
117
|
+
total: number
|
|
118
|
+
passed: number
|
|
119
|
+
failed: number
|
|
120
|
+
skipped: number
|
|
121
|
+
tests: ReportedTest[]
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function attribute(attributes: string, name: string): string {
|
|
125
|
+
return new RegExp(`\\b${name}="([^"]*)"`).exec(attributes)?.[1] ?? ""
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Read the counts and the failed and skipped tests from a `testng-results.xml`.
|
|
130
|
+
*/
|
|
131
|
+
function summarizeReport(xml: string): Omit<SuiteSummary, "iut" | "image" | "report"> {
|
|
132
|
+
const header = /<testng-results([^>]*)>/.exec(xml)?.[1]
|
|
133
|
+
|
|
134
|
+
if (header == null) throw new Error("the report has no <testng-results> element")
|
|
135
|
+
|
|
136
|
+
const tests: ReportedTest[] = []
|
|
137
|
+
|
|
138
|
+
for (const match of xml.matchAll(/<test-method([^>]*)>([\s\S]*?)<\/test-method>/g)) {
|
|
139
|
+
const attributes = match[1]!
|
|
140
|
+
const status = attribute(attributes, "status")
|
|
141
|
+
|
|
142
|
+
if (status !== "FAIL" && status !== "SKIP") continue
|
|
143
|
+
|
|
144
|
+
const body = match[2]!
|
|
145
|
+
|
|
146
|
+
tests.push({
|
|
147
|
+
status,
|
|
148
|
+
name: attribute(attributes, "name"),
|
|
149
|
+
description: attribute(attributes, "description"),
|
|
150
|
+
parameters: [...body.matchAll(/<value[^>]*>\s*<!\[CDATA\[([\s\S]*?)\]\]>/g)].map((value) => value[1]!.trim()),
|
|
151
|
+
message: /<message>\s*<!\[CDATA\[([\s\S]*?)\]\]>/.exec(body)?.[1]?.trim() ?? "",
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
total: Number(attribute(header, "total")),
|
|
157
|
+
passed: Number(attribute(header, "passed")),
|
|
158
|
+
failed: Number(attribute(header, "failed")),
|
|
159
|
+
skipped: Number(attribute(header, "skipped")),
|
|
160
|
+
tests,
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function runSuite(iut: string): Promise<SuiteSummary> {
|
|
165
|
+
await writeLocalTextFile(
|
|
166
|
+
`<?xml version="1.0" encoding="UTF-8"?>
|
|
167
|
+
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
|
168
|
+
<properties version="1.0">
|
|
169
|
+
<entry key="iut">${iut}</entry>
|
|
170
|
+
</properties>
|
|
171
|
+
`,
|
|
172
|
+
out("test-run-props.xml")
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
const suite = await runProcess(
|
|
176
|
+
"podman",
|
|
177
|
+
[
|
|
178
|
+
"run",
|
|
179
|
+
"--rm",
|
|
180
|
+
"--network=host",
|
|
181
|
+
"-v",
|
|
182
|
+
`${out}:/run:Z`,
|
|
183
|
+
"--entrypoint",
|
|
184
|
+
"java",
|
|
185
|
+
values.image,
|
|
186
|
+
"-cp",
|
|
187
|
+
SUITE_CLASSPATH,
|
|
188
|
+
SUITE_MAIN,
|
|
189
|
+
"-o",
|
|
190
|
+
"/run",
|
|
191
|
+
"-h",
|
|
192
|
+
"true",
|
|
193
|
+
"/run/test-run-props.xml",
|
|
194
|
+
],
|
|
195
|
+
{ reject: false }
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
await writeLocalTextFile(`${suite.stdout}${suite.stderr}\nEXIT=${suite.exitCode}\n`, out("ets.log"))
|
|
199
|
+
|
|
200
|
+
if (suite.exitCode !== 0) throw new Error(`the suite exited ${suite.exitCode}; see ${out("ets.log")}`)
|
|
201
|
+
|
|
202
|
+
const reports = await Promise.all(
|
|
203
|
+
(await sortedGlob(out, "testng/*/testng-results.xml")).map(async (path) => ({
|
|
204
|
+
path,
|
|
205
|
+
modified: (await statPath(path)).mtimeMs,
|
|
206
|
+
}))
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
const newest = reports.toSorted((a, b) => b.modified - a.modified)[0]?.path
|
|
210
|
+
|
|
211
|
+
if (!newest) throw new Error(`the suite wrote no testng-results.xml under ${out("testng")}`)
|
|
212
|
+
|
|
213
|
+
return { iut, image: values.image, report: newest, ...summarizeReport(await readLocalTextFile(newest)) }
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let summary: SuiteSummary
|
|
217
|
+
|
|
218
|
+
if (values.iut) {
|
|
219
|
+
summary = await runSuite(values.iut)
|
|
220
|
+
} else {
|
|
221
|
+
const iut = `http://127.0.0.1:${values.port}/`
|
|
222
|
+
|
|
223
|
+
await using server = new ProcessTask(
|
|
224
|
+
process.execPath,
|
|
225
|
+
[
|
|
226
|
+
fileURLToPath(import.meta.resolve("#cli/main")),
|
|
227
|
+
"serve",
|
|
228
|
+
"--host",
|
|
229
|
+
"127.0.0.1",
|
|
230
|
+
"--port",
|
|
231
|
+
values.port,
|
|
232
|
+
"--serve-items",
|
|
233
|
+
],
|
|
234
|
+
{ stdout: "ignore", stderr: "inherit", reject: false }
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
await waitForServer(`${iut}conformance`, server)
|
|
238
|
+
|
|
239
|
+
summary = await runSuite(iut)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
await writeLocalJSONFile(summary, out("summary.json"))
|
|
243
|
+
|
|
244
|
+
console.log(`ets-ogcapi-features10 (${summary.image}) against ${summary.iut}`)
|
|
245
|
+
console.log(`total ${summary.total}, passed ${summary.passed}, failed ${summary.failed}, skipped ${summary.skipped}`)
|
|
246
|
+
console.log(`report: ${summary.report}`)
|
|
247
|
+
|
|
248
|
+
for (const test of summary.tests) {
|
|
249
|
+
const parameters = test.parameters.length
|
|
250
|
+
? ` [${test.parameters.map((value) => value.slice(0, 80)).join(" | ")}]`
|
|
251
|
+
: ""
|
|
252
|
+
|
|
253
|
+
console.log(`\n${test.status} ${test.name}${parameters}\n ${test.description}\n ${test.message.slice(0, 500)}`)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (summary.failed > 0) {
|
|
257
|
+
process.exitCode = 1
|
|
258
|
+
}
|