Test StatsD consumer's send.
[beam_stats.git] / test / beam_stats_consumer_statsd_SUITE.erl
1 -module(beam_stats_consumer_statsd_SUITE).
2
3 -include_lib("beam_stats/include/beam_stats.hrl").
4
5 -export(
6 [ all/0
7 , groups/0
8 ]).
9
10 %% Test cases
11 -export(
12 [ t_beam_stats_to_bins/1
13 , t_memory_component_to_statsd_msg/1
14 , t_statsd_msg_add_name_prefix/1
15 , t_statsd_msg_to_bin/1
16 , t_node_id_to_bin/1
17 , t_send/1
18 ]).
19
20 -define(statsd_module, beam_stats_consumer_statsd).
21 -define(GROUP, ?statsd_module).
22
23 %% ============================================================================
24 %% Common Test callbacks
25 %% ============================================================================
26
27 all() ->
28 [{group, ?GROUP}].
29
30 groups() ->
31 Tests =
32 [ t_beam_stats_to_bins
33 , t_memory_component_to_statsd_msg
34 , t_statsd_msg_add_name_prefix
35 , t_statsd_msg_to_bin
36 , t_node_id_to_bin
37 , t_send
38 ],
39 Properties = [],
40 [{?GROUP, Properties, Tests}].
41
42 %% =============================================================================
43 %% Test cases
44 %% =============================================================================
45
46 t_beam_stats_to_bins(_Cfg) ->
47 ?statsd_module:ct_test__beam_stats_to_bins(_Cfg).
48
49 t_memory_component_to_statsd_msg(_Cfg) ->
50 ?statsd_module:ct_test__memory_component_to_statsd_msg(_Cfg).
51
52 t_statsd_msg_add_name_prefix(_Cfg) ->
53 ?statsd_module:ct_test__statsd_msg_add_name_prefix(_Cfg).
54
55 t_statsd_msg_to_bin(_Cfg) ->
56 ?statsd_module:ct_test__statsd_msg_to_bin(_Cfg).
57
58 t_node_id_to_bin(_Cfg) ->
59 ?statsd_module:ct_test__node_id_to_bin(_Cfg).
60
61 t_send(_Cfg) ->
62 BEAMStats = #beam_stats
63 { timestamp = {1, 2, 3}
64 , node_id = 'node_foo@host_bar'
65 , memory = [{mem_type_foo, 1}]
66 },
67 ServerPort = 8125,
68 {ok, ServerSocket} = gen_udp:open(ServerPort, [binary, {active, false}]),
69 BEAMStatsQ = queue:in(BEAMStats, queue:new()),
70 Options = [{dst_port, ServerPort}],
71 {_, State1} = beam_stats_consumer_statsd:init(Options),
72 State2 = beam_stats_consumer_statsd:consume(BEAMStatsQ, State1),
73 {} = beam_stats_consumer_statsd:terminate(State2),
74 ResultOfReceive = gen_udp:recv(ServerSocket, 0),
75 ok = gen_udp:close(ServerSocket),
76 {ok, {_, _, Data}} = ResultOfReceive,
77 <<"beam_stats.node_foo_host_bar.mem_type_foo:1|g\n">> = Data.
This page took 0.08101 seconds and 5 git commands to generate.