Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mtproto_proxy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mtproto_proxy
Commits
e9471b25
Unverified
Commit
e9471b25
authored
Mar 07, 2019
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Make it possible to block until metric value will match predicate
parent
9a735bf9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
mtp_test_client.erl
test/mtp_test_client.erl
+2
-2
mtp_test_metric.erl
test/mtp_test_metric.erl
+26
-1
No files found.
test/mtp_test_client.erl
View file @
e9471b25
...
...
@@ -63,7 +63,7 @@ recv_packet_inner(#client{sock = Sock, codec = Codec0} = Client, Timeout) ->
recv_all
(
#client
{
sock
=
Sock
,
codec
=
Codec0
}
=
Client
,
Timeout
)
->
case
tcp_recv_all
(
Sock
,
Timeout
)
of
{
ok
,
Stream
}
->
io
:
format
(
"
~p
:
~p~n
"
,
[
byte_size
(
Stream
),
Stream
]),
%%
io:format("~p: ~p~n", [byte_size(Stream), Stream]),
{
ok
,
Packets
,
Codec
}
=
mtp_codec
:
fold_packets
(
fun
(
Packet
,
Acc
,
Codec
)
->
...
...
@@ -79,7 +79,7 @@ recv_all(#client{sock = Sock, codec = Codec0} = Client, Timeout) ->
end
.
tcp_recv_all
(
Sock
,
Timeout
)
->
io
:
format
(
"Sock:
~p
; Timeout:
~p~n~n~n
"
,
[
Sock
,
Timeout
]),
%%
io:format("Sock: ~p; Timeout: ~p~n~n~n", [Sock, Timeout]),
case
gen_tcp
:
recv
(
Sock
,
0
,
Timeout
)
of
{
ok
,
Stream
}
->
tcp_recv_all_inner
(
Sock
,
Stream
);
...
...
test/mtp_test_metric.erl
View file @
e9471b25
...
...
@@ -9,7 +9,9 @@
-
export
([
notify
/
4
]).
-
export
([
get
/
2
,
get
/
3
,
get_tags
/
3
]).
get_tags
/
3
,
wait_for_value
/
5
,
wait_for
/
5
]).
%% gen_server callbacks
-
export
([
init
/
1
,
handle_call
/
3
,
handle_cast
/
2
,
handle_info
/
2
,
...
...
@@ -37,6 +39,29 @@ get(Type, Name, Extra) ->
get_tags
(
Type
,
Name
,
Tags
)
->
get
(
Type
,
Name
,
#
{
labels
=>
Tags
}).
wait_for_value
(
Type
,
Name
,
Tags
,
Value
,
Timeout
)
->
Now
=
erlang
:
monotonic_time
(
millisecond
),
Test
=
fun
(
Current
)
->
Current
==
Value
end
,
wait_for_till
(
Type
,
Name
,
#
{
labels
=>
Tags
},
Test
,
Now
+
Timeout
).
wait_for
(
Type
,
Name
,
Tags
,
Test
,
Timeout
)
->
Now
=
erlang
:
monotonic_time
(
millisecond
),
wait_for_till
(
Type
,
Name
,
#
{
labels
=>
Tags
},
Test
,
Now
+
Timeout
).
wait_for_till
(
Type
,
Name
,
Extra
,
Test
,
Deadline
)
->
case
Test
(
get
(
Type
,
Name
,
Extra
))
of
true
->
ok
;
false
->
Now
=
erlang
:
monotonic_time
(
millisecond
),
case
Now
>=
Deadline
of
true
->
timeout
;
false
->
timer
:
sleep
(
10
),
wait_for_till
(
Type
,
Name
,
Extra
,
Test
,
Deadline
)
end
end
.
init
([])
->
{
ok
,
#state
{}}.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment