aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tdef/tdef_vty_test_dynamic.vty
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-01-26 20:36:12 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2019-02-04 18:52:16 +0100
commit0fd615fd7b701fc0b3fd7f96429691e3eaa5a877 (patch)
tree7c2885199ce93394c308e3399b4d76d843416505 /tests/tdef/tdef_vty_test_dynamic.vty
parent44c15b7a8fadff949e79be0b843ec9caca61901c (diff)
add osmo_tdef API, originally adopted from osmo-bsc T_def
Move T_def from osmo-bsc to libosmocore as osmo_tdef. Adjust naming to be more consistent. Upgrade to first class API: - add timer grouping - add generic vty support - add mising API doc - add C test - add VTY transcript tests, also as examples for using the API From osmo_fsm_inst_state_chg() API doc, cross reference to osmo_tdef API. The root reason for moving to libosmocore is that I want to use the mgw_endpoint_fsm in osmo-msc for inter-MSC handover, and hence want to move the FSM to libosmo-mgcp-client. This FSM uses the T_def from osmo-bsc. Though the mgw_endpoint_fsm's use of T_def is minimal, I intend to use the osmo_tdef API in osmo-msc (and probably elsewhere) as well. libosmocore is the most sensible place for this. osmo_tdef provides: - a list of Tnnnn (GSM) timers with description, unit and default value. - vty UI to allow users to configure non-default timeouts. - API to tie T timers to osmo_fsm states and set them on state transitions. - a few standard units (minute, second, millisecond) as well as a custom unit (which relies on the timer's human readable description to indicate the meaning of the value). - conversion for standard units: for example, some GSM timers are defined in minutes, while our FSM definitions need timeouts in seconds. Conversion is for convenience only and can be easily avoided via the custom unit. By keeping separate osmo_tdef arrays, several groups of timers can be kept separately. The VTY tests in tests/tdef/ showcase different schemes: - tests/vty/tdef_vty_test_config_root.c: Keep several timer definitions in separately named groups: showcase the osmo_tdef_vty_groups*() API. Each timer group exists exactly once. - tests/vty/tdef_vty_test_config_subnode.c: Keep a single list of timers without separate grouping. Put this list on a specific subnode below the CONFIG_NODE. There could be several separate subnodes with timers like this, i.e. continuing from this example, sets timers could be separated by placing timers in specific config subnodes instead of using the global group name. - tests/vty/tdef_vty_test_dynamic.c: Dynamically allocate timer definitions per each new created object. Thus there can be an arbitrary number of independent timer definitions, one per allocated object. T_def was introduced during the recent osmo-bsc refactoring for inter-BSC handover, and has proven useful: - without osmo_tdef, each invocation of osmo_fsm_inst_state_chg() needs to be programmed with the right timeout value, for all code paths that invoke this state change. It is a likely source of errors to get one of them wrong. By defining a T timer exactly for an FSM state, the caller can merely invoke the state change and trust on the original state definition to apply the correct timeout. - it is helpful to have a standardized config file UI to provide user configurable timeouts, instead of inventing new VTY commands for each separate application of T timer numbers. Change-Id: Ibd6b1ed7f1bd6e1f2e0fde53352055a4468f23e5
Diffstat (limited to 'tests/tdef/tdef_vty_test_dynamic.vty')
-rw-r--r--tests/tdef/tdef_vty_test_dynamic.vty83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/tdef/tdef_vty_test_dynamic.vty b/tests/tdef/tdef_vty_test_dynamic.vty
new file mode 100644
index 00000000..6aae746b
--- /dev/null
+++ b/tests/tdef/tdef_vty_test_dynamic.vty
@@ -0,0 +1,83 @@
+tdef_vty_test> list
+...
+ show member-timer [NAME] [TNNNN]
+...
+
+tdef_vty_test> enable
+tdef_vty_test# configure terminal
+
+tdef_vty_test(config)# member robin
+tdef_vty_test(config-member)# timer
+ robin: T1111 = 2 s Dynamic Duo (default: 2 s)
+ robin: T2222 = 1 s BATMAN (default: 1 s)
+ robin: T3333 = 12 s Dadadadadadadadadadadada (default: 12 s)
+ robin: T4444 = 500 ms POW! (default: 500 ms)
+
+tdef_vty_test(config-member)# timer T2222 423
+tdef_vty_test(config-member)# timer T2222
+ robin: T2222 = 423 s BATMAN (default: 1 s)
+
+tdef_vty_test(config-member)# timer
+ robin: T1111 = 2 s Dynamic Duo (default: 2 s)
+ robin: T2222 = 423 s BATMAN (default: 1 s)
+ robin: T3333 = 12 s Dadadadadadadadadadadada (default: 12 s)
+ robin: T4444 = 500 ms POW! (default: 500 ms)
+
+tdef_vty_test(config-member)# do show member-timer
+ robin: T1111 = 2 s Dynamic Duo (default: 2 s)
+ robin: T2222 = 423 s BATMAN (default: 1 s)
+ robin: T3333 = 12 s Dadadadadadadadadadadada (default: 12 s)
+ robin: T4444 = 500 ms POW! (default: 500 ms)
+
+tdef_vty_test(config-member)# exit
+
+tdef_vty_test(config)# member batman
+tdef_vty_test(config-member)# timer 3333 17
+tdef_vty_test(config-member)# timer 3333
+ batman: T3333 = 17 s Dadadadadadadadadadadada (default: 12 s)
+
+tdef_vty_test(config-member)# show running-config
+
+Current configuration:
+...
+member robin
+ timer T2222 423
+member batman
+ timer T3333 17
+...
+
+tdef_vty_test(config-member)# timer 3333 default
+
+tdef_vty_test(config-member)# show running-config
+...
+member robin
+ timer T2222 423
+member batman
+... !timer
+
+tdef_vty_test(config-member)# exit
+tdef_vty_test(config)# exit
+tdef_vty_test# show member-timer
+ robin: T1111 = 2 s Dynamic Duo (default: 2 s)
+ robin: T2222 = 423 s BATMAN (default: 1 s)
+ robin: T3333 = 12 s Dadadadadadadadadadadada (default: 12 s)
+ robin: T4444 = 500 ms POW! (default: 500 ms)
+ batman: T1111 = 2 s Dynamic Duo (default: 2 s)
+ batman: T2222 = 1 s BATMAN (default: 1 s)
+ batman: T3333 = 12 s Dadadadadadadadadadadada (default: 12 s)
+ batman: T4444 = 500 ms POW! (default: 500 ms)
+
+tdef_vty_test# show member-timer batman
+ batman: T1111 = 2 s Dynamic Duo (default: 2 s)
+ batman: T2222 = 1 s BATMAN (default: 1 s)
+ batman: T3333 = 12 s Dadadadadadadadadadadada (default: 12 s)
+ batman: T4444 = 500 ms POW! (default: 500 ms)
+
+tdef_vty_test# show member-timer robin
+ robin: T1111 = 2 s Dynamic Duo (default: 2 s)
+ robin: T2222 = 423 s BATMAN (default: 1 s)
+ robin: T3333 = 12 s Dadadadadadadadadadadada (default: 12 s)
+ robin: T4444 = 500 ms POW! (default: 500 ms)
+
+tdef_vty_test# show member-timer joker
+% No such member: joker