scylla-sstable: correctly dump sharding_metadata

This patch fixes 2 issues at one go:

First, Currently sstables::load clears the sharding metadata
(via open_data()), and so scylla-sstable always prints
an empty array for it.

Second, printing token values would generate invalid json
as they are currently printed as binary bytes, and they
should be printed simply as numbers, as we do elsewhere,
for example, for the first and last keys.

Fixes #26982

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>

Closes scylladb/scylladb#26991

(cherry picked from commit f9ce98384a)

Closes scylladb/scylladb#27030
This commit is contained in:
Benny Halevy
2025-11-11 11:17:48 +02:00
committed by Avi Kivity
parent 3818e15d91
commit 4dcb8c19bd
4 changed files with 20 additions and 5 deletions

View File

@@ -176,8 +176,14 @@ def test_scylla_sstable_dump_component(cql, test_keyspace, scylla_path, scylla_d
print(out)
assert out
assert json.loads(out)
json_out = json.loads(out)
assert json_out
if what == "scylla-metadata":
assert "sstables" in json_out, f"Expected 'sstables' in json output: {json_out}"
for sst_name, sst_metadata in json_out["sstables"].items():
assert "sharding" in sst_metadata, f"Expected 'sharding' metadata in sstable scylla-metadata: sstable={sst_name}: {sst_metadata}"
assert sst_metadata["sharding"] != [], f"Expected non-empty sharding metadata in sstable scylla-metadata: sstable={sst_name}: {sst_metadata}"
@pytest.mark.parametrize("table_factory", [
simple_no_clustering_table,