Poll for myCnf in the MySQL connection-timeout CLI tests - #1192
Open
claude[bot] wants to merge 1 commit into
Open
Poll for myCnf in the MySQL connection-timeout CLI tests#1192claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
pmm-admin add returns once the server has the agent; pmm-agent writes the mysqld_exporter myCnf only after it receives the new state, so PMM-T2221's fixed 2s sleep raced that write and read an empty file. PMM-T2222/T2223 read the same file the same way. Retry the read instead of sleeping. Signed-off-by: travagliad <215686151+travagliad@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Failures fixed (investigator)
CLI / Integration tests / CLI / Integration / Percona Server 8.4(job 95388558456)cli/tests/perconaMySqlServer.spec.ts:180/@percona-server— PMM-T2221 "User can use connection timeout while using pmm-admin add"What failed
Percona Server 8.4was one of two red checks in that run. ItsRun CLI testsstep ends in|| true, so the job went red one step later onlaunchable gate(Actionable Failures | 1):The received string is empty — the
cat …/myCnfproduced no output at all.The same 23 tests, same FB image, passed on
Percona Server 5.7andPercona Server 8.0inthat same run. The telling detail is the timing: PMM-T2221 took 2.4s on the leg that failed
and 3.6s on both legs that passed.
Root cause — the test races an asynchronous write
pmm-admin addreturns as soon as the server has recorded the agent. pmm-agent writes themysqld_exporter
myCnfonly once it receives the resulting state, some time later. The testcovered that gap with a fixed
sleep 2and then read the file exactly once:So the real budget is
2splus however long those three interveningdocker execcalls take —which is why the leg where they were faster (2.4s total) is the one that failed, while the two
slower legs (3.6s) passed. A test that gets less reliable as the machine gets faster is a race,
not a product problem.
Measured directly on the FB build (
perconalab/pmm-server-fb:PR-4513-8106301, digestsha256:8b323a74…— the same digest Launchable recorded for the failing session), on an idle6-core box, polling every 100 ms:
The file does not exist when
pmm-admin addreturns; it appears ~1.2s later and does containconnect_timeout=5. PMM is doing the right thing — the 2s margin is simply not a guarantee.PMM-T2222 and PMM-T2223 read the same file the same way, behind
sleep 5.The fix
Replace the fixed sleeps + one-shot read with a polling assertion (
expect(…).toPass, thepattern already used in
mongoDb-psmdb.spec.ts) that re-resolves the agent id and re-readsmyCnfevery second for up to 60s. The service id / agent id lookups moved inside the poll too,so a not-yet-listed agent retries instead of silently producing a bad path.
Nothing is loosened: the assertion is still the exact same substring (
connect_timeout=5/=4/
=2). A build that stops writing the connection timeout still fails this test — it just nowfails after 60s of trying rather than at an arbitrary 2s mark.
Verification
Reproduced and fixed on a throwaway Linode VM following
runner-integration-cli-tests.yml, withthe failing run's own
PMM_SERVER_IMAGE=perconalab/pmm-server-fb:PR-4513-8106301,CLIENT_VERSION=…pmm-client-PR-4513-8106301.tar.gzand--database ps=8.4.Baseline — the suite is green here as-is on a fast idle box (
23 passed), matching the twoPS legs that passed in CI. Reproducing the red needs the race widened.
A/B under the same contention (
docker update --cpus 0.3 pmm-server, everything elseidentical, 3 runs each):
main(a2bf067)Expected substring: "connect_timeout=5"/Received string: ""Full
@percona-serversuite on this branch against the FB image, server unthrottled — thesame 23 tests CI ran:
23 passed (25.0s). PMM-T2222/T2223 also got faster (3.1s / 2.2s vs~5.9s), since they no longer sit through a fixed 5s sleep.
Not blocked on anything upstream. The change is test-side only and passes against the FB
image and against
main's behaviour alike — normal PR, not a draft.npm run lint(eslint +tsc --noEmit) incli/: Lint OK, 0 errors.The 60s poll budget is generous against a measured ~1.2s, but it is still a bound: at an
absurd
--cpus 0.1throttle (where a singlepmm-admin listtakes seconds) I saw one runexceed it. That is far past any CI runner and I did not tune for it.
Not covered by this PR
The other red check in that run,
E2E / Docker configuration tests / e2e tests: @docker-configuration(PMM-T2237, all three ClickHouse configs), is already tracked by the openPR #1180 — untouched here.
The same fixed-sleep-then-read-once pattern exists in the PostgreSQL, MongoDB, Valkey and
ProxySQL variants of PMM-T2221/T2222 (they grep
pmm-agent.lograther thanmyCnf). They didnot fail in this run and are left alone; worth the same treatment if they start flaking.
Generated by Claude Code