osmith has submitted this change. (
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40321?usp=email )
Change subject: epdg: initial testenv.cfg
......................................................................
epdg: initial testenv.cfg
With this config, all tests are passing.
Depends: osmo-ci Ia60d5c1f5ade31e37293b40340e789f04ea86287
Change-Id: Ide2873be7830cc43e7fa09f26b2d504d0563a3c2
---
M epdg/EPDG_Tests.cfg
A epdg/osmo-epdg.config
A epdg/testenv.cfg
A epdg/testenv/run_osmo_epdg_with_dummy_ue.sh
A epdg/testenv/run_qemu.sh
A epdg/testenv/wait_until_osmo_epdg_is_ready.sh
6 files changed, 253 insertions(+), 0 deletions(-)
Approvals:
fixeria: Looks good to me, approved
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/epdg/EPDG_Tests.cfg b/epdg/EPDG_Tests.cfg
index c164293..00be40f 100644
--- a/epdg/EPDG_Tests.cfg
+++ b/epdg/EPDG_Tests.cfg
@@ -12,6 +12,18 @@
[MODULE_PARAMETERS]
+EPDG_Tests.mp_gsup_local_ip := "172.18.3.103"
+EPDG_Tests.mp_swx_local_ip := "172.18.3.103"
+EPDG_Tests.mp_s6b_local_ip := "172.18.3.103"
+EPDG_Tests.mp_s2b_local_ip := "172.18.3.103"
+EPDG_Tests.mp_upf_gtpu_local_ip := "172.18.3.103"
+
+EPDG_Tests.mp_gsup_remote_ip := "172.18.3.20"
+EPDG_Tests.mp_s6b_remote_ip := "172.18.3.20"
+EPDG_Tests.mp_s2b_remote_ip := "172.18.3.20"
+
+# Match (diameter_watchdog_timer/1000)*diameter_watchdog_config["okay"] in
osmo-epdg.config:
+EPDG_Tests.mp_diam_watchdog_initial_wait_sec := 6;
[MAIN_CONTROLLER]
diff --git a/epdg/osmo-epdg.config b/epdg/osmo-epdg.config
new file mode 100644
index 0000000..d8919eb
--- /dev/null
+++ b/epdg/osmo-epdg.config
@@ -0,0 +1,87 @@
+[
+ %% ===========================================
+ %% Application config
+ %% ===========================================
+ {osmo_epdg,
+ [% GSUP Server connection parameters
+ {gsup_local_ip, "172.18.3.20"},
+ {gsup_local_port, 4222},
+ % Diameter Connection parameters
+ {dia_swx_remote_ip, "172.18.3.103"},
+ {dia_swx_remote_port, 3868},
+ {dia_swx_proto, sctp},
+ {dia_swx_connect_timer, 200},
+ {dia_swx_watchdog_timer, 6000},
+ {dia_swx_watchdog_config,
+ [{okay, 1},
+ {suspect, 1}]},
+ {dia_swx_vendor_id, 0},
+ {dia_swx_origin_host, "epdg.localdomain"},
+ {dia_swx_origin_realm, "localdomain"},
+ {dia_swx_context_id, "epdg@localdomain"},
+ % Diameter s6b Connection parameters
+ {dia_s6b_local_ip, "172.18.3.20"},
+ {dia_s6b_local_port, 3869},
+ {dia_s6b_proto, sctp},
+ {dia_s6b_connect_timer, 200},
+ {dia_s6b_watchdog_timer, 6000},
+ {dia_s6b_watchdog_config,
+ [{okay, 1},
+ {suspect, 1}]},
+ {dia_s6b_vendor_id, 0},
+ {dia_s6b_origin_host, "aaa.localdomain"},
+ {dia_s6b_origin_realm, "localdomain"},
+ {dia_s6b_context_id, "aaa@localdomain"},
+ % GTPv2C Connection parameters
+ {gtpc_local_ip, "172.18.3.20"},
+ {gtpc_local_port, 2123},
+ {gtpc_remote_ip, "172.18.3.103"},
+ {gtpc_remote_port, 2123}
+ ]
+ },
+ %% ===========================================
+ %% gtp_u_kmod config
+ %% ===========================================
+ {gtp_u_kmod, [
+ {sockets, [{gtp0, [%% ip: IP Address assigned at the tunnel:
+ {ip, {172,18,3,20}},
+ %% Allow binding to an IP address that is nonlocal or does not
(yet) exist (IP_FREEBIND):
+ freebind,
+ % Create gtp tundev with role SGSN:
+ {role, sgsn}
+ ]
+ }]
+ }
+ ]},
+ %% ===========================================
+ %% gen_socket config
+ %% ===========================================
+ {gen_socket, [
+ {libdir, "@GEN_SOCKET_LIBDIR@"}
+]},
+ %% ===========================================
+ %% Lager logging config
+ %% ===========================================
+ {lager, [
+ {log_root, "/data/"},
+ {colored, true},
+ {handlers,
+ [{lager_console_backend, [{level, debug}]},
+ {lager_file_backend,
+ [{file, "console.log"}, {level, debug}, {size, 104857600}, {date,
"$D0"}, {count, 10}]},
+ {lager_file_backend,
+ [{file, "error.log"}, {level, error}, {size, 104857600}, {date,
"$D0"}, {count, 10}]}]},
+ {crash_log, "crash.log"},
+ {crash_log_msg_size, 65536},
+ {crash_log_size, 104857600},
+ {crash_log_date, "$D0"},
+ {crash_log_count, 10},
+ {error_logger_redirect, true}
+ ]},
+ {kernel, [
+ {logger, [{handler, debug, logger_std_h, % {handler, HandlerId, Module,
+ #{config => #{file => "/data/erlang.log"}}
+ }]
+ }
+ ]}
+].
diff --git a/epdg/testenv.cfg b/epdg/testenv.cfg
new file mode 100644
index 0000000..e8980bd
--- /dev/null
+++ b/epdg/testenv.cfg
@@ -0,0 +1,12 @@
+[testsuite]
+program=EPDG_Tests
+config=EPDG_Tests.cfg
+
+[epdg]
+qemu=required
+program=testenv/run_qemu.sh
+setup=testenv/wait_until_osmo_epdg_is_ready.sh
+clean=EXTRA_IPS="172.18.3.103" add_remove_testenv0_bridge.sh
+make=osmo-epdg
+package=osmo-epdg
+copy=osmo-epdg.config testenv
diff --git a/epdg/testenv/run_osmo_epdg_with_dummy_ue.sh
b/epdg/testenv/run_osmo_epdg_with_dummy_ue.sh
new file mode 100755
index 0000000..93853b8
--- /dev/null
+++ b/epdg/testenv/run_osmo_epdg_with_dummy_ue.sh
@@ -0,0 +1,39 @@
+#!/bin/sh -ex
+EPDG_TUN="gtp0"
+UE_IFACE="ue"
+UE_SUBNET="192.168.0.0/16"
+UE_ADDR="192.168.0.2/16"
+
+ip link add "$UE_IFACE" type dummy
+ip addr add "$UE_ADDR" dev "$UE_IFACE"
+ip link set "$UE_IFACE" up
+ip rule add from "$UE_SUBNET" table 45
+
+ERL_FLAGS='-config osmo-epdg.config' osmo-epdg &
+
+set +x
+
+FOUND=0
+for i in $(seq 1 10); do
+ sleep 1
+ if ip link ls dev "$EPDG_TUN" 2>&1 >/dev/null; then
+ FOUND=1
+ break
+ fi
+done
+
+if [ "$FOUND" = 0 ]; then
+ echo
+ echo "ERROR: run_osmo_epdg_with_dummy_ue.sh: osmo-epdg did not create
$EPDG_TUN!"
+ echo
+ exit 1
+fi
+
+ip route add default dev $EPDG_TUN table 45
+
+echo
+# wait_until_osmo_epdg_is_ready.sh checks for this string
+echo "run_osmo_epdg_with_dummy_ue.sh: osmo-epdg is ready"
+echo
+
+wait
diff --git a/epdg/testenv/run_qemu.sh b/epdg/testenv/run_qemu.sh
new file mode 100755
index 0000000..024e423
--- /dev/null
+++ b/epdg/testenv/run_qemu.sh
@@ -0,0 +1,76 @@
+#!/bin/sh -ex
+GEN_SOCKET_LIBDIR=""
+
+set_gen_socket_libdir() {
+ if [ -z "$OSMO_DEV_MAKE_DIR" ]; then
+ # With --binary-repo
+ GEN_SOCKET_LIBDIR=/usr/lib
+ else
+ # Without --binary-repo
+ GEN_SOCKET_LIBDIR="$OSMO_DEV_MAKE_DIR"/osmo-epdg/default/lib/gen_socket/priv/lib
+ fi
+}
+
+adjust_osmo_epdg_config() {
+ sed -i "s~@GEN_SOCKET_LIBDIR@~$GEN_SOCKET_LIBDIR~" osmo-epdg.config
+}
+
+build_initrd() {
+ qemu_initrd_init
+
+ qemu_initrd_add_mod \
+ dummy \
+ gtp \
+ sctp \
+ tun
+
+ qemu_initrd_add_bin \
+ "$GEN_SOCKET_LIBDIR"/gen_socket.so \
+ "$GEN_SOCKET_LIBDIR"/gen_socket_nif.so \
+ /usr/bin/escript \
+ /usr/lib/x86_64-linux-gnu/libm.so.6 \
+ /usr/lib/x86_64-linux-gnu/libsctp.so.1 \
+ /usr/lib/x86_64-linux-gnu/libstdc++.so.6 \
+ /usr/lib/x86_64-linux-gnu/libtinfo.so.6 \
+ /usr/lib/x86_64-linux-gnu/libz.so.1
+
+ qemu_initrd_add_file \
+ "$(which osmo-epdg)" \
+ /usr/bin/erl \
+ /usr/lib/erlang \
+ osmo-epdg.config \
+ testenv/run_osmo_epdg_with_dummy_ue.sh
+
+ # Enable dynamic_debug
+ qemu_initrd_add_cmd \
+ "mount -t debugfs none /sys/kernel/debug || true" \
+ "echo -n 'module gtp +p' > /sys/kernel/debug/dynamic_debug/control ||
true"
+
+ qemu_initrd_add_cmd \
+ "ip addr add 172.18.3.20/24 brd 172.18.3.255 dev eth0" \
+ "ip route add default via 172.18.3.1 dev eth0" \
+ "sysctl net.ipv4.ip_forward=1" \
+ "sysctl net.ipv4.conf.all.rp_filter=0" \
+ "sysctl net.ipv4.conf.default.rp_filter=0" \
+ "testenv/run_osmo_epdg_with_dummy_ue.sh"
+
+ qemu_initrd_finish
+}
+
+
+# FIXME: when using the debian kernel, osmo-epdg doesn't create the gtp device
+# and then fails with: "terminating ss7_routes with reason shutdownterminating
+# ss7_links with reason shutdownip: can't find device 'gtp0'"
+if [ "$TESTENV_QEMU_KERNEL" = "debian" ]; then
+ set +x
+ echo
+ echo "ERROR: epdg currently only works with -C, --custom-kernel"
+ echo
+ exit 1
+fi
+
+set_gen_socket_libdir
+adjust_osmo_epdg_config
+. qemu_functions.sh
+qemu_build_initrd_with_log_redirect
+qemu_run
diff --git a/epdg/testenv/wait_until_osmo_epdg_is_ready.sh
b/epdg/testenv/wait_until_osmo_epdg_is_ready.sh
new file mode 100755
index 0000000..96f02e3
--- /dev/null
+++ b/epdg/testenv/wait_until_osmo_epdg_is_ready.sh
@@ -0,0 +1,27 @@
+#!/bin/sh -e
+LOGFILE="$(basename "$PWD").log"
+
+# Wait until osmo-epdg is ready and fail early if errors are logged during
+# startup. Otherwise osmo-epdg may keep running and we get less obvious
+# failures later.
+epdg_wait() {
+ i=0
+ for i in $(seq 1 150); do
+ sleep 0.1
+
+ if grep -q "\[error\]" "$LOGFILE"; then
+ # The log output is visible in stdout
+ exit 1
+ fi
+
+ if grep -q "run_osmo_epdg_with_dummy_ue.sh: osmo-epdg is ready"
"$LOGFILE"; then
+ exit 0
+ fi
+ done
+
+ echo "ERROR: wait_until_osmo_epdg_is_ready.sh: osmo-epdg failed to start"
+ exit 1
+}
+
+qemu_wait.sh
+epdg_wait
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40321?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ide2873be7830cc43e7fa09f26b2d504d0563a3c2
Gerrit-Change-Number: 40321
Gerrit-PatchSet: 4
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>