Skip to content

Commit

Permalink
Add miss test case of proxy_lib_SUITE
Browse files Browse the repository at this point in the history
Added missing test case in proxy_lib_SUITE and updated configuration for correct checking of ergw_proxy_lib:choose_gw/4 function
  • Loading branch information
vkatsuba authored and RoadRunnr committed Nov 27, 2020
1 parent 0c0f774 commit 1f1b221
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ergw_proxy_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ get_seq_no(#tunnel{socket = Socket}, ReqKey, Request) ->
ergw_gtp_c_socket:get_seq_no(Socket, ReqId).

%% choose_gw/4
choose_gw([], _NodeSelect, _Version, _Socket) ->
choose_gw([], _NodeSelect, _Version, #socket{}) ->
{error, ?CTX_ERR(?FATAL, no_resources_available)};
choose_gw(Nodes, NodeSelect, Version, #socket{name = Name} = Socket) ->
{Candidate, Next} = ergw_node_selection:snaptr_candidate(Nodes),
Expand All @@ -71,7 +71,7 @@ choose_gw(Nodes, NodeSelect, Version, #socket{name = Name} = Socket) ->
select_gw(#{imsi := IMSI, gwSelectionAPN := APN}, Version, Services, NodeSelect, Socket) ->
FQDN = ergw_node_selection:apn_to_fqdn(APN, IMSI),
case ergw_node_selection:candidates(FQDN, Services, NodeSelect) of
Nodes when is_list(Nodes), length(Nodes) /= 0 ->
[_|_] = Nodes ->
choose_gw(Nodes, NodeSelect, Version, Socket);
_ ->
{error, ?CTX_ERR(?FATAL, system_failure)}
Expand Down
9 changes: 9 additions & 0 deletions test/proxy_lib_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
{static,
[
%% APN NAPTR alternative
{"web.apn.epc.mnc001.mcc001.3gppnetwork.org", {0,0},
[{"x-3gpp-pgw","x-s5-gtp"},{"x-3gpp-pgw","x-s8-gtp"},
{"x-3gpp-pgw","x-gn"},{"x-3gpp-pgw","x-gp"}],
?'CP-Node'},
{"web.apn.epc.mnc001.mcc001.3gppnetwork.org", {300,64536},
[{"x-3gpp-pgw","x-s5-gtp"},{"x-3gpp-pgw","x-s8-gtp"},
{"x-3gpp-pgw","x-gn"},{"x-3gpp-pgw","x-gp"}],
Expand Down Expand Up @@ -128,6 +132,11 @@ proxy_lookup(_Config) ->
PI7 = PI#{gwSelectionAPN => apn(<<"web.mnc567.mcc001.gprs">>)},
{error, Proxy7} = ergw_proxy_lib:select_gw(PI7, v1, ?SERVICES, NodeSelect, Socket),
?match(#ctx_err{level = ?FATAL, reply = system_failure}, Proxy7),

PI8 = PI#{gwSelectionAPN => apn(<<"web.apn.epc.mnc001.mcc001.3gppnetwork.org">>)},
ok = gtp_path_reg:register({<<"TEST">>, v1, ?'CP-IP'}, down),
{error, Proxy8} = ergw_proxy_lib:select_gw(PI8, v1, ?SERVICES, NodeSelect, Socket),
?match(#ctx_err{level = ?FATAL, reply = no_resources_available}, Proxy8),
ok.

apn(Bin) ->
Expand Down

0 comments on commit 1f1b221

Please sign in to comment.