mirror of https://github.com/redis/redis.git
				
				
				
			Fix EVAL timeout test failed on freebsd (#10098)
* Refactor EVAL timeout test * since the test used r config set appendonly yes which generates a rewrite, it missed it's purpose * Fix the bug that start_server returns before redis starts ready, which affects when multiple tests share the same dir. * Elapsed time tracking no loner needed Co-authored-by: Oran Agra <oran@redislabs.com>
This commit is contained in:
		
							parent
							
								
									495ac8b79a
								
							
						
					
					
						commit
						fa60049648
					
				|  | @ -478,26 +478,26 @@ tags {"aof external:skip"} { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     test {EVAL timeout with slow verbatim Lua script from AOF} { |     test {EVAL timeout with slow verbatim Lua script from AOF} { | ||||||
|         create_aof $aof_dirpath $aof_file { |         start_server [list overrides [list dir $server_path appendonly yes lua-time-limit 1 aof-use-rdb-preamble no]] {   | ||||||
|             append_to_aof [formatCommand select 9] |  | ||||||
|             append_to_aof [formatCommand eval {redis.call('set',KEYS[1],'y'); for i=1,1500000 do redis.call('ping') end return 'ok'} 1 x] |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         start_server [list overrides [list dir $server_path appendonly no lua-time-limit 1 aof-use-rdb-preamble no]] { |  | ||||||
|             # generate a long running script that is propagated to the AOF as script |             # generate a long running script that is propagated to the AOF as script | ||||||
|             # make sure that the script times out during loading |             # make sure that the script times out during loading | ||||||
|  |             create_aof $aof_dirpath $aof_file { | ||||||
|  |                 append_to_aof [formatCommand select 9] | ||||||
|  |                 append_to_aof [formatCommand eval {redis.call('set',KEYS[1],'y'); for i=1,1500000 do redis.call('ping') end return 'ok'} 1 x] | ||||||
|  |             } | ||||||
|             set rd [redis_deferring_client] |             set rd [redis_deferring_client] | ||||||
|             r config set appendonly yes |  | ||||||
|             set start [clock clicks -milliseconds] |  | ||||||
|             $rd debug loadaof |             $rd debug loadaof | ||||||
|             $rd flush |             $rd flush | ||||||
|             after 100 |             wait_for_condition 100 10 { | ||||||
|  |                 [s loading] == 1 | ||||||
|  |             } else { | ||||||
|  |                 fail "server didn't start loading" | ||||||
|  |             } | ||||||
|             catch {r ping} err |             catch {r ping} err | ||||||
|             assert_match {LOADING*} $err |             assert_match {LOADING*} $err | ||||||
|             $rd read |             $rd read | ||||||
|             set elapsed [expr [clock clicks -milliseconds]-$start] |  | ||||||
|             if {$::verbose} { puts "loading took $elapsed milliseconds" } |  | ||||||
|             $rd close |             $rd close | ||||||
|  |             wait_for_log_messages 0 {"*Slow script detected*"} 0 100 100 | ||||||
|             assert_equal [r get x] y |             assert_equal [r get x] y | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -505,6 +505,10 @@ proc start_server {options {code undefined}} { | ||||||
|         close $fd |         close $fd | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     # We may have a stdout left over from the previous tests, so we need | ||||||
|  |     # to get the current count of ready logs | ||||||
|  |     set previous_ready_count [count_message_lines $stdout "Ready to accept"] | ||||||
|  | 
 | ||||||
|     # We need a loop here to retry with different ports. |     # We need a loop here to retry with different ports. | ||||||
|     set server_started 0 |     set server_started 0 | ||||||
|     while {$server_started == 0} { |     while {$server_started == 0} { | ||||||
|  | @ -585,7 +589,7 @@ proc start_server {options {code undefined}} { | ||||||
| 
 | 
 | ||||||
|         while 1 { |         while 1 { | ||||||
|             # check that the server actually started and is ready for connections |             # check that the server actually started and is ready for connections | ||||||
|             if {[count_message_lines $stdout "Ready to accept"] > 0} { |             if {[count_message_lines $stdout "Ready to accept"] > $previous_ready_count} { | ||||||
|                 break |                 break | ||||||
|             } |             } | ||||||
|             after 10 |             after 10 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue