/xwiki:xwiki-fix-flickering-docker-testfrom xwiki
Investigates and fixes flickering Docker UI tests in XWiki repos using evidence-first methodology: gather CI history, map failure groups, form hypotheses, and force race conditions to reproduce before applying fixes.
Ships in xwiki. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Read first, before editing any test: the rules the steps below depend on are not repeated here — kb/testing/strategy.md for the page-object boundary (the fix goes in a page object, never as a getDriver() call in the test class) and the don't-pay-the-timeout rule, and kb/testing/running-docker-its.md for the JDK-on-PATH and :8080 prerequisites that otherwise surface as "Failed to start XWiki in [N] seconds". kb/testing/flickers.md has how to read the failure's video, the Selenium and browser mechanics most flickers turn out to be, and how to force a race.
A flicker is investigated like any other bug: evidence → hypothesis → experiment → fix, looping back to the hypothesis whenever an experiment disagrees with it. Re-running the unchanged test until it fails locally rarely works — local timing seldom matches CI's — so the experiment forces the interleaving the hypothesis names instead of waiting for it. A flicker is understood when an experiment turns the test red with the CI symptom on demand — forced, or unforced when the flicker happens to reproduce reliably locally — and fixed when the same experiment turns green with the fix.
Keep the evidence, each hypothesis and each experiment's outcome in a notes file in the work directory: a hypothesis that failed is evidence for the next one, and the investigation often spans sessions.
Gather it all before running anything locally. Done when you can state, for each distinct failure: the symptom (exception, failing step), the rate, the configurations it hits and the ones it spares, since when it fails, and what the browser showed at that moment.
dv-test-history when installed, the develocity MCP otherwise (kb/servers/develocity.md). There is no Develocity data for xwiki-contrib repos: go to Jenkins (kb/servers/jenkins.md).git show origin/<branch>:<file>) — line numbers differ between branches, so groups that look different are often one step, and one line can be two steps.kb/testing/flickers.md).kb/testing/flickers.md).REALTIME_DEBUG dump (kb/testing/flickers.md).Read the failing step's test code, every page-object method it calls, and the production code those drive — the JavaScript handlers, the templates, the Java — following the step until you know what went wrong — usually two things racing within the test, sometimes a state the wiki was already in when the test started. Then write the hypothesis down as a mechanism: A happens before B because C, plus its prediction — what delaying or reordering which operation will produce.
Done when the hypothesis explains every piece of evidence: the symptom and the failing line, the configurations it hits and spares, the rough rate, the screenshot. Evidence it does not explain stays in the notes as open — it is usually a second cause or a wrong hypothesis, and several failure groups can need several hypotheses.
kb/testing/flickers.md; most flickers are one of them.showMinorEdits() waits for the reload and deleteRangeVersions() does not has its answer in the next method.kb/testing/flickers.md has the signs); the experiment then targets the setup and the server rather than the test's own steps.Present the evidence, the hypothesis and the planned experiment to the developer before launching Docker runs: each costs minutes and holds port 8080.
Make the hypothesised interleaving happen on demand, then run the test with the code unchanged: this is the control.
Thread.sleep in the test or page object, a deferred browser action through executeScript (kb/testing/flickers.md has the recipes), or a sleep or setTimeout in the production code itself.window array read back through executeScript, since the console is readable only on Chrome (kb/testing/flickers.md) — to observe the actual order of the two operations, when the order rather than the outcome is in doubt.-Dxwiki.test.ui.browserTag=<tag>), another browser, another database.A reliable local reproduction is an experiment too. When the unchanged test already fails with the CI symptom in a large share of local runs — 10 of 15, say — those runs are the control, and nothing needs forcing. Count the failures by symptom (by the deepest test frame, kb/testing/flickers.md): the CI one must be among them, and the others are further races of the same flicker that the fix has to account for. The failing runs' own screenshots, videos and logs feed the hypothesis, which still decides where the fix goes.
The forcing may make happen only what can happen without it — a delay CI can plausibly hit, an order the code does not prevent, a value the source can return — and the notes say what it forces and why that is reachable. A forced state the code can never reach still turns red, and its fix then turns green, so that red proves nothing about CI.
Mark every temporary change // TEMP and save it as a patch, so it can be reverted and re-applied for the fix's run. A forced race fails nearly every time, so a few repetitions are enough — a temporary @RepeatedTest(N), with the test first deleting what it creates (pages, users) so a repetition starts clean.
Read the outcome against the prediction:
When the proof runs out, ask. A hypothesis you consider likely but cannot confirm — the experiments stayed green, or none can reach the window — goes to the developer rather than being dropped or fixed silently: the evidence, the hypothesis and why it is likely, each experiment and its outcome, and the options you see — a fix on the evidence there is, a different experiment, diagnostic logging and unforced repetitions (see the rate section below), or stopping with a comment on the flicker issue. Then follow their choice.
Fix the cause the experiment confirmed — in a page object when the test drives the UI faster than the page allows (per the page-object boundary, which also fixes every other test using it), in production code when the race is a product bug. Then:
// TEMP change and run the test unforced on Firefox and Chrome: it still passes. The diff now contains only the fix.xwiki-jira) rather than filing it on your own.dv-test-history gives the number of clean runs needed to call it fixed.-docker and -tests suffix.jetty/start_xwiki.sh in the configuration's directory under ./target/ — hsqldb-default-default-jetty_standalone-default-firefox on 18.7.0RC1+, hsqldb_embedded-… before, plus -standardflavor when the test sets standardFlavor — run from that directory (its paths are relative). Reusing the provisioned instance makes an iteration take seconds instead of minutes. Stop it with ./stop_xwiki.sh there, at the end.mvn compiler:testCompile failsafe:integration-test -B -ntp -Dxwiki.test.ui.servletEngine=external -Dit.test=TestClass#testMethod -Dxwiki.test.ui.browser=chrome
failsafe:integration-test does not recompile test sources, so without compiler:testCompile this silently re-runs the previously compiled test.
5. After a change outside the -docker and -pageobjects projects, go back to 1 to recreate the instance; after a page-object change, rebuild the -pageobjects project and repeat 4.
xwiki-it-repeat.mjsRunning the unchanged test many times is a way to gather evidence, not to prove a fix: it only pays off when the flicker fails locally without forcing, and most do not. Whether to try it is a judgement call:
A local rate high enough to be a reliable reproduction is proof like a forced experiment (step 3); a low one is supporting evidence, quoted with its execution counts.
node "${CLAUDE_PLUGIN_ROOT}/scripts/xwiki-it-repeat.mjs" --module <path-to-*-test-docker> \
--test TestClass#testMethod --runs 20 --browser firefox --label before
(In Kimi Code the script is under ${KIMI_SKILL_DIR}/../../scripts/, in opencode under $XWIKI_LLM_HOME/xwiki/scripts/.) It keeps each failing repetition's Failsafe report, screenshot and video under run-NN/, writes a report.json and a summary.md table to quote on the issue or the pull request, and takes one Docker IT slot for the whole session. --baseline <before>/report.json on the second measurement prints both rates and the delta. It refuses to start when something already holds port 8080, rather than provisioning into somebody else's wiki (the 401 trap).
beforeAll never ran the test, so it is listed on its own line and left out of the rate — see the symptom table in kb/testing/running-docker-its.md. Same for one that hit the timeout.dv-test-history gives the number of clean CI runs this particular test needs.--mode reuse, the default, provisions the wiki once and re-runs the test against it, which is ten times faster per repetition; it needs the default jetty_standalone engine and port 8080 free. Repetitions then share one wiki, so when the suspicion is that the test depends on a fresh one, use --mode fresh — a full -Pdocker,integration-tests build per repetition, with any servlet engine.Ask before launching it, as for any Docker run (step 2): twenty repetitions take around half an hour.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
38 skills in this plugin
/xwiki-backportBackport any change (bug fix, feature, refactor, or test) to an older branch of an XWiki repo (xwiki-platform / xwiki-commons / xwiki-rendering / xwiki-contrib). Cherry-pick `-x` the source commit(s) into a worktree, ADAPT the result to the older branch (module pom versions, Java level, `@since` tags, data migration versions and skip ranges, style/API divergence), verify it compiles against that branch, and push / open a PR. Use whenever a commit that exists on one branch needs to be applied to an older/maintenance branch. For the `testneeded`-labelled test sweep use xwiki-backport-testneeded (which builds on this skill); for Maven commands use xwiki-build; for PR/commit conventions use xwiki-pull-request; for the versioning/`@since` conventions (the format and what carries `@since`) use xwiki-knowledge./xwiki-backport-testneededBackport the automated test of one JIRA issue labelled `testneeded` to the currently-supported stable branches, adjust its `@since` tags across all branches, and open the PRs. Use when asked to backport the test of a given testneeded issue, or to catch a stable branch up with a recently-added test. (For several issues at once, the user will say so — then apply this per issue.) This is the test-specific layer on top of xwiki-backport (which owns the generic cherry-pick / adapt-to-branch / verify mechanics — including the mandatory pom-version, Java-version and `@since` checks). For Maven use xwiki-build; for PR/commit conventions use xwiki-pull-request; for the `@since` rules use xwiki-knowledge; for querying JIRA (the testneeded sweep) use xwiki-jira.npx claudepluginhub xwiki/xwiki-dev-llm --plugin xwiki