Summary: test_describe in cqlsh_tests/cqlsh_tests.py::TestCqlsh is flaky. The test is written to expect the objects of a keyspace to be lexicographically sorted in DESCRIBE KEYSPACE output. However, this almost never happens, because the sort order of objects in DESCRIBE KEYSPACE output is arbitrary. I plan to modify the test to check for expected output without requiring lexicographic sorting of items of the same type; this work would be rolled up under other work in CASSANDRA-10190.
This is happening in the Cassandra Python driver, in cassandra.metadata, in the KeyspaceMetadata and TableMetadata classes. KeyspaceMetadata and TableMetadata store their child objects in Python dictionaries, and when generating DESCRIBE output, they visit their child objects in the order returned by the values() function of each dictionary. The Python dictionary values() function returns items in an arbitrary order, so they will not necessarily come back sorted lexicographically as expected by the test.
A simple fix for the test would be to change the way it checks for the expected output so that the order of objects of the same type is no longer important.
As currently written, the test creates a keyspace like so:
It expects the output of DESCRIBE KEYSPACE test to appear in the following order:
But as described above, tables aren't sorted lexicographically, and a table's indexes aren't sorted lexicographically, so output for table test.users can come before output for table test.test, and output for index test_val_idx can come before output for index test_col_idx. The planned change to the test would make it so that the test passes regardless of the order of these like objects.
If lexicographic sorting of objects of like type actually is a requirement for DESCRIBE KEYSPACE, then we could fix this by modifying cqlsh (duplicative, but simple), or by modifying the Cassandra Python driver's cassandra/metadata.py script file (less duplicative but more difficult to distribute).