Skip to content

test/encoding: fix false failures in readable.sh - #71946

Open
Doracly wants to merge 3 commits into
ceph:mainfrom
Doracly:readable_sh_locale
Open

Doracly wants to merge 3 commits into
ceph:mainfrom
Doracly:readable_sh_locale

Conversation

@Doracly

@Doracly Doracly commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

src/test/encoding/readable.sh reports false failures when the shell locale is not C/POSIX, and on builds that cannot see a release tag. Three independent problems, one commit each.

1. The sort ran under the caller's locale.

For types ceph-dencoder reports as non-deterministic, the script sorts the dumps of an object and its re-encoded self before comparing them. glibc collates distinct punctuation-only lines (the bare {, },, ] of a json dump) as equal, and GNU sort is stable, so tied lines keep their input order and the dumps compare unequal:

$ printf '        {\n        },\n' | LC_ALL=de_DE.UTF-8 sort   # {  then  },
$ printf '        },\n        {\n' | LC_ALL=de_DE.UTF-8 sort   # },  then  {

Of the 123 corpus objects whose dump order changes after a re-encode, 107 falsely mismatch under de_DE.UTF-8, none under C. The fix covers only this sort; the sort -V calls compare versions, where collation cannot tie.

2. diff is fatal under set -e.

On a mismatch the script shows the difference with diff, which exits non-zero and, under set -e, kills the background job before it writes its result file. The summary then reports result file for job N is missing instead of the diff, and the type's remaining objects go untested.

3. A non-release decoder version is compared as if it were one.

Without a reachable release tag the decoder reports an abbreviated git hash, which sort -V orders by its leading characters. A digit-prefixed hash lands among the archives:

$ printf '%s\n' 0.94.2-207-g88e7ee7 4cb6da8e11 9.0.2-1116-g7811c77 | sort -V
0.94.2-207-g88e7ee7
4cb6da8e11
9.0.2-1116-g7811c77

so an 18.2.0 object marked forward incompat at 19.2.0-404-g78ddc7f9027 is tested instead of skipped, and fails. Such a build is newer than every archive, so it is now compared as zzzzz.

None of this is a regression: the diff call dates to 625a89d (2012), the result-file scheme to 8b6be11 (2016).

Verified on x86-64 Linux with LANG=de_DE.UTF-8, clang debug build reporting 4cb6da8e11: ctest -R readable → passed 29286 tests.

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.

@github-actions github-actions Bot added the tests label Sep 21, 2026
Doracly added a commit to Doracly/ceph that referenced this pull request Sep 25, 2026
needs to stay in this branch until
ceph#71946
is merged upstream.
@Doracly
Doracly marked this pull request as draft September 29, 2026 12:19
@Doracly Doracly changed the title test/encoding: fix readable.sh on hosts with a non-C locale test/encoding: fix false failures in readable.sh Sep 29, 2026
@Doracly
Doracly marked this pull request as ready for review September 29, 2026 12:51
Doracly added a commit to Doracly/ceph that referenced this pull request Sep 29, 2026
needs to stay in this branch until
ceph#71946
is merged upstream.
Doracly added a commit to Doracly/ceph that referenced this pull request Sep 30, 2026
needs to stay in this branch until
ceph#71946
is merged upstream.
Doracly added a commit to Doracly/ceph that referenced this pull request Oct 9, 2026
needs to stay in this branch until
ceph#71946
is merged upstream.
readable.sh compares the json dump of a nondeterministic object with the
dump of its re-encoded self, sorting both first so that element order does
not matter.  The sort ran under the caller's locale.  glibc collates
distinct punctuation-only lines as equal -- the bare "{", "},", "]" that
fill a json dump -- and GNU sort is stable, so tied lines keep their input
order.  The nondeterministic ordering the sort was meant to erase survives
it and the two dumps compare unequal, so the test fails on any machine
whose locale is not C/POSIX:

  $ printf '        {\n        },\n' | LC_ALL=de_DE.UTF-8 sort   # {  then  },
  $ printf '        },\n        {\n' | LC_ALL=de_DE.UTF-8 sort   # },  then  {

Byte order has no ties, so LC_ALL=C gives one canonical order.  Of the 123
corpus objects that do dump in a different order after a re-encode, 107
falsely mismatch under de_DE.UTF-8 and none under C.

Fixes: https://tracker.ceph.com/issues/80700
Signed-off-by: Dominik Raddatz <[email protected]>
@Doracly
Doracly force-pushed the readable_sh_locale branch from 90dded2 to 0bf51a3 Compare October 12, 2026 07:17
@Doracly

Doracly commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@Doracly

Doracly commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

Doracly added a commit to Doracly/ceph that referenced this pull request Nov 4, 2026
needs to stay in this branch until
ceph#71946
is merged upstream.
Doracly added a commit to Doracly/ceph that referenced this pull request Nov 4, 2026
needs to stay in this branch until
ceph#71946
is merged upstream.
Doracly added a commit to Doracly/ceph that referenced this pull request Nov 4, 2026
needs to stay in this branch until
ceph#71946
is merged upstream.
@Doracly

Doracly commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@NitzanMordhai could you review this? A build without a release tag reports a git hash as its version, which sort -V sorts among the archive versions, so the incompat checks from 011b25d test objects they should skip.

@Doracly
Doracly requested a review from NitzanMordhai November 9, 2026 12:55

@NitzanMordhai NitzanMordhai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have just 2 comments added, other then that, LGTM

Comment on lines +49 to +59
# The incompat checks compare versions with `sort -V`, which orders a git
# hash (a build without a release tag) by its leading characters. Such a
# build is newer than every archive: compare it as "zzzzz", which sorts last.
if [[ "$myversion" =~ ^[0-9]+\.[0-9]+ ]]; then
cmpversion=$myversion
else
echo "ceph-dencoder version '$myversion' is not a release version;" \
"treating the decoder as newer than every archive"
cmpversion=zzzzz
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the odd version here comes from src/CMakeLists.txt:49. It always strips the first character of git describe --always to drop the v, so an untagged build reports a truncated hash (4cb6da8e11 is missing its first character).
Not something to fix in this PR, but the CMake line should probably strip v only when it's there, maybe as a separate fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting it, fixed in #73757.

Comment thread src/test/encoding/readable.sh Outdated
Comment on lines 255 to 260
if ! cmp $tmp1 $tmp2; then
echo "**** reencode of $vdir/objects/$type/$f resulted in a different dump ****"
diff $tmp1 $tmp2
# diff always exits non-zero here; || true keeps set -e from
# killing this job before it records its result.
diff $tmp1 $tmp2 || true
failed=$(($failed + 1))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: diff can do both jobs here, which also removes the need for || true and its comment:


 if ! diff $tmp1 $tmp2; then
   echo "**** reencode of $vdir/objects/$type/$f resulted in a different dump ****"
   failed=$(($failed + 1))
 fi

The diff output would now come before the "resulted in a different dump" line instead of after it. If you'd rather keep the original order, the current version is fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

On a mismatch readable.sh prints the difference with diff, which exits
non-zero by construction.  The script runs under "set -e" and the body of
an if is not a tested position, so the shell aborts.  test_object runs as
a background job that records its tally to a result file once it is done,
so the abort discards that file and the type's remaining objects are never
tested.  The summing loop then reports

  **** result file for job N is missing; the job likely died before
  recording its result ****

which hides the very diff it was meant to show and undercounts numtests.
A genuine encode/decode regression therefore surfaces as a missing result
file rather than as a readable difference.

Test with diff itself instead of cmp: set -e ignores a failing if
condition.  The mismatch is still counted by the failed=$(($failed + 1))
in the if body.

Fixes: https://tracker.ceph.com/issues/80700
Assisted-by: claude-opus-5-5
Signed-off-by: Dominik Raddatz <[email protected]>
readable.sh decides which corpus objects to skip by comparing the
decoder's version with archive and marker versions under `sort -V`.
Without a reachable release tag that version is an abbreviated git hash,
which `sort -V` orders by its leading characters.  A digit-prefixed hash
lands among the archives:

  $ printf '%s\n' 0.94.2-207-g88e7ee7 4cb6da8e11 9.0.2-1116-g7811c77 | sort -V
  0.94.2-207-g88e7ee7
  4cb6da8e11
  9.0.2-1116-g7811c77

so an 18.2.0 object of a type marked forward incompat at
19.2.0-404-g78ddc7f9027, for example, is tested instead of skipped, and
fails.

Such a build is newer than every archive, so compare it as "zzzzz",
which sorts after any version.  Messages still report the real version.

Signed-off-by: Dominik Raddatz <[email protected]>
@Doracly

Doracly commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@NitzanMordhai thanks for the reviews! Could you add needs-qa here and on #73757?

@Doracly

Doracly commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@NitzanMordhai this and #73757 have had needs-qa since 11-15 without being batched; RADOS batches seem to pick PRs by the core label. Could you add it to both, or can test/build-only changes like these be merged without a QA run?

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@NitzanMordhai this and #73757 have had needs-qa since 11-15 without being batched; RADOS batches seem to pick PRs by the core label. Could you add it to both, or can test/build-only changes like these be merged without a QA run?

No, it needs to run in teuthology as well. will ask to pick them @SrinivasaBharath can you please pick it?

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath3-testing-20261127.055027-main.

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