Skip to content

radosgw-admin: add exit-code tests for the command-line handling - #71155

Merged
yuvalif merged 2 commits into
ceph:mainfrom
Rotemrs:rgw-exit-code-tests
Sep 17, 2026
Merged

yuvalif merged 2 commits into
ceph:mainfrom
Rotemrs:rgw-exit-code-tests

Conversation

@Rotemrs

@Rotemrs Rotemrs commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds test coverage for radosgw-admin command-line handling, covering the exit code of each command.

Three suites:

  • test-bucket-exit-codes.sh - the bucket commands and their argument-parsing edge cases
  • test-globals.sh - the Ceph global flags
  • test-script-exit-codes.sh - the script and script-package commands and their argument-parsing edge cases

There is currently no dedicated coverage for this behavior. src/test/cli/radosgw-admin/help.t checks --help output, 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

cd build
bash ../src/test/rgw/radosgw-admin/test-bucket-exit-codes.sh
bash ../src/test/rgw/radosgw-admin/test-globals.sh
bash ../src/test/rgw/radosgw-admin/test-script-exit-codes.sh

Rows come in three kinds:

  • check() runs with --no-mon-config and 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 aws CLI. When it cannot, for example when aws is not installed, those rows are skipped and the reason is printed.

In teuthology, rgw:tools runs all three through the qa/workunits/rgw/run-radosgw-admin-exit-codes.sh workunit, added by @yuvalif.

src/test/rgw/radosgw-admin/README.md covers the same ground, plus how to point the suites at a different build or cluster and how teuthology runs them.

Scope

This covers the bucket commands, the Ceph global flags, and the script and script-package commands. 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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions

Copy link
Copy Markdown

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 ci-approved to allow Jenkins CI jobs to run.

@Rotemrs
Rotemrs marked this pull request as ready for review August 20, 2026 07:50
@Rotemrs
Rotemrs requested a review from a team as a code owner August 20, 2026 07:50
@Rotemrs

Rotemrs commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

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.

@Rotemrs

Rotemrs commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor Author

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 :)

@adamemerson

Copy link
Copy Markdown
Contributor

ok to test

RaminNietzsche added a commit to RaminNietzsche/ceph that referenced this pull request Sep 3, 2026
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]>
@yuvalif
yuvalif requested a review from cbodley September 3, 2026 13:58
@yuvalif

yuvalif commented Sep 3, 2026

Copy link
Copy Markdown
Contributor
  • please squash the commits
  • please add a readme.md file explaining what is needed fro running the test locally (e.g a vstart cluster)

@yuvalif

yuvalif commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

teuthology was added in: d210139

test results: https://qa-proxy.ceph.com/teuthology/yuvalif-2026-09-10_14:55:34-rgw:tools-main-distro-default-trial/549652/teuthology.log

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 rgw:tools is part of the rgw suite.
for the expected failures, either make them a "skip" or if we want to run them a document the failure reason, add a new notion of xfail to the suite, where it is handled as failure, but does not fail the script itself

Rotemrs and others added 2 commits September 15, 2026 13:25
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
@Rotemrs

Rotemrs commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @yuvalif, all three are done:

  • Squashed into 2 commits: all my changes, then your teuthology commit with its changes kept intact.
  • Added src/test/rgw/radosgw-admin/README.md, which explains how to run the tests locally, including the vstart cluster.
  • Added XFAIL to the bucket suite and marked the 42 known failures with it. They are reported as expected failures and don't fail the suite. If one starts passing, it is reported as XPASS, which doesn't fail the suite either.

@yuvalif

yuvalif commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Thanks @yuvalif, all three are done:

  • Squashed into 2 commits: all my changes, then your teuthology commit with its changes kept intact.
  • Added src/test/rgw/radosgw-admin/README.md, which explains how to run the tests locally, including the vstart cluster.
  • Added XFAIL to the bucket suite and marked the 42 known failures with it. They are reported as expected failures and don't fail the suite. If one starts passing, it is reported as XPASS, which doesn't fail the suite either.

thanks!
trying to run in teuthology. currently failing on unrelated issues. will update once i have a successful run

@yuvalif

yuvalif commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@yuvalif
yuvalif self-requested a review September 15, 2026 19:01
@yuvalif

yuvalif commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

followup work:
(1) since the bash test are emulating quite a bit of what the pytest framework already does. I would recommend to re-write them using python+pytest
(2) we should fix the xfails (where we return incorrect error codes from the radosgw-admin)

@yuvalif

yuvalif commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@yuvalif
yuvalif merged commit ef2985b into ceph:main Sep 17, 2026
17 checks passed
aainscow pushed a commit to aainscow/ceph that referenced this pull request Sep 18, 2026
radosgw-admin: add exit-code tests for the command-line handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants