@@ -6731,6 +6731,66 @@ async def test_function_load_cluster_with_route(
67316731
67326732 assert await redis_client .function_load (new_code , True , route ) == lib_name
67336733
6734+ @pytest .mark .parametrize ("cluster_mode" , [True , False ])
6735+ @pytest .mark .parametrize ("protocol" , [ProtocolVersion .RESP2 , ProtocolVersion .RESP3 ])
6736+ async def test_function_flush (self , redis_client : TGlideClient ):
6737+ min_version = "7.0.0"
6738+ if await check_if_server_version_lt (redis_client , min_version ):
6739+ pytest .skip (f"Redis version required >= { min_version } " )
6740+
6741+ lib_name = f"mylib1C{ get_random_string (5 )} "
6742+ func_name = f"myfunc1c{ get_random_string (5 )} "
6743+ code = generate_lua_lib_code (lib_name , {func_name : "return args[1]" }, True )
6744+
6745+ # Load the function
6746+ assert await redis_client .function_load (code ) == lib_name
6747+
6748+ # TODO: Ensure the function exists with FUNCTION LIST
6749+
6750+ # Flush functions
6751+ assert await redis_client .function_flush (FlushMode .SYNC ) == OK
6752+ assert await redis_client .function_flush (FlushMode .ASYNC ) == OK
6753+
6754+ # TODO: Ensure the function is no longer present with FUNCTION LIST
6755+
6756+ # Attempt to re-load library without overwriting to ensure FLUSH was effective
6757+ assert await redis_client .function_load (code ) == lib_name
6758+
6759+ # Clean up by flushing functions again
6760+ await redis_client .function_flush ()
6761+
6762+ @pytest .mark .parametrize ("cluster_mode" , [True ])
6763+ @pytest .mark .parametrize ("protocol" , [ProtocolVersion .RESP2 , ProtocolVersion .RESP3 ])
6764+ @pytest .mark .parametrize ("single_route" , [True , False ])
6765+ async def test_function_flush_with_routing (
6766+ self , redis_client : GlideClusterClient , single_route : bool
6767+ ):
6768+ min_version = "7.0.0"
6769+ if await check_if_server_version_lt (redis_client , min_version ):
6770+ pytest .skip (f"Redis version required >= { min_version } " )
6771+
6772+ lib_name = f"mylib1C{ get_random_string (5 )} "
6773+ func_name = f"myfunc1c{ get_random_string (5 )} "
6774+ code = generate_lua_lib_code (lib_name , {func_name : "return args[1]" }, True )
6775+ route = SlotKeyRoute (SlotType .PRIMARY , "1" ) if single_route else AllPrimaries ()
6776+
6777+ # Load the function
6778+ assert await redis_client .function_load (code , False , route ) == lib_name
6779+
6780+ # TODO: Ensure the function exists with FUNCTION LIST
6781+
6782+ # Flush functions
6783+ assert await redis_client .function_flush (FlushMode .SYNC , route ) == OK
6784+ assert await redis_client .function_flush (FlushMode .ASYNC , route ) == OK
6785+
6786+ # TODO: Ensure the function is no longer present with FUNCTION LIST
6787+
6788+ # Attempt to re-load library without overwriting to ensure FLUSH was effective
6789+ assert await redis_client .function_load (code , False , route ) == lib_name
6790+
6791+ # Clean up by flushing functions again
6792+ assert await redis_client .function_flush (route = route ) == OK
6793+
67346794 @pytest .mark .parametrize ("cluster_mode" , [True , False ])
67356795 @pytest .mark .parametrize ("protocol" , [ProtocolVersion .RESP2 , ProtocolVersion .RESP3 ])
67366796 async def test_srandmember (self , redis_client : TGlideClient ):
0 commit comments