@@ -1020,3 +1020,97 @@ def test_update_collection_async_replication_config_rejected_when_async_false(
10201020 )
10211021
10221022 mock_collections .get .return_value .config .update .assert_not_called ()
1023+
1024+
1025+ def test_create_collection_async_replication_config_warns_on_old_version (
1026+ mock_client , mock_wvc_object_ttl , capsys
1027+ ):
1028+ """Warn when async_replication_config is used against a server older than v1.34.18."""
1029+ mock_collections = MagicMock ()
1030+ mock_client .collections = mock_collections
1031+ mock_collections .exists .side_effect = [False , True ]
1032+ mock_client .get_meta .return_value = {"version" : "1.34.0" }
1033+
1034+ manager = CollectionManager (mock_client )
1035+
1036+ manager .create_collection (
1037+ collection = "TestCollection" ,
1038+ replication_factor = 3 ,
1039+ vector_index = "hnsw" ,
1040+ async_enabled = True ,
1041+ async_replication_config = {"max_workers" : 10 },
1042+ )
1043+
1044+ captured = capsys .readouterr ()
1045+ assert "Warning: --async_replication_config requires Weaviate >= v1.34.18" in (
1046+ captured .out + captured .err
1047+ )
1048+ mock_collections .create .assert_called_once ()
1049+
1050+
1051+ def test_update_collection_async_replication_config_reset (
1052+ mock_client , mock_wvc_object_ttl
1053+ ):
1054+ """Reset (empty dict) calls Reconfigure.Replication.async_config() with no kwargs."""
1055+ mock_collections = MagicMock ()
1056+ mock_client .collections = mock_collections
1057+ mock_client .collections .exists .side_effect = [True , True ]
1058+ mock_client .get_meta .return_value = {"version" : "1.36.0" }
1059+
1060+ mock_collection = MagicMock ()
1061+ mock_client .collections .get .return_value = mock_collection
1062+ mock_collection .config .get .return_value = MagicMock (
1063+ replication_config = MagicMock (factor = 3 ),
1064+ multi_tenancy_config = MagicMock (
1065+ enabled = False , auto_tenant_creation = False , auto_tenant_activation = False
1066+ ),
1067+ )
1068+
1069+ manager = CollectionManager (mock_client )
1070+
1071+ with patch .object (
1072+ wvc .Reconfigure .Replication ,
1073+ "async_config" ,
1074+ wraps = wvc .Reconfigure .Replication .async_config ,
1075+ ) as mock_async_config :
1076+ manager .update_collection (
1077+ collection = "TestCollection" ,
1078+ async_replication_config = {},
1079+ )
1080+
1081+ mock_async_config .assert_called_once_with ()
1082+ mock_collection .config .update .assert_called_once ()
1083+ repl_config = mock_collection .config .update .call_args .kwargs ["replication_config" ]
1084+ assert repl_config .asyncConfig is not None
1085+
1086+
1087+ def test_update_collection_async_replication_config_warns_on_old_version (
1088+ mock_client , mock_wvc_object_ttl , capsys
1089+ ):
1090+ """Warn when async_replication_config is used against a server older than v1.34.18."""
1091+ mock_collections = MagicMock ()
1092+ mock_client .collections = mock_collections
1093+ mock_client .collections .exists .side_effect = [True , True ]
1094+ mock_client .get_meta .return_value = {"version" : "1.34.0" }
1095+
1096+ mock_collection = MagicMock ()
1097+ mock_client .collections .get .return_value = mock_collection
1098+ mock_collection .config .get .return_value = MagicMock (
1099+ replication_config = MagicMock (factor = 3 ),
1100+ multi_tenancy_config = MagicMock (
1101+ enabled = False , auto_tenant_creation = False , auto_tenant_activation = False
1102+ ),
1103+ )
1104+
1105+ manager = CollectionManager (mock_client )
1106+
1107+ manager .update_collection (
1108+ collection = "TestCollection" ,
1109+ async_replication_config = {"max_workers" : 10 },
1110+ )
1111+
1112+ captured = capsys .readouterr ()
1113+ assert "Warning: --async_replication_config requires Weaviate >= v1.34.18" in (
1114+ captured .out + captured .err
1115+ )
1116+ mock_collection .config .update .assert_called_once ()
0 commit comments