Skip to content

Commit 2c18142

Browse files
committed
Update instrumentation tests for components
There is need to check for the empty host type in the labels, because components don't have host types assigned to them.
1 parent 3eac487 commit 2c18142

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Diff for: big_tests/tests/component_SUITE.erl

+20-16
Original file line numberDiff line numberDiff line change
@@ -113,30 +113,26 @@ register_one_component(Config) ->
113113
CheckServer = fun(#{lserver := S}) -> S =:= ComponentAddr end,
114114

115115
%% Expect events for handshake, but not for 'start stream'.
116-
instrument_helper:assert(xmpp_element_size_out, #{connection_type => component}, FullCheckF,
116+
instrument_helper:assert(xmpp_element_out, ht_labels(), FullCheckF,
117117
#{expected_count => 1, min_timestamp => TS}),
118-
instrument_helper:assert(xmpp_element_size_in, #{connection_type => component}, FullCheckF,
118+
instrument_helper:assert(xmpp_element_in, ht_labels(), FullCheckF,
119119
#{expected_count => 1, min_timestamp => TS}),
120120

121121
instrument_helper:assert(component_auth_failed, #{}, FullCheckF,
122122
#{expected_count => 0, min_timestamp => TS}),
123-
instrument_helper:assert(tcp_data_in, #{connection_type => component}, CheckBytes,
123+
instrument_helper:assert(tcp_data_in, labels(), CheckBytes,
124124
#{min_timestamp => TS}),
125-
instrument_helper:assert(tcp_data_out, #{connection_type => component}, CheckBytes,
125+
instrument_helper:assert(tcp_data_out, labels(), CheckBytes,
126126
#{min_timestamp => TS}),
127127

128128
TS1 = instrument_helper:timestamp(),
129129
verify_component(Config, Component, ComponentAddr),
130130

131131
% Message from Alice
132-
instrument_helper:assert(xmpp_element_size_out, #{connection_type => component}, FullCheckF,
132+
instrument_helper:assert(xmpp_element_out, ht_labels(), FullCheckF,
133133
#{expected_count => 1, min_timestamp => TS1}),
134134
% Reply to Alice
135-
instrument_helper:assert(xmpp_element_size_in, #{connection_type => component}, FullCheckF,
136-
#{expected_count => 1, min_timestamp => TS1}),
137-
instrument_helper:assert(component_element_in, #{}, CheckServer,
138-
#{expected_count => 1, min_timestamp => TS1}),
139-
instrument_helper:assert(component_element_out, #{}, CheckServer,
135+
instrument_helper:assert(xmpp_element_in, ht_labels(), FullCheckF,
140136
#{expected_count => 1, min_timestamp => TS1}),
141137

142138
component_helper:disconnect_component(Component, ComponentAddr).
@@ -151,9 +147,9 @@ register_one_component_tls(Config) ->
151147
end,
152148
CheckBytes = fun(#{byte_size := S}) -> S > 0 end,
153149
CheckServer = fun(#{lserver := S}) -> S =:= ComponentAddr end,
154-
instrument_helper:assert(tls_data_in, #{connection_type => component}, CheckBytes,
150+
instrument_helper:assert(tls_data_in, labels(), CheckBytes,
155151
#{min_timestamp => TS}),
156-
instrument_helper:assert(tls_data_out, #{connection_type => component}, CheckBytes,
152+
instrument_helper:assert(tls_data_out, labels(), CheckBytes,
157153
#{min_timestamp => TS}),
158154

159155
TS1 = instrument_helper:timestamp(),
@@ -187,9 +183,9 @@ intercomponent_communication(Config) ->
187183
FullCheckF = fun(#{byte_size := S, lserver := LServer}) ->
188184
S > 0 andalso LServer =:= CompAddr1 orelse LServer =:= CompAddr2
189185
end,
190-
instrument_helper:assert(xmpp_element_size_out, #{connection_type => component}, FullCheckF,
186+
instrument_helper:assert(xmpp_element_out, ht_labels(), FullCheckF,
191187
#{expected_count => 1, min_timestamp => TS}),
192-
instrument_helper:assert(xmpp_element_size_in, #{connection_type => component}, FullCheckF,
188+
instrument_helper:assert(xmpp_element_in, ht_labels(), FullCheckF,
193189
#{expected_count => 1, min_timestamp => TS}),
194190

195191
component_helper:disconnect_component(Comp1, CompAddr1),
@@ -241,10 +237,10 @@ register_two_components(Config) ->
241237
S > 0 andalso LServer =:= CompAddr1 orelse LServer =:= CompAddr2
242238
end,
243239
% Msg to Alice, msg to Bob
244-
instrument_helper:assert(xmpp_element_size_in, #{connection_type => component}, FullCheckF,
240+
instrument_helper:assert(xmpp_element_in, ht_labels(), FullCheckF,
245241
#{expected_count => 2, min_timestamp => TS}),
246242
% Msg from Bob, msg from Alice
247-
instrument_helper:assert(xmpp_element_size_out, #{connection_type => component}, FullCheckF,
243+
instrument_helper:assert(xmpp_element_out, ht_labels(), FullCheckF,
248244
#{expected_count => 2, min_timestamp => TS}),
249245

250246
component_helper:disconnect_component(Comp1, CompAddr1),
@@ -591,6 +587,14 @@ restore_domain(Config) ->
591587
events() ->
592588
instrument_helper:declared_events(mongoose_component_listener, [#{}]).
593589

590+
%% Data metrics have only the connection_type label
591+
labels() ->
592+
#{connection_type => component}.
593+
594+
%% XMPP element metric labels include host_type, but components don't have host types
595+
ht_labels() ->
596+
(labels())#{host_type => <<>>}.
597+
594598
%%--------------------------------------------------------------------
595599
%% Stanzas
596600
%%--------------------------------------------------------------------

0 commit comments

Comments
 (0)