Skip to content

Commit

Permalink
CT: make IPv4 pool size configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
RoadRunnr committed Dec 9, 2020
1 parent 1455d3c commit 40ec096
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
7 changes: 5 additions & 2 deletions test/ergw_test_lib.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@
-define('IMEISV', <<"3520990017614823">>). %% found on wikipedia

-define(IPv4PoolStart, {10, 180, 0, 1}).
-define(IPv4PoolEnd, {10, 180, 255, 254}).
%%-define(IPv4PoolEnd, {10, 180, 255, 254}).
-define(IPv4PoolEnd, {10, 187, 255, 254}).
-define(IPv4StaticIP, {10, 180, 128, 128}).
%%-define(IPv4PoolSize, 65534).
-define(IPv4PoolSize, 524286).

-define(IPv6PoolStart, {16#8001, 0, 1, 0, 0, 0, 0, 0}).
-define(IPv6PoolEnd, {16#8001, 0, 1, 16#FFFF, 16#FFFF, 16#FFFF, 16#FFFF, 16#FFFF}).
-define(IPv6PoolEnd, {16#8001, 0, 7, 16#FFFF, 16#FFFF, 16#FFFF, 16#FFFF, 16#FFFF}).
-define(IPv6StaticIP, {16#8001, 0, 1, 16#0180, 1, 2, 3, 4}).

%% for non-standard /128 assigments
Expand Down
20 changes: 10 additions & 10 deletions test/ggsn_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ end_per_testcase(Config) ->
stop_gtpc_server(),

PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),

AppsCfg = proplists:get_value(aaa_cfg, Config),
ok = application:set_env(ergw_aaa, apps, AppsCfg),
Expand Down Expand Up @@ -766,7 +766,7 @@ create_pdp_context_request_gy_fail() ->
create_pdp_context_request_gy_fail(Config) ->
PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

MetricsBefore = socket_counter_metrics(),
Expand All @@ -779,7 +779,7 @@ create_pdp_context_request_gy_fail(Config) ->
ok = meck:wait(?HUT, terminate, '_', ?TIMEOUT),
wait4contexts(?TIMEOUT),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

socket_counter_metrics_ok(MetricsBefore, MetricsAfter, create_pdp_context_request),
Expand Down Expand Up @@ -1009,14 +1009,14 @@ simple_pdp_context_request() ->
simple_pdp_context_request(Config) ->
PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

MetricsBefore = socket_counter_metrics(),
{GtpC, _, _} = create_pdp_context(Config),
MetricsAfter = socket_counter_metrics(),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65533),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize - 1),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 1),

delete_pdp_context(GtpC),
Expand All @@ -1031,7 +1031,7 @@ simple_pdp_context_request(Config) ->
socket_counter_metrics_ok(MetricsBefore, MetricsAfter, create_pdp_context_request),
socket_counter_metrics_ok(MetricsBefore, MetricsAfter, request_accepted), % In response

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

meck_validate(Config),
Expand Down Expand Up @@ -1605,8 +1605,8 @@ session_options(Config) ->
'Password' => '_',

'PDP-Context-Type' => primary,
'Framed-IP-Address' => {10, 180, '_', '_'},
'Framed-IPv6-Prefix' => {{16#8001, 0, 1, '_', '_', '_', '_', '_'},64},
'Framed-IP-Address' => {10, '_', '_', '_'},
'Framed-IPv6-Prefix' => {{16#8001, 0, '_', '_', '_', '_', '_', '_'},64},

'Charging-Rule-Base-Name' => <<"m2m0001">>,

Expand Down Expand Up @@ -2087,8 +2087,8 @@ simple_ocs(Config) ->
'Diameter-Session-Id' => '_',
%% 'ECGI' => '?????',
%% 'Event-Trigger' => '?????',
'Framed-IP-Address' => {10, 180, '_', '_'},
'Framed-IPv6-Prefix' => {{16#8001, 0, 1, '_', '_', '_', '_', '_'},64},
'Framed-IP-Address' => {10, '_', '_', '_'},
'Framed-IPv6-Prefix' => {{16#8001, 0, '_', '_', '_', '_', '_', '_'},64},
'Framed-Protocol' => 'GPRS-PDP-Context',
'Multi-Session-Id' => '_',
'NAS-Identifier' => <<"NAS-Identifier">>,
Expand Down
26 changes: 13 additions & 13 deletions test/pgw_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ end_per_testcase(Config) ->
stop_gtpc_server(),

PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),

AppsCfg = proplists:get_value(aaa_cfg, Config),
ok = application:set_env(ergw_aaa, apps, AppsCfg),
Expand Down Expand Up @@ -1067,15 +1067,15 @@ create_session_request_gy_fail() ->
create_session_request_gy_fail(Config) ->
PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

create_session(gy_fail, Config),

ok = meck:wait(?HUT, terminate, '_', ?TIMEOUT),
wait4contexts(?TIMEOUT),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

meck_validate(Config),
Expand Down Expand Up @@ -1327,12 +1327,12 @@ simple_session_request() ->
simple_session_request(Config) ->
PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

{GtpC, _, _} = create_session(ipv4, Config),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65533),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize - 1),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 1),

delete_session(GtpC),
Expand All @@ -1342,7 +1342,7 @@ simple_session_request(Config) ->
ok = meck:wait(?HUT, terminate, '_', ?TIMEOUT),
wait4contexts(?TIMEOUT),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

[SER|_] = lists:filter(
Expand Down Expand Up @@ -1477,20 +1477,20 @@ simple_session_request_cp_teid() ->
simple_session_request_cp_teid(Config) ->
PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

{GtpC, _, _} = create_session(ipv4, Config),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65533),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize - 1),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 1),

delete_session(GtpC),

?equal([], outstanding_requests()),
ok = meck:wait(?HUT, terminate, '_', ?TIMEOUT),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

[SER|_] = lists:filter(
Expand Down Expand Up @@ -2454,8 +2454,8 @@ session_options(Config) ->
'Password' => '_',

%% TODO check 'PDP-Context-Type' => primary,
'Framed-IP-Address' => {10, 180, '_', '_'},
'Framed-IPv6-Prefix' => {{16#8001, 0, 1, '_', '_', '_', '_', '_'},64},
'Framed-IP-Address' => {10, '_', '_', '_'},
'Framed-IPv6-Prefix' => {{16#8001, 0, '_', '_', '_', '_', '_', '_'},64},
'Framed-Pool' => <<"pool-A">>,
'Framed-IPv6-Pool' => <<"pool-A">>,

Expand Down Expand Up @@ -3366,8 +3366,8 @@ simple_ocs(Config) ->
'Diameter-Session-Id' => '_',
'ECGI' => '_',
'Event-Trigger' => '_',
'Framed-IP-Address' => {10, 180, '_', '_'},
%% 'Framed-IPv6-Prefix' => {{16#8001, 0, 1, '_', '_', '_', '_', '_'},64},
'Framed-IP-Address' => {10, '_', '_', '_'},
%% 'Framed-IPv6-Prefix' => {{16#8001, 0, '_', '_', '_', '_', '_', '_'},64},
'Framed-Protocol' => 'GPRS-PDP-Context',
'Multi-Session-Id' => '_',
'NAS-Identifier' => '_',
Expand Down
20 changes: 10 additions & 10 deletions test/saegw_s11_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ end_per_testcase(Config) ->
stop_gtpc_server(),

PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),

AppsCfg = proplists:get_value(aaa_cfg, Config),
ok = application:set_env(ergw_aaa, apps, AppsCfg),
Expand Down Expand Up @@ -654,14 +654,14 @@ create_session_request_gy_fail() ->
create_session_request_gy_fail(Config) ->
PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

create_session(gy_fail, Config),

ok = meck:wait(?HUT, terminate, '_', ?TIMEOUT),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

meck_validate(Config),
Expand Down Expand Up @@ -743,12 +743,12 @@ simple_session_request() ->
simple_session_request(Config) ->
PoolId = [<<"pool-A">>, ipv4, "10.180.0.1"],

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

{GtpC1, _, _} = create_session(Config),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65533),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize - 1),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 1),

{GtpC2, _, _} = modify_bearer(enb_u_tei, GtpC1),
Expand All @@ -757,7 +757,7 @@ simple_session_request(Config) ->
?equal([], outstanding_requests()),
ok = meck:wait(?HUT, terminate, '_', ?TIMEOUT),

?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, 65534),
?match_metric(prometheus_gauge, ergw_local_pool_free, PoolId, ?IPv4PoolSize),
?match_metric(prometheus_gauge, ergw_local_pool_used, PoolId, 0),

meck_validate(Config),
Expand Down Expand Up @@ -1151,8 +1151,8 @@ session_options(Config) ->
'Password' => '_',

%% TODO check 'PDP-Context-Type' => primary,
'Framed-IP-Address' => {10, 180, '_', '_'},
'Framed-IPv6-Prefix' => {{16#8001, 0, 1, '_', '_', '_', '_', '_'},64},
'Framed-IP-Address' => {10, '_', '_', '_'},
'Framed-IPv6-Prefix' => {{16#8001, 0, '_', '_', '_', '_', '_', '_'},64},

'Charging-Rule-Base-Name' => <<"m2m0001">>,

Expand Down Expand Up @@ -1604,8 +1604,8 @@ simple_ocs(Config) ->
'Diameter-Session-Id' => '_',
'ECGI' => '_',
'Event-Trigger' => '_',
'Framed-IP-Address' => {10, 180, '_', '_'},
%% 'Framed-IPv6-Prefix' => {{16#8001, 0, 1, '_', '_', '_', '_', '_'},64},
'Framed-IP-Address' => {10, '_', '_', '_'},
%% 'Framed-IPv6-Prefix' => {{16#8001, 0, '_', '_', '_', '_', '_', '_'},64},
'Framed-Protocol' => 'GPRS-PDP-Context',
'Multi-Session-Id' => '_',
'NAS-Identifier' => '_',
Expand Down

0 comments on commit 40ec096

Please sign in to comment.