mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 13:28:04 +00:00
Phase 0 of the sliding sync port (renders/sliding-sync-rust-plan.md). No behaviour change: nothing calls the Rust handler yet. - `experimental_features.rust_sliding_sync: off | on`. There is no shadow mode. Booleans are accepted, as for `rust_sync`. - `synapse_rust.sliding_sync.SlidingSyncHandler`, built by `RustHandlers` on the native driver only. It shares the v2 sync handler's `SyncStore` and carries the pool, deferred and blocking helpers the later phases' entry points use. - `SlidingSyncStats`, observed per request into the `synapse_sliding_sync_rust_*` histograms. `SyncDbStats` now counts the transactions a reader begins. - The `synapse_sliding_sync_rust_rooms_total` and `synapse_sliding_sync_rust_requests_total` counters. - `SYNAPSE_TEST_RUST_SLIDING_SYNC` and `_STRICT` for trial, with the handler wrapped in `_BlockingRustCalls`, and `RUST_SLIDING_SYNC` for Complement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R5b7Ruy4cgt27Mjq6Ptxbb
111 lines
3.6 KiB
Python
111 lines
3.6 KiB
Python
#
|
|
# This file is licensed under the Affero General Public License (AGPL) version 3.
|
|
#
|
|
# Copyright (C) 2026 Element Creations Ltd.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# See the GNU Affero General Public License for more details:
|
|
# <https://www.gnu.org/licenses/agpl-3.0.html>.
|
|
|
|
|
|
import yaml
|
|
from parameterized import parameterized
|
|
|
|
from synapse.config._base import ConfigError, RootConfig
|
|
from synapse.config.experimental import ExperimentalConfig
|
|
from synapse.config.homeserver import HomeServerConfig
|
|
from synapse.types import JsonDict
|
|
|
|
from tests import unittest
|
|
|
|
|
|
class ExperimentalConfigTestCase(unittest.TestCase):
|
|
@parameterized.expand(
|
|
[
|
|
[
|
|
"single",
|
|
{
|
|
"experimental_features": {
|
|
"msc3575_enabled": True,
|
|
}
|
|
},
|
|
],
|
|
[
|
|
"multi",
|
|
{
|
|
"experimental_features": {
|
|
"msc3575_enabled": True,
|
|
"msc3030_enabled": True,
|
|
}
|
|
},
|
|
],
|
|
# This has historically worked and this is being added as a regression test
|
|
["none", {"experimental_features": None}],
|
|
]
|
|
)
|
|
def test_experimental_features_parsing(
|
|
self, test_description: str, config_values: JsonDict
|
|
) -> None:
|
|
"""
|
|
Test the that `experimental_features` parses with these values
|
|
"""
|
|
|
|
_read_config(config_values)
|
|
|
|
@parameterized.expand(
|
|
[
|
|
("rust_state_res: shadow", "shadow"),
|
|
# YAML reads these as booleans.
|
|
("rust_state_res: on", "on"),
|
|
("rust_state_res: off", "off"),
|
|
("rust_state_res: 'on'", "on"),
|
|
("{}", "off"),
|
|
]
|
|
)
|
|
def test_rust_state_res(self, features_yaml: str, expected: str) -> None:
|
|
config = _read_config({"experimental_features": yaml.safe_load(features_yaml)})
|
|
self.assertEqual(config.rust_state_res, expected)
|
|
|
|
def test_rust_state_res_rejects_unknown_modes(self) -> None:
|
|
with self.assertRaises(ConfigError):
|
|
_read_config({"experimental_features": {"rust_state_res": "maybe"}})
|
|
|
|
@parameterized.expand(
|
|
[
|
|
# YAML reads these as booleans.
|
|
("rust_sliding_sync: on", "on"),
|
|
("rust_sliding_sync: off", "off"),
|
|
("rust_sliding_sync: 'on'", "on"),
|
|
("{}", "off"),
|
|
]
|
|
)
|
|
def test_rust_sliding_sync(self, features_yaml: str, expected: str) -> None:
|
|
config = _read_config({"experimental_features": yaml.safe_load(features_yaml)})
|
|
self.assertEqual(config.rust_sliding_sync, expected)
|
|
|
|
@parameterized.expand([("shadow",), ("maybe",)])
|
|
def test_rust_sliding_sync_rejects_unknown_modes(self, mode: str) -> None:
|
|
"""There is no shadow mode."""
|
|
with self.assertRaises(ConfigError):
|
|
_read_config({"experimental_features": {"rust_sliding_sync": mode}})
|
|
|
|
|
|
def _read_config(config_values: JsonDict) -> ExperimentalConfig:
|
|
config = ExperimentalConfig(RootConfig())
|
|
config.read_config(
|
|
yaml.safe_load(
|
|
HomeServerConfig().generate_config(
|
|
config_dir_path="CONFDIR",
|
|
data_dir_path="/data_dir_path",
|
|
server_name="che.org",
|
|
)
|
|
)
|
|
| config_values,
|
|
allow_secrets_in_config=False,
|
|
)
|
|
return config
|