Skip to content

Revive the original test suites and run them in CI - #258

Open
cldellow wants to merge 9 commits into
masterfrom
revive-test-suites
Open

cldellow wants to merge 9 commits into
masterfrom
revive-test-suites

Conversation

@cldellow

@cldellow cldellow commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Fixes #257.

Based on upstream/master. This PR is mainly to check that CI runs the suites on pull requests.

Change

Nine commits, meant to be reviewed one at a time:

  1. test-bin: restore the unit test sources adds the 34 C++ files that src/test-bin/Makefile.am builds. They're copied unchanged from drolbr/Overpass-API at 87bfad18, the tip of its minor_issues branch and the source of the v0.7.62.11 release. Every blob hash matches.

  2. test suites: fix stale expected outputs and skip timing-dependent tests makes every suite pass at size 40, with no workflow changes:

    • fixes osm-3s_testing/turn_testing_on.sh, which left testing off;
    • updates the expected outputs that predate a new runtime remark line, an older log format, or osm3s_query's current behaviour;
    • normalises the machine-dependent elapsed time (After 0h0m2s:) and Stack: progress in limit messages;
    • skips the 6 osm3s_query timeout tests whose queries take under 10 seconds.

    The commit message lists each change.

  3. CI: run the test suites extends the existing job in ci.yml rather than adding a workflow. Her steps stay; it adds:

    • a step that turns test-bin on;
    • --prefix="$GITHUB_WORKSPACE" and CXXFLAGS="-g -O2 -D_GLIBCXX_ASSERTIONS" to configure. With the prefix, make install puts bin/, cgi-bin/ and test-bin/ where the scripts expect them. With assertions, out-of-bounds indexing into a std::string or std::vector aborts instead of passing unnoticed;
    • make -j"$(nproc)" install;
    • a step that runs run_testsuite.sh 40. It fails if any test reports FAILED or a difference, or if the suites didn't run at all; the scripts always exit 0, so it checks their output.
  4. test suites: add a suite for regression tests adds run_testsuite_regressions.sh, which passes shellcheck. Each test is one directory with:

    • its query;
    • optional data, imported into a database of the test's own;
    • an optional CGI environment.

    A future fix can add its test without changing a script. Each test runs for at most 60 seconds and writes at most 10 MB per file, so a test of a hang fails rather than blocks the suite.

  5. Commits 5 to 9 add one regression test each, for the fixes since v0.7.62.11:

Test Covers With the fix reverted
regression_ql_nesting_limit: node(1); inside 1024 levels of parentheses 04c045b9, parser nesting limit the parser loops, writing parse errors without end
regression_user_touched_relations: rel(1); nwr._(uid_touched:999999999); out count; and, as a control, the same with uid_touched:1 4a9c1b59, user filter on relations the first query counts 1 relation instead of 0
regression_cgi_custom_url_line_break: GET data=[out:custom];node(1);out; with url=http://example.com/%0d%0aX-Injected:%201 8edf11b0, CGI fixes a 302 redirect with an extra X-Injected: 1 header line instead of 400 Bad Request
regression_cgi_bbox_not_numeric: GET data=node(bbox);out; with bbox=7,51,8);node(id:1,52 8edf11b0, CGI fixes the query becomes node(51,7,52,8);node(id:1);out; and returns node 1, instead of failing to parse
regression_cgi_truncated_percent: GET data=node(1);out;% 8edf11b0, CGI fixes replace_cgi reads one past the end of the string. That's only visible with -D_GLIBCXX_ASSERTIONS, as in CI, where it aborts.

Impact on the benchmark queries

None. The PR changes no code that the server or the query tools run. It adds test programs (built only when testing is turned on), test scripts, test data and CI steps.

Testing

  • Locally, run_testsuite.sh 40 reports 781 tests succeeding, and no failures or differences. The attic, vlt and implicit areas suites only report differences, and report none.
  • CI passes on this PR with 781 tests succeeding. It needs no extra packages on the runner.
  • For each fix, I rebuilt with only that fix reverted (git revert -n 04c045b9, git revert -n 4a9c1b59, git revert -n -m 1 8edf11b0), with -D_GLIBCXX_ASSERTIONS. Exactly the tests in the table failed, and with nothing reverted all passed.
  • Commit 1: the blob hashes of all 34 files equal those at 87bfad18.

Limitations and open questions

  • The suites must run at size 40: the osm3s_query and run_and_compare.sh expected outputs are fixed files made at that size.
  • Six timeout tests are skipped: 19, 28, 31, 34, 66 and 67. Without the limit, their queries take 1.3 to 5.9 seconds at size 40, against a limit that fires at 2 seconds, so the result depends on the machine. The other nine timeout tests run queries that take 12 seconds to over two minutes, and they still run.
  • osm3s_query test 22 had to change. After a foreach, _ is now empty, as the statements unit test foreach 2 expects. The test's input now writes the loop and its query to their own sets, so its original expected output still holds.
  • Not covered by regression tests:
    • the parts of 8edf11b0 that leave the output unchanged even with assertions: reading the POST body in chunks, the scope of the = search, and the operates_* checks in pt_diagrams;
    • the cgi-bin shell script fixes in 284d0d18;
    • 48d5aa5e and d4510489, which change only performance.
  • The CI job now takes about 9 to 12 minutes: 6 to 9 to build, including the test programs, and 2 to 3 to run the suites.
  • osm3s_query ignores SIGTERM while running osm3s_query tests 63 and 64 without their timeout (a nested print loop). It should go in an issue of its own.

🤖 Generated with Claude Code

https://claude.ai/code/session_01736kJTiuJPoCWZs7RtFYjm

The release tarballs this repository was imported from leave out the C++
sources of the test programs that src/test-bin/Makefile.am builds; the
test scripts and their inputs and expected outputs (src/test-bin,
osm-3s_testing) are already here.

These 34 files are copied unchanged from drolbr/Overpass-API at
87bfad1 (branch minor_issues), the commit that
src/overpass_api/core/settings.cc names as this code's source_hash. They
are every file that src/test-bin/Makefile.am references and that is
missing here, apart from four that drolbr's repository doesn't have
either.

Co-Authored-By: Colin Dellow <cldellow@gmail.com>
@cldellow
cldellow force-pushed the revive-test-suites branch 4 times, most recently from bdca871 to 2f9513d Compare November 27, 2026 04:17
claude and others added 8 commits November 27, 2026 04:19
The suites expect a build installed with the repository root as prefix,
so that bin/, cgi-bin/ and test-bin/ sit next to src/ (the top-level
.gitignore already lists them), and are run from osm-3s_testing:

  cd osm-3s_testing && ./turn_testing_on.sh
  cd ../src && autoreconf -i && ./configure --prefix="$(cd .. && pwd)"
  make install
  cd ../osm-3s_testing && ../test-bin/run_testsuite.sh 40

With the changes below, every suite passes at size 40: 776 tests
report success, and the attic, vlt and implicit areas suites, which
report only differences, report none. Size 40 is
needed: the expected outputs of osm3s_query and run_and_compare.sh are
fixed files made at that size, while the other suites generate theirs
for any size.

- turn_testing_on.sh: use Makefile.test.am and configure.test.ac only if
  they exist. When they don't, `diff -q` prints nothing to stdout, so the
  script tried to move the missing file and left testing off.
- osm3s_query: osm3s_query now writes "runtime remark: Timeout is N and
  maxsize is M." to stderr. Add it to the expected stderr of the tests
  from 20 on that still run.
- osm3s_query 22: after a foreach, `_` is empty, as the statements unit
  test foreach 2 expects, but the expected output prints the input set.
  Write the foreach and the query in it to their own sets, so that `_`
  keeps the input set and the expected output still holds.
- osm3s_query: when a query hits its timeout or element limit, the
  progress message starts with the elapsed time ("After 0h0m2s: ") and
  ends with where the query stood (" Stack: ..."). Both depend on the
  machine and on timing: a query that hits its element limit at once
  reports 0h0m1s if it starts just before a second boundary. Replace the
  elapsed time with "After: " and strip the stack, here and in the
  expected outputs.
- osm3s_query: skip tests 19, 28, 31, 34, 66 and 67. They expect a query
  to hit, or not hit, a one-second timeout, but without the timeout their
  queries take only 1.3 to 5.9 seconds, so the result depends on the
  machine: on two machines 19 always finished, 31 always timed out, and
  28, 34 and 67 varied. The other nine timeout tests run queries that
  take 12 seconds to over two minutes and still run. The skipped tests'
  input and expected files are unchanged.
- run_and_compare.sh 1 to 3 (osm_backend): the expected outputs were made
  at size 2000 and with an older progress format. Replace them with the
  output at size 40.
- implicit areas: add the runtime remark to the expected stderr.
  area_bbox no longer reports "Filters too weak"; its output is
  unchanged.
- run_testsuite.sh: also run run_unittests_implicit_areas.sh.
- Ignore result.osm, which run_unittests_areas.sh leaves behind.

Co-Authored-By: Colin Dellow <cldellow@gmail.com>
Extend the existing CI job, which runs on every push and pull request,
so that it turns test-bin on, installs into the repository root (the
test scripts expect bin/, cgi-bin/ and test-bin/ next to src/), runs
run_testsuite.sh at size 40, and fails if any test reports FAILED or a
difference from its expected output. On failure, it uploads the log and
the failed tests' outputs. The scripts always exit 0, so the job checks
their output.

Build with -D_GLIBCXX_ASSERTIONS, so that out-of-bounds indexing into a
std::string or std::vector aborts instead of reading past the end
unnoticed, and with one make job per CPU.

The job now takes about 9 minutes: 6 to build, including the test
programs, and 2 to run the suites.

Co-Authored-By: Colin Dellow <cldellow@gmail.com>
Add run_testsuite_regressions.sh, which runs every test in
osm-3s_testing/input/regression_*/ and compares its output with
expected/regression_*/, and call it from run_testsuite.sh. Each test is
one directory, so a fix can add its test without changing a script:

  stdin.log    the query (for a CGI test, the request body, if any)
  init.osm     optional: data imported into a database of the test's own
  import.args  optional: arguments for update_database (default --meta)
  env          optional: run cgi-bin/interpreter with these environment
               variables instead of osm3s_query, with a dispatcher over
               the test's database

Each test runs for at most 60 seconds and writes at most 10 MB per file,
so a test of a hang fails rather than blocks the suite. The database is
created with mktemp, because the dispatcher's socket path in a directory
under osm-3s_testing/run can exceed the length limit for socket paths.
The script passes shellcheck.

The following commits add tests for the fixes since v0.7.62.11. They
leave out the parts of #4 that leave the output of a request unchanged
(reading the POST body in chunks, the scope of the "=" search, the
operates_* checks in pt_diagrams), the cgi-bin shell scripts of #3,
and the performance changes of #8 and #11.

Co-Authored-By: Colin Dellow <cldellow@gmail.com>
Test 04c045b, "Stop the OverpassQL parser looping past the nesting
limit": node(1); inside 1024 levels of parentheses. The parser reports
that nesting is limited to 1023 levels and stops. With the fix reverted
(git revert -n 04c045b), it reports parse errors without end, and the
test stops when the output reaches 10 MB.

Co-Authored-By: Colin Dellow <cldellow@gmail.com>
Test #7: on one relation, way and two nodes by uid 1,

  rel(1); nwr._(uid_touched:999999999); out count;
  rel(1); nwr._(uid_touched:1); out count;

count 0 and 1 relations. With the fix reverted (git revert -n 4a9c1b5),
the first counts 1 relation.

Co-Authored-By: Colin Dellow <cldellow@gmail.com>
Test #4: a GET request for data=[out:custom];node(1);out; with
url=http://example.com/%0d%0aX-Injected:%201 is rejected with 400 Bad
Request. With #4 reverted (git revert -n -m 1 8edf11b), the response is
a 302 redirect with an extra header line "X-Injected: 1".

Co-Authored-By: Colin Dellow <cldellow@gmail.com>
Test #4: a GET request for data=node(bbox);out; with
bbox=7,51,8);node(id:1,52 fails to parse. With #4 reverted
(git revert -n -m 1 8edf11b), the value is substituted as is, the query
becomes node(51,7,52,8);node(id:1);out; and returns node 1.

Co-Authored-By: Colin Dellow <cldellow@gmail.com>
Test #4: a GET request for data=node(1);out;% keeps the "%" and fails
to parse. Before #4, replace_cgi read raw[pos+2], one past the end of
the string, for a "%" in the last position. The result was discarded,
so the output is the same with or without the fix, but in a build with
-D_GLIBCXX_ASSERTIONS, as in CI, the old code aborts. With #4 reverted
(git revert -n -m 1 8edf11b) and that flag, the test fails.

Co-Authored-By: Colin Dellow <cldellow@gmail.com>
@cldellow
cldellow force-pushed the revive-test-suites branch 2 times, most recently from 1f202ea to 27edf5c Compare November 27, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revive the original test suites and run them in CI

2 participants