@@ -1574,6 +1574,170 @@ def test_replication_config(
15741574 assert config .replication_config .deletion_strategy == deletion_strategy
15751575
15761576
1577+ def test_replication_config_without_async_config (collection_factory : CollectionFactory ) -> None :
1578+ collection = collection_factory (
1579+ replication_config = Configure .replication (factor = 1 , async_enabled = False ),
1580+ )
1581+ config = collection .config .get ()
1582+ assert config .replication_config .factor == 1
1583+ assert config .replication_config .async_enabled is False
1584+ assert config .replication_config .async_config is None
1585+
1586+
1587+ def test_replication_config_with_async_config (collection_factory : CollectionFactory ) -> None :
1588+ collection = collection_factory (
1589+ replication_config = Configure .replication (
1590+ factor = 1 ,
1591+ async_enabled = True ,
1592+ async_config = Configure .Replication .async_config (
1593+ max_workers = 8 ,
1594+ hashtree_height = 20 ,
1595+ ),
1596+ ),
1597+ )
1598+ config = collection .config .get ()
1599+ assert config .replication_config .factor == 1
1600+ assert config .replication_config .async_enabled is True
1601+ assert config .replication_config .async_config is not None
1602+ ac = config .replication_config .async_config
1603+ assert ac .max_workers == 8
1604+ assert ac .hashtree_height == 20
1605+
1606+
1607+ def test_replication_config_remove_async_config_by_disabling_async_replication (
1608+ collection_factory : CollectionFactory ,
1609+ ) -> None :
1610+ collection_dummy = collection_factory ("dummy" )
1611+ if collection_dummy ._connection ._weaviate_version .is_lower_than (1 , 34 , 18 ):
1612+ pytest .skip ("async replication config requires Weaviate >= 1.34.18" )
1613+
1614+ collection = collection_factory (
1615+ replication_config = Configure .replication (
1616+ factor = 1 ,
1617+ async_enabled = True ,
1618+ async_config = Configure .Replication .async_config (
1619+ max_workers = 8 ,
1620+ hashtree_height = 20 ,
1621+ ),
1622+ ),
1623+ )
1624+ config = collection .config .get ()
1625+ assert config .replication_config .async_config is not None
1626+ assert config .replication_config .async_config .max_workers == 8
1627+
1628+ collection .config .update (
1629+ replication_config = Reconfigure .replication (
1630+ async_enabled = False ,
1631+ ),
1632+ )
1633+ config = collection .config .get ()
1634+ assert config .replication_config .async_enabled is False
1635+ assert config .replication_config .async_config is None
1636+
1637+
1638+ def test_replication_config_remove_async_config (collection_factory : CollectionFactory ) -> None :
1639+ collection_dummy = collection_factory ("dummy" )
1640+ if collection_dummy ._connection ._weaviate_version .is_lower_than (1 , 34 , 18 ):
1641+ pytest .skip ("async replication config requires Weaviate >= 1.34.18" )
1642+
1643+ collection = collection_factory (
1644+ replication_config = Configure .replication (
1645+ factor = 1 ,
1646+ async_enabled = True ,
1647+ async_config = Configure .Replication .async_config (
1648+ max_workers = 8 ,
1649+ hashtree_height = 20 ,
1650+ ),
1651+ ),
1652+ )
1653+ config = collection .config .get ()
1654+ assert config .replication_config .async_config is not None
1655+ assert config .replication_config .async_config .max_workers == 8
1656+
1657+ collection .config .update (
1658+ replication_config = Reconfigure .replication (
1659+ factor = 1 , async_enabled = True , async_config = Reconfigure .Replication .async_config ()
1660+ ),
1661+ )
1662+ config = collection .config .get ()
1663+ assert config .replication_config .async_enabled is True
1664+ assert config .replication_config .async_config is None
1665+ assert config .replication_config .factor == 1
1666+
1667+
1668+ def test_replication_config_unset_single_async_field (
1669+ collection_factory : CollectionFactory ,
1670+ ) -> None :
1671+ collection_dummy = collection_factory ("dummy" )
1672+ if collection_dummy ._connection ._weaviate_version .is_lower_than (1 , 36 , 0 ):
1673+ pytest .skip ("async replication config requires Weaviate >= 1.36.0" )
1674+
1675+ collection = collection_factory (
1676+ replication_config = Configure .replication (
1677+ factor = 1 ,
1678+ async_enabled = True ,
1679+ async_config = Configure .Replication .async_config (
1680+ max_workers = 8 ,
1681+ hashtree_height = 20 ,
1682+ ),
1683+ ),
1684+ )
1685+ config = collection .config .get ()
1686+ ac = config .replication_config .async_config
1687+ assert ac is not None
1688+ assert ac .max_workers == 8
1689+ assert ac .hashtree_height == 20
1690+
1691+ # Update with only max_workers — hashtree_height reverts to server default
1692+ collection .config .update (
1693+ replication_config = Reconfigure .replication (
1694+ async_config = Reconfigure .Replication .async_config (
1695+ max_workers = 8 ,
1696+ ),
1697+ ),
1698+ )
1699+ config = collection .config .get ()
1700+ ac = config .replication_config .async_config
1701+ assert ac is not None
1702+ assert ac .max_workers == 8
1703+ assert ac .hashtree_height != 20
1704+
1705+
1706+ def test_replication_config_add_async_config_to_existing_collection (
1707+ collection_factory : CollectionFactory ,
1708+ ) -> None :
1709+ """Test updating a collection that was created without async_config to add one.
1710+
1711+ This covers the case where the existing schema has no asyncConfig key
1712+ and merge_with_existing must handle the missing field gracefully.
1713+ """
1714+ collection_dummy = collection_factory ("dummy" )
1715+ if collection_dummy ._connection ._weaviate_version .is_lower_than (1 , 34 , 18 ):
1716+ pytest .skip ("async replication config requires Weaviate >= 1.34.18" )
1717+
1718+ # Create without async_config
1719+ collection = collection_factory (
1720+ replication_config = Configure .replication (factor = 1 , async_enabled = True ),
1721+ )
1722+ config = collection .config .get ()
1723+ assert config .replication_config .async_config is None
1724+
1725+ # Update to add async_config
1726+ collection .config .update (
1727+ replication_config = Reconfigure .replication (
1728+ async_config = Reconfigure .Replication .async_config (
1729+ max_workers = 12 ,
1730+ propagation_concurrency = 4 ,
1731+ ),
1732+ ),
1733+ )
1734+ config = collection .config .get ()
1735+ assert config .replication_config .async_config is not None
1736+ ac = config .replication_config .async_config
1737+ assert ac .max_workers == 12
1738+ assert ac .propagation_concurrency == 4
1739+
1740+
15771741def test_update_property_descriptions (collection_factory : CollectionFactory ) -> None :
15781742 collection = collection_factory (
15791743 vectorizer_config = Configure .Vectorizer .none (),
0 commit comments