Skip to content

feat(acceptance): add support for Elasticsearch to the acceptance workflow - #88

Merged
phil-davis merged 1 commit into
mainfrom
feat/acceptance-elasticsearch
Jul 29, 2026
Merged

phil-davis merged 1 commit into
mainfrom
feat/acceptance-elasticsearch

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Description

Apps whose acceptance tests need Elasticsearch — search_elastic — could not run them on GitHub Actions at all. The acceptance workflow provisions only mysql and postgres, and there was no hook for anything else, so those suites stayed stranded in Drone.

This adds an optional elasticsearch-version input that starts owncloudops/elasticsearch on the host network. Empty — the default — leaves the workflow completely unchanged for every existing caller.

The shape follows #58 (email server) exactly: one workflow_call input, one gated docker run step, one demo caller in test.yml.

Design notes

Why a version string, not a boolean. Callers pin the version explicitly, the way databases already carries mysql:8.0-style values, so apps can move between ES versions without touching this workflow.

Why no occ config:app:set search_elastic servers step. Drone needs one because Elasticsearch is a separate container hostname there. With --network host, the service is reachable under the app's own default setting of localhost:9200, so nothing has to be configured — verified against a live container, including that parse_url handles that scheme-less value correctly. This also matches how Selenium and Inbucket are already started.

Why poll _cluster/health?wait_for_status=yellow rather than probing the port like Drone's wait-for: the first Background step of these suites creates the search index, so it needs shards allocated, not merely a listening socket. A TCP check would pass too early and fail intermittently.

The two ELASTICSEARCH_* variables mirror the Drone service definition — quieten the logs, skip the memory-lock bootstrap check. No vm.max_map_count tuning is needed: the image's entrypoint template sets discovery.type: single-node.

On failure the cluster health, index list and container log are dumped, so a red run is diagnosable rather than opaque.

Note on the new test.yml job

acceptance-api-elasticsearch will fail until owncloud/search_elastic#349 lands — the "Setup app" step runs make ci, and that app has never defined the target, having never run through this workflow before. Flagging it here rather than leaving a reviewer to discover it. Merging that PR first, or accepting one red job briefly, both work.

How Has This Been Tested?

Each new step was executed verbatim against a live container, not just reviewed:

  • Service step — owncloudops/elasticsearch:7.17 starts and is reachable on localhost:9200; _cat/plugins reports ingest-attachment 7.17.20.
  • Readiness gate — the exact timeout 600 bash -c 'until curl -sf ...' command returns "status":"green" and exits 0, in ~18s from a cold start.
  • Diagnostics step — cluster health, _cat/indices and docker logs all produce useful output.
  • actionlint on both changed files: 75 findings before, 75 after — the changes introduce no new lint findings, and there are no schema or expression errors. (The pre-existing ones are shellcheck SC2086 info notes on untouched steps.)

Not yet verified: a full acceptance run, which needs the dependency above.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

🤖 Generated with Claude Code

…kflow

Apps whose acceptance tests need Elasticsearch - search_elastic - could not
run them on GitHub Actions at all: the acceptance workflow provisions only
mysql and postgres, so those suites were stranded in Drone.

An optional `elasticsearch-version` input now starts owncloudops/elasticsearch
on the host network. The version is an input rather than a boolean so callers
pin it explicitly, the way `databases` already carries "mysql:8.0"-style
values. Empty - the default - keeps the workflow unchanged for every existing
caller.

Running it with --network host means the app is reachable under its own
default `localhost:9200` setting, so no `occ config:app:set` step is needed;
that is only required in Drone because Elasticsearch is a separate container
hostname there. The two ELASTICSEARCH_* variables mirror the Drone service
definition to quieten the logs and skip the memory-lock bootstrap check.

The readiness gate polls `_cluster/health?wait_for_status=yellow` rather than
just probing the port, because the first Background step of these suites
creates the search index and therefore needs shards allocated, not merely a
listening socket. On failure the cluster health, the index list and the
container log are dumped so a red run can be diagnosed.

Note the new `acceptance-api-elasticsearch` job in test.yml stays red until
owncloud/search_elastic gains the `make ci` target the "Setup app" step
invokes - that app has never had one, having never run through this workflow.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Thomas Müller <[email protected]>
@DeepDiver1975
DeepDiver1975 requested a review from a team as a code owner July 29, 2026 12:01
DeepDiver1975 added a commit to owncloud/search_elastic that referenced this pull request Jul 29, 2026
The `elasticsearch-version` input does not exist on
owncloud/reusable-workflows@main yet - it is only on the branch of
owncloud/reusable-workflows#88. GitHub validates reusable workflow inputs when
the run starts, before any job executes, so an unknown input is not a failure
of the job that passes it: it is a startup failure that invalidates the whole
workflow file. The result was a run with no checks at all, taking down the
existing code style and unit test jobs as collateral damage.

Referencing the feature branch directly makes the file valid again, so every
job runs and the acceptance suites can actually be exercised before either PR
merges. A TODO records the switch back to @main once #88 lands.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Thomas Müller <[email protected]>
@DeepDiver1975

Copy link
Copy Markdown
Contributor Author

The Elasticsearch plumbing is verified working

owncloud/search_elastic#349 consumes this branch and is fully green: apiSearchElastic 72/72, apiLimitSearches 52/52, webUISearchElastic 22/22 — 146 scenarios, 0 failures, all against the elasticsearch-version input added here.

So the service step, the _cluster/health?wait_for_status=yellow readiness gate and the --network host approach are confirmed end-to-end by a real consumer, not just by inspection. In particular the gate does its job: no occ config:app:set servers step turned out to be necessary, as predicted.

The acceptance-api-elasticsearch job here is still red, and needs #349 to merge first

The PR description flagged one dependency — search_elastic having no make ci target. A second turned up once the job got past that point: that app still had a behat.yml, and core's run.sh no longer has any behat.yml in its config search path, so behat was handed core's behat.php to parse as YAML and ran 0 scenarios. Both are fixed in #349.

Because this job runs against search_elastic's default branch, it will stay red until #349 lands. It is not a defect in this PR — the same code passes on #349, where the app-side fixes are present.

Suggested merge order: owncloud/search_elastic#349 first, then this one. #349 pins uses: ...@feat/acceptance-elasticsearch so it is green today; the last commit there switches back to @main once this merges.

One suggestion surfaced by the exercise

fail-fast: true on the acceptance matrix means one failing suite cancels its siblings. While debugging #349 this masked apiSearchElastic's result twice — it was cancelled rather than run, so two full cycles gave no verdict for it. fail-fast: false would let each suite report independently, which is usually what you want from a test matrix. Out of scope here; flagging it as a separate improvement.

🤖 Generated with Claude Code

phil-davis pushed a commit to owncloud/search_elastic that referenced this pull request Jul 29, 2026
* ci: run acceptance tests on GitHub Actions

Code style and unit tests were migrated to GitHub Actions already, with the
corresponding Drone stages switched off, but acceptance tests were left
behind and still ran only in Drone. The whole Behat layer was therefore
invisible to the checks on a pull request - including the regression scenario
added for the stored XSS fix in the search content highlights, which no
GitHub check executed.

Both suites now run there: the API job fans out over apiSearchElastic and
apiLimitSearches, and a second job runs webUISearchElastic. Elasticsearch is
provided by the reusable workflow's new `elasticsearch-version` input, and
mysql:8.0 is pinned to match what Drone uses rather than taking the reusable
default of mariadb.

The reusable workflow installs the app under test with `make ci`, which this
Makefile did not define - the target is added here, mirroring the other apps.
It depends on `vendor`, whose `--no-dev` install omits the behat tooling; that
is intentional, since the acceptance targets pull their own dependencies in on
the test-runner side.

Two deliberate differences from the Drone configuration: Firefox is dropped,
as the reusable workflow only starts a Chrome Selenium container - the one
Firefox-sensitive scenario is already tagged @skipOnFIREFOX - and the
files_external extra app is not requested, because it ships with core and is
enabled by default.

.drone.star is left untouched so both systems run acceptance in parallel for
now, which is what makes it possible to compare results and rule out
flakiness before the Drone pipeline is retired.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Thomas Müller <[email protected]>

* ci: point acceptance jobs at the reusable workflow branch

The `elasticsearch-version` input does not exist on
owncloud/reusable-workflows@main yet - it is only on the branch of
owncloud/reusable-workflows#88. GitHub validates reusable workflow inputs when
the run starts, before any job executes, so an unknown input is not a failure
of the job that passes it: it is a startup failure that invalidates the whole
workflow file. The result was a run with no checks at all, taking down the
existing code style and unit test jobs as collateral damage.

Referencing the feature branch directly makes the file valid again, so every
job runs and the acceptance suites can actually be exercised before either PR
merges. A TODO records the switch back to @main once #88 lands.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Thomas Müller <[email protected]>

* test: convert behat config from YAML to PHP

The acceptance suites could not start at all: behat aborted with
"Unable to parse at line 1 (near "<?php")" and ran 0 scenarios.

Core's tests/acceptance/run.sh looks for config/behat.php, acceptance/config/
behat.php and tests/acceptance/config/behat.php, and falls back to its own
config/behat.php when none is found. There is no behat.yml in that list any
more, so this app's YAML config was never found and behat was handed core's
PHP config as a YAML file instead.

This is pre-existing breakage rather than a consequence of moving to GitHub
Actions - Drone clones core master too and also never sets BEHAT_CONFIG_FILE -
but it blocks the migration, so the config is converted here. All three suites
and their contexts are carried over unchanged; the shared FeatureContext
arguments keep the behaviour the YAML anchor gave them.

behat itself is bumped from ^3.13 to ^3.31 because PHP configuration is not
supported before 3.20, and ^3.13 resolved to 3.15. The vendor-bin platform is
raised from 7.4 to 8.3 to match, which is what appinfo/info.xml already
requires and what behat 3.31 needs.

Verified by dry-running the suites inside a core checkout: apiSearchElastic
resolves 72 scenarios and apiLimitSearches 52, where both previously reached
0. The webUI suite cannot be dry-run outside run.sh, as its page objects need
the Mink session - files_texteditor, whose webUI suite passes in CI, fails the
same way under the same command.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Thomas Müller <[email protected]>

* test: wait for the search index to refresh after creating it

The apiLimitSearches suite failed intermittently, and on different rows each
run: one attempt missed '/फन्नि näme/upload.txt', the next also missed the
plain ASCII '/just-a-folder/upload.txt'. That the failing paths move between
runs, and are not confined to non-ASCII names, points at a race rather than an
encoding problem.

`the search index has been updated` already sleeps for two seconds, with a
comment explaining that Elasticsearch only makes changed shards searchable
every index.refresh_interval, which defaults to one second, so continuing
immediately can return results based on stale data. `the search index has been
created` had no such wait, even though it leaves documents equally
unsearchable, so scenarios whose Background creates the index could search
before the shards had refreshed.

The same two second wait is applied there.

Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Thomas Müller <[email protected]>

---------

Signed-off-by: Thomas Müller <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
@phil-davis
phil-davis merged commit cfce5bb into main Jul 29, 2026
61 of 62 checks passed
@phil-davis
phil-davis deleted the feat/acceptance-elasticsearch branch July 29, 2026 15:23
phil-davis pushed a commit to owncloud/search_elastic that referenced this pull request Jul 30, 2026
The comment asked for both acceptance jobs to be switched back to @main once
owncloud/reusable-workflows#88 merged. That happened in #350, so the two jobs
already reference @main and the note now contradicts the four lines below it.

Signed-off-by: Thomas Müller <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
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.

2 participants