9
0
Fork 0

tests/vty: Add VTY tests to the osmo-stp

There seems to be issues with the write handling of the osmo-stp
and so far we did not enable vty tests here. Make it possible to
enable the tests, fix the VTY strings, change string to OsmoSTP.

Change-Id: I547fd4840d86ce16e8589fb63802dd7099781194
This commit is contained in:
Holger Hans Peter Freyther 2016-08-15 11:54:24 +02:00
parent b1d46b4488
commit 368e549a92
9 changed files with 121 additions and 22 deletions

1
.gitignore vendored
View File

@ -23,6 +23,7 @@ stamp-h1
*.gcda
*.gcno
*.info
*.pyc
# binaries
cellmgr_ng

View File

@ -28,6 +28,21 @@ PKG_CHECK_MODULES([LIBOSMOSCCP], [libosmo-sccp])
PKG_CHECK_MODULES([LIBOSMOVTY], [libosmovty >= 0.3.2])
#PKG_CHECK_MODULES([NEXUSWARE_C7], [nexusware-c7])
AC_ARG_ENABLE([external_tests],
AC_HELP_STRING([--enable-external-tests],
[Include the VTY tests in make check [default=no]]),
[enable_ext_tests="$enableval"],[enable_ext_tests="no"])
if test "x$enable_ext_tests" = "xyes" ; then
AM_PATH_PYTHON
AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
AC_MSG_ERROR([Please install osmocom-python to run the VTY tests.])
fi
fi
AC_MSG_CHECKING([whether to enable VTY tests])
AC_MSG_RESULT([$enable_ext_tests])
AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
old_libs=$LIBS
AC_CHECK_LIB([sctp], sctp_sendmsg, [], [AC_MSG_ERROR([The sctp library is required.])])
LIBS=$old_libs

View File

@ -36,6 +36,6 @@ PKG_CONFIG_PATH=$PWD/..//install/lib/pkgconfig $MAKE $PARALLEL_MAKE install
cd ../../
autoreconf --install --force
PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig ./configure
PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig ./configure --enable-external-tests
PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig $MAKE $PARALLEL_MAKE
PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig LD_LIBRARY_PATH=$PWD/deps/install/lib $MAKE distcheck

41
doc/examples/osmo-stp.cfg Normal file
View File

@ -0,0 +1,41 @@
ss7
udp src-port 4444
m2ua src-port 5555
linkset 0
description My first linkset
mtp3 dpc 1
mtp3 opc 2
mtp3 ni 3
link 0
description A m2ua link
ss7-transport m2ua
linkset 1
description My m3ua linkset
mtp3 dpc 1
mtp3 opc 2
mtp3 ni 3
mtp3 spare 0
link 0
description A m3ua client
ss7-transport m3ua-client
msc 0
mode server
port 5000
token atoken
msc 1
mode server
port 5001
token atoken
timeout ping 20
timeout pong 5
timeout restart 3
application 0
description Relay TCP/IPA to M2UA linkset
type relay
route linkset 0 msc 0
forward-only
application 1
description Relay TCP/IPA to M3UA linkset
type relay
route linkset 1 msc 1
forward-only

27
osmoappdesc.py Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env python
# (C) 2016 by Holger Hans Peter Freyther
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
app_configs = {
"osmo-stp": ["doc/examples/osmo-stp.cfg"]
}
apps = [(4242, "src/osmo-stp", "OsmoSTP", "osmo-stp"),
]
vty_command = ["src/osmo-stp", "-c", "doc/examples/osmo-stp.cfg"]
vty_app = apps[0]

View File

@ -388,6 +388,10 @@ struct mtp_m3ua_client_link *mtp_m3ua_client_link_init(struct mtp_link *blnk)
lnk->queue.bfd.fd = -1;
lnk->traffic_mode = 2;
lnk->aspac_ack_timeout = 10;
/* default ports */
lnk->local.sin_port = lnk->remote.sin_port = htons(2905);
return lnk;
}

View File

@ -103,7 +103,7 @@ DEFUN(node_end, node_end_cmd,
}
static struct vty_app_info vty_info = {
.name = "Cellmgr-ng",
.name = "OsmoSTP",
.version = VERSION,
.go_parent_cb = ss7_go_parent,
};
@ -155,13 +155,13 @@ static int config_write_ss7(struct vty *vty)
static void write_link(struct vty *vty, struct mtp_link *link)
{
const char *name = link->name ? link->name : "";
struct mtp_udp_link *ulnk;
struct mtp_m2ua_link *m2ua;
struct mtp_m3ua_client_link *m3ua_client;
vty_out(vty, " link %d%s", link->nr, VTY_NEWLINE);
vty_out(vty, " description %s%s", name, VTY_NEWLINE);
if (link->name && strlen(link->name) > 0)
vty_out(vty, " description %s%s", link->name, VTY_NEWLINE);
switch (link->type) {
case SS7_LTYPE_UDP:
@ -214,12 +214,12 @@ static void write_link(struct vty *vty, struct mtp_link *link)
static void write_linkset(struct vty *vty, struct mtp_link_set *set)
{
const char *name = set->name ? set->name : "";
struct mtp_link *link;
int i;
vty_out(vty, " linkset %d%s", set->nr, VTY_NEWLINE);
vty_out(vty, " description %s%s", name, VTY_NEWLINE);
if (set->name && strlen(set->name) > 0)
vty_out(vty, " description %s%s", set->name, VTY_NEWLINE);
vty_out(vty, " mtp3 dpc %d%s", set->dpc, VTY_NEWLINE);
vty_out(vty, " mtp3 opc %d%s", set->opc, VTY_NEWLINE);
vty_out(vty, " mtp3 ni %d%s", set->ni, VTY_NEWLINE);
@ -260,18 +260,20 @@ static int config_write_linkset(struct vty *vty)
static void write_msc(struct vty *vty, struct msc_connection *msc)
{
const char *name = msc->name ? msc->name : "";
vty_out(vty, " msc %d%s", msc->nr, VTY_NEWLINE);
vty_out(vty, " description %s%s", name, VTY_NEWLINE);
if (msc->name && strlen(msc->name) > 0)
vty_out(vty, " description %s%s", msc->name, VTY_NEWLINE);
vty_out(vty, " mode %s%s", msc_mode(msc), VTY_NEWLINE);
if (msc->ip)
vty_out(vty, " ip %s%s", msc->ip, VTY_NEWLINE);
vty_out(vty, " port %d%s", msc->port, VTY_NEWLINE);
vty_out(vty, " token %s%s", msc->token, VTY_NEWLINE);
vty_out(vty, " dscp %d%s", msc->dscp, VTY_NEWLINE);
if (msc->ping_time > 0) {
vty_out(vty, " timeout ping %d%s", msc->ping_time, VTY_NEWLINE);
vty_out(vty, " timeout pong %d%s", msc->pong_time, VTY_NEWLINE);
}
vty_out(vty, " timeout restart %d%s", msc->msc_time, VTY_NEWLINE);
}
@ -316,10 +318,9 @@ static const char *link_type(enum ss7_set_type type)
static void write_application(struct vty *vty, struct ss7_application *app)
{
const char *name = app->name ? app->name : "";
vty_out(vty, " application %d%s", app->nr, VTY_NEWLINE);
vty_out(vty, " description %s%s", name, VTY_NEWLINE);
if (app->name && strlen(app->name) > 0)
vty_out(vty, " description %s%s", app->name, VTY_NEWLINE);
vty_out(vty, " type %s%s", app_type(app->type), VTY_NEWLINE);
if (app->fixed_ass_cmpl_reply)
@ -463,7 +464,7 @@ DEFUN(cfg_linkset_mtp3_ssn, cfg_linkset_mtp3_ssn_cmd,
DEFUN(cfg_linkset_no_mtp3_ssn, cfg_linkset_no_mtp3_ssn_cmd,
"no mtp3 ssn <0-255>",
"MTP Level3\n" "SSN supported\n" "SSN\n")
NO_STR "MTP Level3\n" "SSN supported\n" "SSN\n")
{
struct mtp_link_set *set = vty->index;
set->supported_ssn[atoi(argv[0])] = 0;
@ -604,7 +605,7 @@ DEFUN(cfg_linkset_link, cfg_linkset_link_cmd,
DEFUN(cfg_link_ss7_transport, cfg_link_ss7_transport_cmd,
"ss7-transport (none|udp|m2ua|m3ua-client)",
"SS7 transport for the link\n"
"No transport\n" "MTP over UDP\n" "SCTP M2UA\n")
"No transport\n" "MTP over UDP\n" "SCTP M2UA server\n" "SCTP M3UA client\n")
{
int wanted = SS7_LTYPE_NONE;
struct mtp_link *link;
@ -648,7 +649,7 @@ DEFUN(cfg_link_ss7_transport, cfg_link_ss7_transport_cmd,
DEFUN(cfg_link_udp_dest_ip, cfg_link_udp_dest_ip_cmd,
"udp dest ip HOST_NAME",
"UDP Transport\n" "IP\n" "Hostname\n")
"UDP Transport\n" "Destination\n" "IP\n" "Hostname\n")
{
struct hostent *hosts;
@ -684,7 +685,7 @@ DEFUN(cfg_link_udp_dest_ip, cfg_link_udp_dest_ip_cmd,
DEFUN(cfg_link_udp_dest_port, cfg_link_udp_dest_port_cmd,
"udp dest port <1-65535>",
"UDP Transport\n" "Set the port number\n" "Port\n")
"UDP Transport\n" "Destination\n" "Set the port number\n" "Port\n")
{
struct mtp_link *link = vty->index;
struct mtp_udp_link *ulnk;
@ -896,7 +897,7 @@ DEFUN(cfg_link_m3ua_client_routing_ctx, cfg_link_m3ua_client_routing_ctx_cmd,
DEFUN(cfg_link_m3ua_client_traffic_mode, cfg_link_m3ua_client_traffic_mode_cmd,
"m3ua-client traffic-mode (override|loadshare|broadcast)",
"M3UA Client\n" "Traffic Mode\n" "Override" "Loadshare\n" "Broadcast\n")
"M3UA Client\n" "Traffic Mode\n" "Override\n" "Loadshare\n" "Broadcast\n")
{
struct mtp_link *link = vty->index;
struct mtp_m3ua_client_link *m3ua_link;
@ -1047,7 +1048,7 @@ DEFUN(cfg_msc_timeout_pong, cfg_msc_timeout_pong_cmd,
}
DEFUN(cfg_msc_timeout_restart, cfg_msc_timeout_restart_cmd,
"timeout restart <1-65535>",
"timeout restart <0-65535>",
"Timeout commands\n" "Time between restarts\n" "Seconds\n")
{
struct msc_connection *msc = vty->index;
@ -1306,7 +1307,7 @@ DEFUN(cfg_app_hardcode_ass, cfg_app_hardcode_ass_cmd,
DEFUN(cfg_app_no_hardcode_ass, cfg_app_no_hardcode_ass_cmd,
"no hardcode-assignment-complete",
"Hardcode the assignment complete message to HR3\n")
NO_STR "Hardcode the assignment complete message to HR3\n")
{
struct ss7_application *app = vty->index;
app->fixed_ass_cmpl_reply = 0;

View File

@ -280,7 +280,7 @@ DEFUN(allow_inject, allow_inject_cmd,
DEFUN(show_sctp_count, show_sctp_count_cmd,
"show sctp-connections count",
SHOW_STR "Number of SCTP connections\n")
SHOW_STR "SCTP connections\n" "Number of connections\n")
{
int count = sctp_m2ua_conn_count(bsc->m2ua_trans);
vty_out(vty, "Active SCTP connections are: %d.%s", count, VTY_NEWLINE);
@ -289,7 +289,7 @@ DEFUN(show_sctp_count, show_sctp_count_cmd,
DEFUN(show_sctp_details, show_sctp_details_cmd,
"show sctp-connections details",
SHOW_STR "Details of SCTP connections\n")
SHOW_STR "SCTP connections\n" "Details\n")
{
struct sctp_m2ua_conn *conn;

View File

@ -21,8 +21,18 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE)
TESTSUITE = $(srcdir)/testsuite
if ENABLE_EXT_TESTS
python-tests: $(BUILT_SOURCES)
osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v
else
python-tests: $(BUILT_SOURCES)
echo "Not running python-based tests (determined at configure-time)"
endif
check-local: atconfig $(TESTSUITE)
$(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
$(MAKE) $(AM_MAKEFLAGS) python-tests
installcheck-local: atconfig $(TESTSUITE)
$(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \