async def test_global_memory_store_set_store_position(get_global_memory_store_connection): global_memory_store = get_global_memory_store_connection assigned_partitions = [TopicPartition('test', 2)] last_offsets = {TopicPartition('test', 2): 0} current_instance = 2 nb_replica = 4 await global_memory_store.set_store_position(current_instance, nb_replica, assigned_partitions, last_offsets) db_meta = BaseStoreMetaData(assigned_partitions, last_offsets, current_instance, nb_replica) r_db_meta = await global_memory_store.get_metadata() assert r_db_meta.to_dict() == db_meta.to_dict()
async def test_global_memory_store_get_all(get_global_memory_store_connection): global_memory_store = get_global_memory_store_connection await global_memory_store.global_set('test1', b'value1') await global_memory_store.global_set('test2', b'value2') assigned_partitions = [TopicPartition('test', 2)] last_offsets = {TopicPartition('test', 2): 0} current_instance = 2 nb_replica = 4 meta = BaseStoreMetaData(assigned_partitions, last_offsets, current_instance, nb_replica) assert await global_memory_store.get_all() == {'test1': b'value1', 'test2': b'value2', 'metadata': bytes(str(meta.to_dict()), 'utf-8')}
async def test_local_memory_get_metadata(get_local_memory_store_connection): local_memory_store = get_local_memory_store_connection assigned_partitions = [TopicPartition('test', 2)] last_offsets = {TopicPartition('test', 2): 0} current_instance = 2 nb_replica = 4 db_meta = await local_memory_store.get_metadata() local_meta = BaseStoreMetaData(assigned_partitions, last_offsets, current_instance, nb_replica).to_dict() assert db_meta.to_dict() == local_meta
async def test_global_memory_update_metadata_tp_offset(get_global_memory_store_connection): global_memory_store = get_global_memory_store_connection tp = TopicPartition('test', 2) await global_memory_store.update_metadata_tp_offset(tp, 4) assigned_partitions = [TopicPartition('test', 2)] last_offsets = {TopicPartition('test', 2): 4} current_instance = 2 nb_replica = 4 global_meta = BaseStoreMetaData(assigned_partitions, last_offsets, current_instance, nb_replica).to_dict() db_meta = await global_memory_store.get_metadata() assert db_meta.to_dict() == global_meta