Skip to content

Commit 32f0417

Browse files
Copilotfruch
andcommitted
Fix Cassandra41CCMCluster to preserve boolean config values as YAML booleans
The set_configuration_options method was calling str(v) on all values, converting Python booleans (True) to the string 'True'. ruamel.yaml then writes this as a quoted YAML string ('True') instead of the boolean 'true'. When Cassandra's SnakeYAML parser tries to assign a string to a boolean field in cassandra.yaml, it fails with a type mismatch, causing Cassandra to refuse to start. This caused the cluster startup to hang for ~15 min per test module (CCM's wait_for_binary_proto timeout) even with JDK 11. Fix: only stringify values for _in_ms and _in_kb keys where a unit suffix must be appended. For all other keys (booleans, integers, strings) preserve the original Python type. Also add timeout-minutes: 120 to tests-cassandra job as a safety net. Co-authored-by: fruch <340979+fruch@users.noreply.github.com>
1 parent 95f0c2a commit 32f0417

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ jobs:
101101
name: test cassandra ${{ matrix.event_loop_manager }} (${{ matrix.python-version }})
102102
if: "!contains(github.event.pull_request.labels.*.name, 'disable-integration-tests')"
103103
runs-on: ubuntu-24.04
104+
timeout-minutes: 120
104105
strategy:
105106
fail-fast: false
106107
matrix:

tests/integration/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,5 +1001,17 @@ def _get_config_val(self, k, v):
10011001
return v
10021002

10031003
def set_configuration_options(self, values=None, *args, **kwargs):
1004-
new_values = {self._get_config_key(k, str(v)):self._get_config_val(k, str(v)) for (k,v) in values.items()}
1004+
new_values = {}
1005+
for k, v in values.items():
1006+
new_key = self._get_config_key(k, str(v))
1007+
# Only convert the value to a string for duration (_in_ms) and size (_in_kb)
1008+
# options where a unit suffix must be appended. For all other options
1009+
# (including booleans) preserve the original Python type so that ruamel.yaml
1010+
# writes a proper YAML scalar (e.g. ``true`` not ``'True'``).
1011+
if self.IN_MS_REGEX.match(k):
1012+
new_values[new_key] = "%sms" % v
1013+
elif self.IN_KB_REGEX.match(k):
1014+
new_values[new_key] = "%sKiB" % v
1015+
else:
1016+
new_values[new_key] = v
10051017
super(Cassandra41CCMCluster, self).set_configuration_options(values=new_values, *args, **kwargs)

0 commit comments

Comments
 (0)