diff options
author | Loïc Hoguin <[email protected]> | 2015-04-12 16:35:22 +0300 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-04-12 16:35:22 +0300 |
commit | 8d15999e1c4e74a4e76dbf79c7123ecb2190443f (patch) | |
tree | 25f7877d593f7fdc6ca038ea5aa6964ad01e5658 /test/spdy_SUITE.erl | |
parent | 1d49782d3f6d2c0a04918d43dee713bbb027504e (diff) | |
download | gun-8d15999e1c4e74a4e76dbf79c7123ecb2190443f.tar.gz gun-8d15999e1c4e74a4e76dbf79c7123ecb2190443f.tar.bz2 gun-8d15999e1c4e74a4e76dbf79c7123ecb2190443f.zip |
Add more complex SPDY tests
These new tests have the spdy_server send frames back.
Diffstat (limited to 'test/spdy_SUITE.erl')
-rw-r--r-- | test/spdy_SUITE.erl | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/test/spdy_SUITE.erl b/test/spdy_SUITE.erl index 7dd6d34..28d9f7c 100644 --- a/test/spdy_SUITE.erl +++ b/test/spdy_SUITE.erl @@ -21,7 +21,7 @@ all() -> [{group, spdy31}]. groups() -> [{spdy31, [parallel], ct_helper:all(?MODULE)}]. -goaway_on_close(Config) -> +goaway_on_close(_) -> doc("Send a GOAWAY when the client closes the connection (spdy-protocol-draft3-1 2.1)"), {ok, ServerPid, Port} = spdy_server:start_link(), {ok, ConnPid} = gun:open("localhost", Port, #{transport=>ssl}), @@ -29,10 +29,38 @@ goaway_on_close(Config) -> gun:close(ConnPid), [{goaway, 0, ok}] = spdy_server:stop(ServerPid). -goaway_on_shutdown(Config) -> +goaway_on_shutdown(_) -> doc("Send a GOAWAY when the client closes the connection (spdy-protocol-draft3-1 2.1)"), {ok, ServerPid, Port} = spdy_server:start_link(), {ok, ConnPid} = gun:open("localhost", Port, #{transport=>ssl}), {ok, spdy} = gun:await_up(ConnPid), gun:shutdown(ConnPid), [{goaway, 0, ok}] = spdy_server:stop(ServerPid). + +do_req_resp(ConnPid, ServerPid, ServerStreamID) -> + StreamRef = gun:get(ConnPid, "/"), + spdy_server:send(ServerPid, [ + {syn_reply, ServerStreamID, false, <<"200">>, <<"HTTP/1.1">>, []}, + {data, ServerStreamID, true, <<"Hello world!">>} + ]), + _ = gun:await(ConnPid, StreamRef), + ok. + +streamid_is_odd(_) -> + doc("Client-initiated Stream-ID must be an odd number. (spdy-protocol-draft3-1 2.3.2)"), + {ok, ServerPid, Port} = spdy_server:start_link(), + {ok, ConnPid} = gun:open("localhost", Port, #{transport=>ssl}), + {ok, spdy} = gun:await_up(ConnPid), + [do_req_resp(ConnPid, ServerPid, N * 2 - 1) || N <- lists:seq(1, 5)], + Rec = spdy_server:stop(ServerPid), + true = length(Rec) =:= length([ok || {syn_stream, StreamID, _, _, _, _, _, _, _, _, _, _} <- Rec, StreamID rem 2 =:= 1]). + +streamid_increases_monotonically(_) -> + doc("The Stream-ID must increase monotonically. (spdy-protocol-draft3-1 2.3.2)"), + {ok, ServerPid, Port} = spdy_server:start_link(), + {ok, ConnPid} = gun:open("localhost", Port, #{transport=>ssl}), + {ok, spdy} = gun:await_up(ConnPid), + Expected = [1, 3, 5, 7, 9], + [do_req_resp(ConnPid, ServerPid, N) || N <- Expected], + Rec = spdy_server:stop(ServerPid), + Expected = [StreamID || {syn_stream, StreamID, _, _, _, _, _, _, _, _, _, _} <- Rec]. |