From c8a80e4443254016f0cbcbdb2afb0d017097a438 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 3 Mar 2020 16:12:48 +0100 Subject: WIP: Introduce ttcn3-ergw-test Change-Id: Ic93220c6afaddb7edd7502f65c9c1c7690a6e365 --- ttcn3-ergw-test/Dockerfile | 31 ++++++ ttcn3-ergw-test/GGSN_Tests.cfg | 24 +++++ ttcn3-ergw-test/Makefile | 1 + ttcn3-ergw-test/ergw/sys.config | 215 +++++++++++++++++++++++++++++++++++++++ ttcn3-ergw-test/jenkins.sh | 65 ++++++++++++ ttcn3-ergw-test/vpp/init.conf | 34 +++++++ ttcn3-ergw-test/vpp/startup.conf | 24 +++++ 7 files changed, 394 insertions(+) create mode 100644 ttcn3-ergw-test/Dockerfile create mode 100644 ttcn3-ergw-test/GGSN_Tests.cfg create mode 100644 ttcn3-ergw-test/Makefile create mode 100644 ttcn3-ergw-test/ergw/sys.config create mode 100755 ttcn3-ergw-test/jenkins.sh create mode 100644 ttcn3-ergw-test/vpp/init.conf create mode 100644 ttcn3-ergw-test/vpp/startup.conf diff --git a/ttcn3-ergw-test/Dockerfile b/ttcn3-ergw-test/Dockerfile new file mode 100644 index 0000000..7e88f28 --- /dev/null +++ b/ttcn3-ergw-test/Dockerfile @@ -0,0 +1,31 @@ +ARG USER +FROM $USER/debian-stretch-titan + +RUN git clone git://git.osmocom.org/osmo-ttcn3-hacks.git + +RUN cd osmo-ttcn3-hacks && \ + git checkout -f -B master origin/master && \ + make deps + +ARG OSMO_TTCN3_BRANCH="master" + +ADD http://git.osmocom.org/osmo-ttcn3-hacks/patch?h=$OSMO_TTCN3_BRANCH /tmp/commit +RUN cd osmo-ttcn3-hacks && \ + git fetch && \ + git checkout $OSMO_TTCN3_BRANCH && \ + (git symbolic-ref -q HEAD && git reset --hard origin/$OSMO_TTCN3_BRANCH || exit 1); \ + git rev-parse --abbrev-ref HEAD && git rev-parse HEAD && \ + make ggsn_tests + +VOLUME /data + +RUN ln -s /osmo-ttcn3-hacks/ttcn3-tcpdump-start.sh / && \ + ln -s /osmo-ttcn3-hacks/ttcn3-tcpdump-stop.sh / + +COPY GGSN_Tests.cfg /data/GGSN_Tests.cfg + +CMD cd /data && \ + /osmo-ttcn3-hacks/start-testsuite.sh /osmo-ttcn3-hacks/ggsn_tests/GGSN_Tests; \ + exit_code=$?; \ + /osmo-ttcn3-hacks/log_merge.sh GGSN_Tests --rm; \ + exit $exit_code diff --git a/ttcn3-ergw-test/GGSN_Tests.cfg b/ttcn3-ergw-test/GGSN_Tests.cfg new file mode 100644 index 0000000..49a14b0 --- /dev/null +++ b/ttcn3-ergw-test/GGSN_Tests.cfg @@ -0,0 +1,24 @@ +[ORDERED_INCLUDE] +"/osmo-ttcn3-hacks/Common.cfg" +"/osmo-ttcn3-hacks/ggsn_tests/GGSN_Tests.default" + +[LOGGING] +*.JUnitLogger.testsuite_name := "GGSN_Tests" + +[TESTPORT_PARAMETERS] +*.GGSNVTY.CTRL_HOSTNAME := "172.21.16.202" + +[MODULE_PARAMETERS] +# our Own IP address +GGSN_Tests.m_bind_ip_gtpc := "172.21.16.202" +GGSN_Tests.m_bind_ip_gtpu := "172.21.16.202" +# GGSN IP address +GGSN_Tests.m_ggsn_ip_gtpc := "172.21.16.2" +GGSN_Tests.m_ggsn_ip_gtpu := "172.21.16.28" +# GGSN announced DNS address +GGSN_Tests.m_ggsn_ip4_dns1 := "8.8.8.8" +GGSN_Tests.m_have_vty := false + +[EXECUTE] +#GGSN_Tests.control +GGSN_Tests.TC_pdp4_act_deact diff --git a/ttcn3-ergw-test/Makefile b/ttcn3-ergw-test/Makefile new file mode 100644 index 0000000..8d0e10b --- /dev/null +++ b/ttcn3-ergw-test/Makefile @@ -0,0 +1 @@ +include ../make/Makefile diff --git a/ttcn3-ergw-test/ergw/sys.config b/ttcn3-ergw-test/ergw/sys.config new file mode 100644 index 0000000..cae5c58 --- /dev/null +++ b/ttcn3-ergw-test/ergw/sys.config @@ -0,0 +1,215 @@ +%-*-Erlang-*- +[{setup, [{data_dir, "/var/lib/ergw"}, + {log_dir, "/data/"} %% NOTE: lager is not using this + ]}, + + {kernel, + [{logger_level, debug}, + {logger, + [{handler, default, logger_std_h, + #{level => debug, + formatter => + {logger_formatter, + #{single_line => true, + legacy_header => false, + template => [time," ",pid," ",level,": ",msg,"\n"] + }}, + config => + #{sync_mode_qlen => 10000, + drop_mode_qlen => 10000, + flush_qlen => 10000} + } + } + ]} + ]}, + + {ergw, [{'$setup_vars', + [{"ORIGIN", {value, "epc.mnc001.mcc001.3gppnetwork.org"}}]}, + {http_api, + [{port, 8080}, + {ip, {0,0,0,0}} + ]}, + {sockets, + [{'cp-socket', + [{type, 'gtp-u'}, + {vrf, cp}, + {ip, {172,21,16,2}}, + freebind, + {reuseaddr, true} + ]}, + {irx, [{type, 'gtp-c'}, + {vrf, epc}, + {ip, {172,21,16,2}}, + {reuseaddr, true} + ]} + ]}, + + {ip_pools, + [{'SGi', [{ranges, [{{10, 106, 0, 1}, {10, 106, 255, 254}, 32}, + {{16#8001, 0, 0, 0, 0, 0, 0, 0}, + {16#8001, 0, 0, 16#FFFF, 0, 0, 0, 0}, 64} + ]}, + {'MS-Primary-DNS-Server', {8,8,8,8}}, + {'MS-Secondary-DNS-Server', {8,8,4,4}}, + {'MS-Primary-NBNS-Server', {127,0,0,1}}, + {'MS-Secondary-NBNS-Server', {127,0,0,1}} + ]} + ]}, + + {sx_socket, + [{node, 'ergw'}, + {name, 'ergw'}, + {socket, 'cp-socket'}, + {ip, {172,21,16,2}}, + {reuseaddr, true}, + freebind + ]}, + + {handlers, + [{'h1', [{handler, pgw_s5s8}, + {protocol, gn}, + {sockets, [irx]}, + {node_selection, [default]} + ]}, + {'h2', [{handler, pgw_s5s8}, + {protocol, s5s8}, + {sockets, [irx]}, + {node_selection, [default]} + ]} + ]}, + + {apns, + [{'_', [{vrf, sgi}, {ip_pools, ['SGi']}]}]}, + + {node_selection, + [{default, + {static, + [ + %% APN NAPTR alternative + {"_default.apn.$ORIGIN", {300,64536}, + [{"x-3gpp-pgw","x-s5-gtp"},{"x-3gpp-pgw","x-s8-gtp"}, + {"x-3gpp-pgw","x-gn"},{"x-3gpp-pgw","x-gp"}], + "topon.s5s8.pgw.$ORIGIN"}, + {"_default.apn.$ORIGIN", {300,64536}, + [{"x-3gpp-upf","x-sxb"}], + "topon.sx.prox01.$ORIGIN"}, + + %% A/AAAA record alternatives + {"topon.s5s8.pgw.$ORIGIN", [{172, 21, 16, 2}], []}, + {"topon.sx.prox01.$ORIGIN", [{172,21,16,3}], []} + ] + } + } + ] + }, + + {charging, + [{default, + [{rulebase, + [{<<"r-0001">>, + #{'Rating-Group' => [3000], + 'Flow-Information' => + [#{'Flow-Description' => [<<"permit out ip from any to assigned">>], + 'Flow-Direction' => [1] %% DownLink + }, + #{'Flow-Description' => [<<"permit out ip from any to assigned">>], + 'Flow-Direction' => [2] %% UpLink + }], + 'Metering-Method' => [1], + 'Precedence' => [100], + 'Online' => [0], + 'Offline' => [0] + }}, + {<<"m2m0001">>, [<<"r-0001">>]} + ]} + ]} + ]}, + + {nodes, + [{default, + [{vrfs, + [{cp, [{features, ['CP-Function']}]}, + {epc, [{features, ['Access']}]}, + {sgi, [{features, ['SGi-LAN']}]}] + }, + {ip_pools, ['SGi']} + ]}, + {"topon.sx.prox01.$ORIGIN", [connect]} + ] + } + ]}, + + {ergw_aaa, + [{handlers, + [{ergw_aaa_static, + [{'NAS-Identifier', <<"NAS-Identifier">>}, + {'Framed-Protocol', 'PPP'}, + {'Service-Type', 'Framed-User'}, + {'Node-Id', <<"PGW-001">>}, + {'Charging-Rule-Base-Name', <<"m2m0001">>} + %% {'Offline-Charging-Profile', + %% #{'Default' => #{'Tariff-Time' => {13, 20}}}} + ]} + ]}, + + {services, + [{'Default', [{handler, 'ergw_aaa_static'}, + {answers, + #{'Initial-Gx' => + #{'Result-Code' => 2001, + 'Charging-Rule-Install' => + [#{'Charging-Rule-Base-Name' => [<<"m2m0001">>]}] + }, + 'Update-Gx' => #{'Result-Code' => 2001}, + 'Final-Gx' => #{'Result-Code' => 2001} + } + } + ]} + ]}, + + {apps, + [{default, + [{session, ['Default']}, + {procedures, [{authenticate, []}, + {authorize, []}, + {start, []}, + {interim, []}, + {stop, []}, + + {{gx, 'CCR-Initial'}, [{'Default', [{answer, 'Initial-Gx'}]}]}, + {{gx, 'CCR-Update'}, [{'Default', [{answer, 'Update-Gx'}]}]}, + {{gx, 'CCR-Terminate'}, [{'Default', [{answer, 'Final-Gx'}]}]} + ]} + ]} + ]} + ]}, + + {hackney, [ + {mod_metrics, exometer} + ]}, + + {jobs, [{samplers, + [{cpu_feedback, jobs_sampler_cpu, []} + ]}, + {queues, + [{path_restart, + [{regulators, [{counter, [{limit, 100}]}]}, + {modifiers, [{cpu_feedback, 10}]} %% 10 = % increment by which to modify the limit + ]}, + {create, + [{max_time, 5000}, %% max 5 seconds + {regulators, [{rate, [{limit, 100}]}]}, + {modifiers, [{cpu_feedback, 10}]} %% 10 = % increment by which to modify the limit + ]}, + {delete, + [{regulators, [{counter, [{limit, 100}]}]}, + {modifiers, [{cpu_feedback, 10}]} %% 10 = % increment by which to modify the limit + ]}, + {other, + [{max_time, 10000}, %% max 10 seconds + {regulators, [{rate, [{limit, 1000}]}]}, + {modifiers, [{cpu_feedback, 10}]} %% 10 = % increment by which to modify the limit + ]} + ]} + ]} +]. diff --git a/ttcn3-ergw-test/jenkins.sh b/ttcn3-ergw-test/jenkins.sh new file mode 100755 index 0000000..aeae12b --- /dev/null +++ b/ttcn3-ergw-test/jenkins.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +. ../jenkins-common.sh +IMAGE_SUFFIX="${IMAGE_SUFFIX:-master}" +docker_images_require \ + "debian-stretch-build" \ + "osmo-ggsn-$IMAGE_SUFFIX" \ + "debian-stretch-titan" \ + "ttcn3-ggsn-test" + +mkdir $VOL_BASE_DIR/ggsn-tester +cp GGSN_Tests.cfg $VOL_BASE_DIR/ggsn-tester/ + +mkdir $VOL_BASE_DIR/vpp +cp vpp/init.conf $VOL_BASE_DIR/vpp/ +cp vpp/startup.conf $VOL_BASE_DIR/vpp/ + +mkdir $VOL_BASE_DIR/ergw +cp ergw/sys.config $VOL_BASE_DIR/ergw/ + +network_create 172.21.16.0/24 + +# start container with upf in background +docker run --cap-add=NET_ADMIN \ + --device /dev/net/tun:/dev/net/tun \ + --sysctl net.ipv6.conf.all.disable_ipv6=0 \ + --rm \ + --network $NET_NAME --ip 172.21.16.3 \ + -v $VOL_BASE_DIR/vpp:/data \ + --name ${BUILD_TAG}-vpp -d \ + --entrypoint="" \ + quay.io/travelping/upf:feature-2001-upf_v20.01-141-g6864fd594_debug \ + /bin/sh -c "/usr/bin/vpp -c /data/startup.conf >/data/vpp_console.log 2>&1" + +# start container with ergw in background +docker run --cap-add=NET_ADMIN \ + --device /dev/net/tun:/dev/net/tun \ + --sysctl net.ipv6.conf.all.disable_ipv6=0 \ + --rm \ + --network $NET_NAME --ip 172.21.16.2 \ + -v $VOL_BASE_DIR/ergw:/config/ergw-c-node \ + -v $VOL_BASE_DIR/ergw:/data \ + --name ${BUILD_TAG}-ergw -d \ + --entrypoint="" \ + quay.io/travelping/ergw-c-node:master_2.2.0-52-g53265c1 \ + /bin/sh -c "/docker-entrypoint.sh /opt/ergw-c-node/bin/ergw-c-node foreground >/data/ergw_console.log 2>&1" + +echo "Press something to continue:" +read line + +# start docker container with testsuite in foreground +docker run --rm \ + --sysctl net.ipv6.conf.all.disable_ipv6=0 \ + --network $NET_NAME --ip 172.21.16.202 \ + -v $VOL_BASE_DIR/ggsn-tester:/data \ + -e "TTCN3_PCAP_PATH=/data" \ + --name ${BUILD_TAG}-ggsn-test \ + $REPO_USER/ttcn3-ggsn-test + +# stop processes after test has completed +docker container stop ${BUILD_TAG}-ergw +docker container stop ${BUILD_TAG}-vpp + +network_remove +collect_logs diff --git a/ttcn3-ergw-test/vpp/init.conf b/ttcn3-ergw-test/vpp/init.conf new file mode 100644 index 0000000..3d33a5c --- /dev/null +++ b/ttcn3-ergw-test/vpp/init.conf @@ -0,0 +1,34 @@ +ip table add 1 +ip table add 2 +ip6 table add 1 +ip6 table add 2 + +create host-interface name ens224 +set interface mac address host-ens224 00:0c:29:46:1f:53 +set interface ip table host-ens224 1 +set interface ip6 table host-ens224 1 +set interface ip address host-ens224 172.20.16.105/24 +set interface state host-ens224 up + +create host-interface name ens161 +set interface mac address host-ens161 00:50:56:86:ed:f9 +set interface ip table host-ens161 2 +set interface ip6 table host-ens161 2 +set interface ip address host-ens161 172.20.16.106/24 +set interface state host-ens161 up + +create host-interface name sxb-u +set interface mac address host-sxb-u 02:fe:f5:6f:45:72 +set int ip address host-sxb-u 172.21.16.3/24 +set int state host-sxb-u up + +ip route add 0.0.0.0/0 table 2 via 172.21.16.3 host-ens161 + +upf pfcp endpoint ip 172.21.16.3 vrf 0 + +upf nwi name cp vrf 0 +upf nwi name epc vrf 1 +upf nwi name sgi vrf 2 + +upf gtpu endpoint ip 172.21.16.3 nwi cp teid 0x80000000/2 +upf gtpu endpoint ip 172.20.16.105 nwi epc teid 0x80000000/2 diff --git a/ttcn3-ergw-test/vpp/startup.conf b/ttcn3-ergw-test/vpp/startup.conf new file mode 100644 index 0000000..b2f32a7 --- /dev/null +++ b/ttcn3-ergw-test/vpp/startup.conf @@ -0,0 +1,24 @@ +unix { + nodaemon + log /data/vpp.log + full-coredump + gid vpp + interactive + cli-listen localhost:5002 + exec /data/init.conf +} + +api-trace { + on +} + +api-segment { + gid vpp +} + +plugins { + path /usr/lib/x86_64-linux-gnu/vpp_plugins/ + plugin dpdk_plugin.so { disable } + plugin gtpu_plugin.so { disable } + plugin upf_plugin.so { enable } +} -- cgit v1.2.3