From fdd67b72a37bb712c5707072464ce0b1a200380c Mon Sep 17 00:00:00 2001 From: Ali Sabil Date: Fri, 7 Jun 2013 12:01:01 +0200 Subject: Fix the reading of the localhost MTU in the HTTP tests Sometimes the localhost interface has a different name from "lo", this fix adds a helper function to read the MTU value when the interface name starts with "lo". --- test/http_SUITE.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index 2d7f420..9470f44 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -420,6 +420,15 @@ body_to_chunks(ChunkSize, Body, Acc) -> body_to_chunks(ChunkSize, Rest, [<< ChunkSizeBin/binary, "\r\n", Chunk/binary, "\r\n" >>|Acc]). +get_mtu() -> + {ok, Interfaces} = inet:getiflist(), + [LocalInterface | _] = lists:filter(fun + ("lo" ++ _) -> true; + (_) -> false + end, Interfaces), + {ok, [{mtu, MTU}]} = inet:ifget(LocalInterface, [mtu]), + MTU. + %% Tests. check_raw_status(Config) -> @@ -517,7 +526,7 @@ chunked_response(Config) -> %% Check if sending requests whose size is around the MTU breaks something. echo_body(Config) -> Client = ?config(client, Config), - {ok, [{mtu, MTU}]} = inet:ifget("lo", [mtu]), + MTU = get_mtu(), _ = [begin Body = list_to_binary(lists:duplicate(Size, $a)), {ok, Client2} = cowboy_client:request(<<"POST">>, -- cgit v1.2.3 From 809dc32339aedbee63c64e23461c60e207ee53a7 Mon Sep 17 00:00:00 2001 From: Ali Sabil Date: Mon, 10 Jun 2013 09:53:32 +0200 Subject: Improve the detection of localhost interfaces for the HTTP test suite --- test/http_SUITE.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index 9470f44..01da7b2 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -422,9 +422,9 @@ body_to_chunks(ChunkSize, Body, Acc) -> get_mtu() -> {ok, Interfaces} = inet:getiflist(), - [LocalInterface | _] = lists:filter(fun - ("lo" ++ _) -> true; - (_) -> false + [LocalInterface | _ ] = lists:filter(fun(Interface) -> + {ok, [{flags, Flags}]} = inet:ifget(Interface, [flags]), + lists:member(loopback, Flags) end, Interfaces), {ok, [{mtu, MTU}]} = inet:ifget(LocalInterface, [mtu]), MTU. -- cgit v1.2.3 From 240533939c9ecd8f07c9f5a6619182bb8e772a86 Mon Sep 17 00:00:00 2001 From: Ali Sabil Date: Thu, 13 Jun 2013 11:47:24 +0200 Subject: Use ct_helper for retrieving the loopack interface MTU --- test/http_SUITE.erl | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'test') diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index 01da7b2..39b30db 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -420,15 +420,6 @@ body_to_chunks(ChunkSize, Body, Acc) -> body_to_chunks(ChunkSize, Rest, [<< ChunkSizeBin/binary, "\r\n", Chunk/binary, "\r\n" >>|Acc]). -get_mtu() -> - {ok, Interfaces} = inet:getiflist(), - [LocalInterface | _ ] = lists:filter(fun(Interface) -> - {ok, [{flags, Flags}]} = inet:ifget(Interface, [flags]), - lists:member(loopback, Flags) - end, Interfaces), - {ok, [{mtu, MTU}]} = inet:ifget(LocalInterface, [mtu]), - MTU. - %% Tests. check_raw_status(Config) -> @@ -526,7 +517,7 @@ chunked_response(Config) -> %% Check if sending requests whose size is around the MTU breaks something. echo_body(Config) -> Client = ?config(client, Config), - MTU = get_mtu(), + MTU = ct_helper:get_loopback_mtu(), _ = [begin Body = list_to_binary(lists:duplicate(Size, $a)), {ok, Client2} = cowboy_client:request(<<"POST">>, -- cgit v1.2.3