Skip to content

test(admin): cover what the panel actually does, and fix what that found - #562

Merged
EVWorth merged 1 commit into
mainfrom
test/admin-integration-coverage
Sep 7, 2026
Merged

EVWorth merged 1 commit into
mainfrom
test/admin-integration-coverage

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 7, 2026

Copy link
Copy Markdown
Owner

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 already cast for the same reason.

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: 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 in AdminService and 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:

MariaDB 11: IDENTIFIED WITH caching_sha2_password BY 'pw'  ->  ERROR 1064
MariaDB 11: IDENTIFIED WITH mysql_native_password BY 'pw'  ->  ERROR 1064
MariaDB 11: IDENTIFIED BY 'pw'                             ->  ok
MySQL 8:    IDENTIFIED WITH caching_sha2_password BY 'pw'  ->  ok

#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() as i64 when it's unsigned.

12 admin integration tests green against live MySQL 8 and MariaDB 11; clippy clean.

🤖 Generated with Claude Code

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]>
@EVWorth
EVWorth merged commit 4242fc7 into main Sep 7, 2026
10 checks passed
@EVWorth
EVWorth deleted the test/admin-integration-coverage branch September 7, 2026 23:27
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.

[P1] [bug] 13 of 15 admin integration tests missing — CRUD routes through executeQuery

1 participant