Repository navigation
radosgw-admin: add exit-code tests for the command-line handling - #71155
Conversation
|
Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR |
|
Hi @cbodley! Following up on our earlier discussion about the CLI11 migration, I've opened this PR with the exit-code tests we talked about. The idea is to run these tests against main first to capture the current behavior, and then use them as a baseline to identify and review any behavioral changes introduced by the migration. It currently covers the bucket commands, the global flags, and the script commands. |
|
One design question I'd like input on: Each suite mixes two kinds of rows: check() needs no cluster, while check_cluster() needs a running cluster and skips cleanly when there is none. Roughly 40% of the bucket rows are cluster-free. One alternative would be to split the suites into separate files, so the cluster-free rows could be run on their own without requiring a running cluster. I kept them together because the rows are grouped by command and behavior, and splitting them by execution requirement would cut most sections in half. The setup and cluster handling would also need to be reorganized, so while it is doable, it is not a small change. Does that split seem worth doing? I'm happy to do it as a follow-up if you think it would be useful :) |
|
ok to test |
Add an initial exit-code test suite for the account admin module, following the structure and naming used in PR ceph#71155. A shared helper script holds check() and check_cluster(); the account test covers CLI parsing, flag validation, and a small lifecycle integration block. Register the test with add_ceph_test() under WITH_RADOSGW. Signed-off-by: ramin.najarbashi <[email protected]>
|
|
teuthology was added in: d210139 however, before we merge we need to use something like xfail in the test - without that we will be turning the rgw test suite in teuthology red. since |
radosgw-admin has no tests for how it reads its command line. Add three suites that cover the bucket commands, the script commands and the ceph global flags. Each row runs a command and checks the exit code. Error output is not checked because its wording can change at any time. Rows that need a running cluster are skipped when there is none. Some bucket rows expect a code radosgw-admin does not return yet. A few places return -EINVAL (-22) or -ENOENT (-2) without flipping the sign, so the shell shows 234 or 254 instead of 22 or 2. Those rows expect the correct value and are marked XFAIL, so they are reported as expected failures instead of failing the suite. Once radosgw-admin is fixed, those rows pass and are reported as XPASS until someone removes their XFAIL marks. Signed-off-by: Rotem Shapira <[email protected]>
Signed-off-by: Yuval Lifshitz <[email protected]> Assisted-by: claude-code:claude-fable-5.1
9f2d34e to
e89226d
Compare
|
Thanks @yuvalif, all three are done:
|
thanks! |
|
followup work: |
|
jenkins test make check arm64 |
radosgw-admin: add exit-code tests for the command-line handling
Summary
Adds test coverage for radosgw-admin command-line handling, covering the exit code of each command.
Three suites:
test-bucket-exit-codes.sh- thebucketcommands and their argument-parsing edge casestest-globals.sh- the Ceph global flagstest-script-exit-codes.sh- thescriptandscript-packagecommands and their argument-parsing edge casesThere is currently no dedicated coverage for this behavior.
src/test/cli/radosgw-admin/help.tchecks--helpoutput, while these suites cover how the tool behaves for malformed, misplaced, or ambiguous command lines. Error output is not checked because its wording can change at any time.Why now
I am migrating radosgw-admin's argument parsing to CLI11 (#69145). That work changes some of these exit codes. Recording the current behavior first means every change made by the migration can be compared against a specific existing test case, making behavioral differences explicit and easier to review.
It is also why there are many rows. The migration is being done command by command, so each command needs to be checked independently and thoroughly. The same relevant edge cases are therefore repeated across commands. Sampling only a few commands would not catch a behavioral change that affects only one command or command family.
These suites also stand on their own: these are behaviors that scripts and operators already depend on.
How the expectations were produced
Every row was run against radosgw-admin built from main, and its behavior was recorded. The suites were generated from those recordings, so a row asserts what radosgw-admin actually does, not what it was assumed to do. However, in 42 of them the recorded code is a bug. Those rows expect the correct code instead of the recorded one, and are described under Known failures.
Known failures
In 42 rows of the bucket suite, radosgw-admin returns the wrong exit code. In those cases it returns -EINVAL (-22) or -ENOENT (-2) without flipping the sign, so the shell shows 234 or 254. Other commands return the same two errors positive and exit 22 or 2. The 42 rows expect 22 and 2, and are marked XFAIL: they are reported as expected failures and do not fail the suite. Once radosgw-admin is fixed, they pass and are reported as XPASS until someone removes their XFAIL marks. They all need a cluster, so without one they are skipped.
Running it
Rows come in three kinds:
check()runs with--no-mon-configand needs no cluster.check_cluster()needs a running cluster and SKIPs cleanly when there is none.check_bucket(), in the bucket suite only, needs a running cluster and a real bucket, and SKIPs when either is missing.Running without a cluster is safe: the cluster-dependent rows skip rather than hang. Each row's classification was verified, not assumed.
The bucket suite also has a group of rows that need a real bucket. It creates one over S3 with the
awsCLI. When it cannot, for example whenawsis not installed, those rows are skipped and the reason is printed.In teuthology,
rgw:toolsruns all three through theqa/workunits/rgw/run-radosgw-admin-exit-codes.shworkunit, added by @yuvalif.src/test/rgw/radosgw-admin/README.mdcovers the same ground, plus how to point the suites at a different build or cluster and how teuthology runs them.Scope
This covers the
bucketcommands, the Ceph global flags, and thescriptandscript-packagecommands. radosgw-admin's other command families are not covered here.AI disclosure
AI was used as a development aid for research, brainstorming, code generation, test generation, and language assistance. The AI-assisted work was manually reviewed and refined, and the resulting expectations were verified against the existing behavior through direct runs and comparisons with
main.Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.