Repository navigation
test(admin): cover what the panel actually does, and fix what that found - #562
Merged
Merged
Conversation
Closes #445. ## The process list reported every id as 0 Found by the first test written here, and the reason it was worth writing. MySQL 8 declares INFORMATION_SCHEMA.PROCESSLIST.ID as BIGINT UNSIGNED and TIME as INT. sqlx decodes by exact width, so neither fits the i64 the code asked for, and `unwrap_or_default()` turned both failures into 0. Every row in the admin panel showed id 0, and Kill had nothing real to aim at. MariaDB declares ID as a signed bigint, which decodes cleanly — so this was broken on one server and not the other, which is how it survived. Both columns are now cast to SIGNED in the query, alongside the strings that were already cast for the same reason. The test fails against the previous code: `assertion failed: processes.iter() .all(|p| p.id > 0)`. ## Coverage Six tests before this, not the two the issue counts — kill_process was already well covered, and so was kill_query's session-preserving behaviour. What had nothing was get_process_list, get_server_variables, kill_query's error path, and the entire user lifecycle. Twelve now. The lifecycle test runs the statements the dialogs actually emit — CREATE USER with the plugin clause and MAX_USER_CONNECTIONS, the privilege editor's batched GRANT and REVOKE, GRANT OPTION, FLUSH, SHOW GRANTS read back, ALTER USER, DROP USER — because none of that lives in AdminService and nothing checked the server accepts it. A test asserting that revoking an ungranted privilege errors is included deliberately: the privilege editor derives its REVOKE list from what it read a moment earlier, so a stale read stops the batch there. That is the case the partial-failure reporting exists for. ## Also found, filed separately CREATE USER is a syntax error on MariaDB. The dialog emits `IDENTIFIED WITH <plugin> BY '...'`, which MariaDB rejects for both plugins it offers, and its default plugin — caching_sha2_password — does not exist on MariaDB at all. #561, with the transcript. Not fixed here: this change is about coverage, and that one is a frontend fix with its own tests. One test I wrote was redundant with an existing one and removed rather than kept. It also failed, for the same reason as the bug above: I read CONNECTION_ID() as i64 when it is unsigned. Co-Authored-By: Claude Opus 5 <[email protected]>
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.
Closes #445.
The process list reported every id as 0
Found by the first test written here, and the reason it was worth writing.
MySQL 8 declares
INFORMATION_SCHEMA.PROCESSLIST.IDasBIGINT UNSIGNEDandTIMEasINT. sqlx decodes by exact width, so neither fits thei64the code asked for — andunwrap_or_default()turned both failures into 0. Every row in the admin panel showed id 0, and Kill had nothing real to aim at.MariaDB declares
IDas a signed bigint, which decodes cleanly. So this was broken on one server and not the other, which is how it survived. Both columns are now cast toSIGNEDin the query, alongside the strings already cast for the same reason.Fails against the previous code:
Coverage
Six tests before this, not the two the issue counts.
kill_processwas already well covered and so waskill_query's session-preserving behaviour. What had nothing:get_process_list,get_server_variables,kill_query's error path, and the entire user lifecycle.Twelve now. The lifecycle test runs the statements the dialogs actually emit — CREATE USER with the plugin clause and
MAX_USER_CONNECTIONS, the privilege editor's batched GRANT/REVOKE, GRANT OPTION, FLUSH, SHOW GRANTS read back, ALTER USER, DROP USER — because none of that lives inAdminServiceand nothing checked the server accepts it.The test asserting that revoking an ungranted privilege errors is deliberate: the privilege editor derives its REVOKE list from what it read a moment earlier, so a stale read stops the batch right there. That's the case the partial-failure reporting exists for.
Also found, filed separately
CREATE USER is a syntax error on MariaDB. The dialog emits
IDENTIFIED WITH <plugin> BY '...', which MariaDB rejects for both plugins it offers — and its default,caching_sha2_password, doesn't exist on MariaDB at all:#561 with the full transcript. Not fixed here — this change is about coverage, and that's a frontend fix wanting its own tests.
One of mine
A test I wrote was redundant with an existing one, and removed rather than kept. It also failed — for the same reason as the bug above: I read
CONNECTION_ID()asi64when it's unsigned.12 admin integration tests green against live MySQL 8 and MariaDB 11; clippy clean.
🤖 Generated with Claude Code