blob: 3036682610eba470155259b43fd40bce9559ca08 [file] [log] [blame]
David Reiss6d477592008-06-11 01:12:09 +00001-module(test_disklog).
2
3-compile(export_all).
4
5t() ->
6 {ok, TransportFactory} =
7 thrift_disk_log_transport:new_transport_factory(
8 test_disklog,
9 [{file, "/tmp/test_log"},
10 {size, {1024*1024, 10}}]),
11 {ok, ProtocolFactory} = thrift_binary_protocol:new_protocol_factory(
12 TransportFactory, []),
13 {ok, Client} = thrift_client:start_link(ProtocolFactory, thriftTest_thrift),
14
15 io:format("Client started~n"),
David Reiss65cf7202008-06-11 01:12:20 +000016
David Reissc51986f2009-03-24 20:01:25 +000017 % We have to make oneway calls into this client only since otherwise it will try
David Reiss6d477592008-06-11 01:12:09 +000018 % to read from the disklog and go boom.
David Reiss6ce401d2009-03-24 20:01:58 +000019 {ok, ok} = thrift_client:call(Client, testOneway, [16#deadbeef]),
David Reiss6d477592008-06-11 01:12:09 +000020 io:format("Call written~n"),
21
David Reissc51986f2009-03-24 20:01:25 +000022 % Use the send_call method to write a non-oneway call into the log
David Reiss65cf7202008-06-11 01:12:20 +000023 ok = thrift_client:send_call(Client, testString, [<<"hello world">>]),
David Reiss6ce401d2009-03-24 20:01:58 +000024 io:format("Non-oneway call sent~n"),
David Reiss65cf7202008-06-11 01:12:20 +000025
David Reiss6d477592008-06-11 01:12:09 +000026 ok = thrift_client:close(Client),
27 io:format("Client closed~n"),
28
29 ok.
30
David Reiss84454062008-06-11 01:12:31 +000031
32
33t_base64() ->
34 {ok, TransportFactory} =
35 thrift_disk_log_transport:new_transport_factory(
36 test_disklog,
37 [{file, "/tmp/test_b64_log"},
38 {size, {1024*1024, 10}}]),
39 {ok, B64Factory} =
40 thrift_base64_transport:new_transport_factory(TransportFactory),
41 {ok, BufFactory} =
42 thrift_buffered_transport:new_transport_factory(B64Factory),
43 {ok, ProtocolFactory} = thrift_binary_protocol:new_protocol_factory(
44 BufFactory, []),
45 {ok, Client} = thrift_client:start_link(ProtocolFactory, thriftTest_thrift),
46
47 io:format("Client started~n"),
48
David Reissc51986f2009-03-24 20:01:25 +000049 % We have to make oneway calls into this client only since otherwise it will try
David Reiss84454062008-06-11 01:12:31 +000050 % to read from the disklog and go boom.
David Reiss6ce401d2009-03-24 20:01:58 +000051 {ok, ok} = thrift_client:call(Client, testOneway, [16#deadbeef]),
David Reiss84454062008-06-11 01:12:31 +000052 io:format("Call written~n"),
53
David Reissc51986f2009-03-24 20:01:25 +000054 % Use the send_call method to write a non-oneway call into the log
David Reiss84454062008-06-11 01:12:31 +000055 ok = thrift_client:send_call(Client, testString, [<<"hello world">>]),
David Reiss6ce401d2009-03-24 20:01:58 +000056 io:format("Non-oneway call sent~n"),
David Reiss84454062008-06-11 01:12:31 +000057
58 ok = thrift_client:close(Client),
59 io:format("Client closed~n"),
60
61 ok.
62