[ovs-dev] [PATCH 2/4] reconnect: Refactor tests to use common macro.

Justin Pettit jpettit at nicira.com
Wed Aug 25 06:54:42 UTC 2010


Seems reasonable.

--Justin


On Aug 23, 2010, at 5:07 PM, Ben Pfaff wrote:

> This will make it easier to add tests for the Python implemenentation.
> ---
> tests/reconnect.at |  119 ++++++++++++++++++++--------------------------------
> 1 files changed, 46 insertions(+), 73 deletions(-)
> 
> diff --git a/tests/reconnect.at b/tests/reconnect.at
> index 24ad838..d35e7bf 100644
> --- a/tests/reconnect.at
> +++ b/tests/reconnect.at
> @@ -1,23 +1,29 @@
> AT_BANNER([reconnect library])
> 
> +m4_define([__RECONNECT_CHECK],
> +  [AT_SETUP([$1])
> +   AT_KEYWORDS([reconnect])
> +   AT_DATA([input], [$2])
> +   AT_CHECK([$3], [0], [$4])
> +   AT_CLEANUP])
> +
> +m4_define([RECONNECT_CHECK],
> +  [__RECONNECT_CHECK([$1], [$2], [test-reconnect < input], [$3])])
> +
> ######################################################################
> -AT_SETUP([nothing happens if not enabled])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [run
> +RECONNECT_CHECK([nothing happens if not enabled],
> +  [run
> timeout
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> +],
>   [### t=1000 ###
> run
> timeout
>   no timeout
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([quick connect, idle disconnect])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [enable
> +RECONNECT_CHECK([quick connect, idle disconnect],
> +  [enable
> 
> # Connection succeeds.
> run
> @@ -31,8 +37,7 @@ run
> timeout
> run
> disconnected
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> +],
>   [### t=1000 ###
> enable
>   in BACKOFF for 0 ms (0 ms backoff)
> @@ -70,12 +75,10 @@ disconnected
>   1 successful connections out of 1 attempts, seqno 2
>   not connected (0 ms), total 10000 ms connected
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([slow connect, idle disconnect])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [enable
> +RECONNECT_CHECK([slow connect, idle disconnect],
> +  [enable
> 
> # Start connecting.
> run
> @@ -94,8 +97,7 @@ run
> timeout
> run
> disconnected
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> +],
>   [### t=1000 ###
> enable
>   in BACKOFF for 0 ms (0 ms backoff)
> @@ -143,12 +145,10 @@ disconnected
>   1 successful connections out of 1 attempts, seqno 2
>   not connected (0 ms), total 10000 ms connected
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([connect backs off])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [enable
> +RECONNECT_CHECK([connect backs off],
> +  [enable
> 
> # First connection attempt fails after 1000 ms.
> run
> @@ -207,8 +207,7 @@ connecting
> timeout
> run
> connect-failed
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> +],
>   [### t=1000 ###
> enable
>   in BACKOFF for 0 ms (0 ms backoff)
> @@ -345,12 +344,10 @@ connect-failed
>   in BACKOFF for 0 ms (8000 ms backoff)
>   0 successful connections out of 6 attempts, seqno 0
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([connections with no data preserve backoff])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [enable
> +RECONNECT_CHECK([connections with no data preserve backoff],
> +  [enable
> 
> # First connect, then idle timeout kills connection.
> run
> @@ -506,14 +503,11 @@ timeout
> 
> ### t=38000 ###
>   in BACKOFF for 4000 ms (4000 ms backoff)
> -
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([brief connection preserves backoff])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [enable
> +RECONNECT_CHECK([brief connection preserves backoff],
> +  [enable
> 
> # First connection attempt fails after 1000 ms.
> run
> @@ -551,9 +545,7 @@ run
> # Back off for 4000 ms.
> timeout
> run
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> -  [### t=1000 ###
> +], [### t=1000 ###
> enable
>   in BACKOFF for 0 ms (0 ms backoff)
> 
> @@ -641,12 +633,10 @@ timeout
> run
>   should connect
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([brief connection with data preserves backoff])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [enable
> +RECONNECT_CHECK([brief connection with data preserves backoff],
> +  [enable
> 
> # First connection attempt fails after 1000 ms.
> run
> @@ -694,8 +684,7 @@ run
> # Back off for 4000 ms.
> timeout
> run
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> +],
>   [### t=1000 ###
> enable
>   in BACKOFF for 0 ms (0 ms backoff)
> @@ -805,12 +794,10 @@ timeout
> run
>   should connect
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([long connection resets backoff])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [enable
> +RECONNECT_CHECK([long connection resets backoff],
> +  [enable
> 
> # First connection attempt fails after 1000 ms.
> run
> @@ -858,8 +845,7 @@ run
> # Back off for 1000 ms.
> timeout
> run
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> +],
>   [### t=1000 ###
> enable
>   in BACKOFF for 0 ms (0 ms backoff)
> @@ -969,12 +955,10 @@ timeout
> run
>   should connect
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([connection attempt fails quickly])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [enable
> +RECONNECT_CHECK([connection attempt fails quickly],
> +  [enable
> 
> # Connection fails quickly.
> run
> @@ -991,9 +975,8 @@ connect-failed ECONNREFUSED
> # Back off for 2000 ms.
> run
> timeout
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> -  [### t=1000 ###
> +],
> +   [### t=1000 ###
> enable
>   in BACKOFF for 0 ms (0 ms backoff)
> 
> @@ -1027,12 +1010,10 @@ timeout
> ### t=4000 ###
>   in BACKOFF for 2000 ms (2000 ms backoff)
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([max-tries of 1 honored])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [set-max-tries 1
> +RECONNECT_CHECK([max-tries of 1 honored],
> +  [set-max-tries 1
> enable
> 
> # Connection succeeds.
> @@ -1047,8 +1028,7 @@ run
> timeout
> run
> disconnected
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> +],
>   [### t=1000 ###
> set-max-tries 1
>   1 tries left
> @@ -1089,17 +1069,14 @@ disconnected
>   1 successful connections out of 1 attempts, seqno 2
>   not connected (0 ms), total 10000 ms connected
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([max-tries of 0 honored])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [set-max-tries 0
> +RECONNECT_CHECK([max-tries of 0 honored],
> +  [set-max-tries 0
> enable
> run
> timeout
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> +],
>   [### t=1000 ###
> set-max-tries 0
>   0 tries left
> @@ -1108,12 +1085,10 @@ run
> timeout
>   no timeout
> ])
> -AT_CLEANUP
> 
> ######################################################################
> -AT_SETUP([passive mode])
> -AT_KEYWORDS([reconnect])
> -AT_DATA([input], [passive
> +RECONNECT_CHECK([passive mode],
> +  [passive
> enable
> 
> # Start listening.
> @@ -1148,8 +1123,7 @@ disconnected
> timeout
> run
> listening
> -])
> -AT_CHECK([test-reconnect < input], [0], 
> +],
>   [### t=1000 ###
> passive
> enable
> @@ -1228,4 +1202,3 @@ run
> listening
>   in LISTENING for 0 ms (0 ms backoff)
> ])
> -AT_CLEANUP
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list