Message ID | 20190711154604.3781-1-vdasari@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [ovs-dev] ovs-macros: An option to suspend test execution on error | expand |
On Thu, Jul 11, 2019 at 11:46:04AM -0400, Vasu Dasari wrote: > Origins for this patch are captured at > https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048923.html. > > Summarizing here, when a test fails, it would be good to pause test execution > and let the developer poke around the system to see current status of system. > > As part of this patch, made a small tweaks to ovs-macros.at, so that when test > suite fails, ovs_on_exit() function will be called. And in this function, a check > is made to see if an environment variable to OVS_PAUSE_TEST is set. If it is > set, then test suite is paused and will continue to wait for user input > Ctrl-D. Meanwhile user can poke around the system to see why test case has > failed. Once done with investigation, user can press ctrl-d to cleanup the > test suite. > > For example, to re-run test case 139: > > export OVS_PAUSE_TEST=1 > cd tests/system-userspace-testsuite.dir/139 > sudo -E ./run Seems like a reasonable idea. The following replies on GNU extensions to "read" and to "printf". I'd just substitute a plain "read", so that the user can just push Enter to continue. > + while read -s -n 1 key; do > + printf -v keycode "%d" "'$key" > + [ $keycode -ne 4 ] || break > + done
Thanks. Will do. *Vasu Dasari* On Fri, Jul 12, 2019 at 11:43 AM Ben Pfaff <blp@ovn.org> wrote: > On Thu, Jul 11, 2019 at 11:46:04AM -0400, Vasu Dasari wrote: > > Origins for this patch are captured at > > https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048923.html > . > > > > Summarizing here, when a test fails, it would be good to pause test > execution > > and let the developer poke around the system to see current status of > system. > > > > As part of this patch, made a small tweaks to ovs-macros.at, so that > when test > > suite fails, ovs_on_exit() function will be called. And in this > function, a check > > is made to see if an environment variable to OVS_PAUSE_TEST is set. If > it is > > set, then test suite is paused and will continue to wait for user input > > Ctrl-D. Meanwhile user can poke around the system to see why test case > has > > failed. Once done with investigation, user can press ctrl-d to cleanup > the > > test suite. > > > > For example, to re-run test case 139: > > > > export OVS_PAUSE_TEST=1 > > cd tests/system-userspace-testsuite.dir/139 > > sudo -E ./run > > Seems like a reasonable idea. > > The following replies on GNU extensions to "read" and to "printf". I'd > just substitute a plain "read", so that the user can just push Enter to > continue. > > > + while read -s -n 1 key; do > > + printf -v keycode "%d" "'$key" > > + [ $keycode -ne 4 ] || break > > + done >
Thanks. I see I wrote "replies" below when I meant "relies". (Maybe that was obvious.) On Fri, Jul 12, 2019 at 11:45:11AM -0400, Vasu Dasari wrote: > Thanks. Will do. > > *Vasu Dasari* > > > On Fri, Jul 12, 2019 at 11:43 AM Ben Pfaff <blp@ovn.org> wrote: > > > On Thu, Jul 11, 2019 at 11:46:04AM -0400, Vasu Dasari wrote: > > > Origins for this patch are captured at > > > https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048923.html > > . > > > > > > Summarizing here, when a test fails, it would be good to pause test > > execution > > > and let the developer poke around the system to see current status of > > system. > > > > > > As part of this patch, made a small tweaks to ovs-macros.at, so that > > when test > > > suite fails, ovs_on_exit() function will be called. And in this > > function, a check > > > is made to see if an environment variable to OVS_PAUSE_TEST is set. If > > it is > > > set, then test suite is paused and will continue to wait for user input > > > Ctrl-D. Meanwhile user can poke around the system to see why test case > > has > > > failed. Once done with investigation, user can press ctrl-d to cleanup > > the > > > test suite. > > > > > > For example, to re-run test case 139: > > > > > > export OVS_PAUSE_TEST=1 > > > cd tests/system-userspace-testsuite.dir/139 > > > sudo -E ./run > > > > Seems like a reasonable idea. > > > > The following replies on GNU extensions to "read" and to "printf". I'd > > just substitute a plain "read", so that the user can just push Enter to > > continue. > > > > > + while read -s -n 1 key; do > > > + printf -v keycode "%d" "'$key" > > > + [ $keycode -ne 4 ] || break > > > + done > >
On Fri, Jul 12, 2019 at 08:42:51AM -0700, Ben Pfaff wrote: > On Thu, Jul 11, 2019 at 11:46:04AM -0400, Vasu Dasari wrote: > > Origins for this patch are captured at > > https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048923.html. > > > > Summarizing here, when a test fails, it would be good to pause test execution > > and let the developer poke around the system to see current status of system. > > > > As part of this patch, made a small tweaks to ovs-macros.at, so that when test > > suite fails, ovs_on_exit() function will be called. And in this function, a check > > is made to see if an environment variable to OVS_PAUSE_TEST is set. If it is > > set, then test suite is paused and will continue to wait for user input > > Ctrl-D. Meanwhile user can poke around the system to see why test case has > > failed. Once done with investigation, user can press ctrl-d to cleanup the > > test suite. > > > > For example, to re-run test case 139: > > > > export OVS_PAUSE_TEST=1 > > cd tests/system-userspace-testsuite.dir/139 > > sudo -E ./run > > Seems like a reasonable idea. > > The following replies on GNU extensions to "read" and to "printf". I'd > just substitute a plain "read", so that the user can just push Enter to > continue. Oh, also I'd add a note about this feature to Documentation/topics/testing.rst.
Sure. Will do. *Vasu Dasari* On Fri, Jul 12, 2019 at 12:08 PM Ben Pfaff <blp@ovn.org> wrote: > On Fri, Jul 12, 2019 at 08:42:51AM -0700, Ben Pfaff wrote: > > On Thu, Jul 11, 2019 at 11:46:04AM -0400, Vasu Dasari wrote: > > > Origins for this patch are captured at > > > > https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048923.html. > > > > > > Summarizing here, when a test fails, it would be good to pause test > execution > > > and let the developer poke around the system to see current status of > system. > > > > > > As part of this patch, made a small tweaks to ovs-macros.at, so that > when test > > > suite fails, ovs_on_exit() function will be called. And in this > function, a check > > > is made to see if an environment variable to OVS_PAUSE_TEST is set. If > it is > > > set, then test suite is paused and will continue to wait for user input > > > Ctrl-D. Meanwhile user can poke around the system to see why test case > has > > > failed. Once done with investigation, user can press ctrl-d to cleanup > the > > > test suite. > > > > > > For example, to re-run test case 139: > > > > > > export OVS_PAUSE_TEST=1 > > > cd tests/system-userspace-testsuite.dir/139 > > > sudo -E ./run > > > > Seems like a reasonable idea. > > > > The following replies on GNU extensions to "read" and to "printf". I'd > > just substitute a plain "read", so that the user can just push Enter to > > continue. > > Oh, also I'd add a note about this feature to > Documentation/topics/testing.rst. >
diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 10593429d..57617a410 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -35,11 +35,36 @@ m4_divert_push([PREPARE_TESTS]) # directory. ovs_init() { ovs_base=`pwd` - trap '. "$ovs_base/cleanup"' 0 + trap ovs_on_exit 0 : > cleanup ovs_setenv } +# Catch testsuite error condition and cleanup test environment by tearing down +# all interfaces and processes spawned. +# User has an option to leave the test environment in error state so that system +# can be poked around to get more information. User can enable this option by setting +# environment variable OVS_PAUSE_TEST=1. User needs to press CTRL-D to resume the +# cleanup operation. +ovs_pause() { + echo "=====================================================" + echo "Set environment variable to use various ovs utilities" + echo "export OVS_RUNDIR=$ovs_base" + echo "Press ctrl-d to continue:" + while read -s -n 1 key; do + printf -v keycode "%d" "'$key" + [ $keycode -ne 4 ] || break + done +} + +ovs_on_exit () { + if [ ! -z "${OVS_PAUSE_TEST}" ]; then + trap '' INT + ovs_pause + fi + . "$ovs_base/cleanup" +} + # With no parameter or an empty parameter, sets the OVS_*DIR # environment variables to point to $ovs_base, the base directory in # which the test is running.
Origins for this patch are captured at https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048923.html. Summarizing here, when a test fails, it would be good to pause test execution and let the developer poke around the system to see current status of system. As part of this patch, made a small tweaks to ovs-macros.at, so that when test suite fails, ovs_on_exit() function will be called. And in this function, a check is made to see if an environment variable to OVS_PAUSE_TEST is set. If it is set, then test suite is paused and will continue to wait for user input Ctrl-D. Meanwhile user can poke around the system to see why test case has failed. Once done with investigation, user can press ctrl-d to cleanup the test suite. For example, to re-run test case 139: export OVS_PAUSE_TEST=1 cd tests/system-userspace-testsuite.dir/139 sudo -E ./run When error occurs, above command would display something like this: ===================================================== Set environment variable to use various ovs utilities export OVS_RUNDIR=/opt/vdasari/Developer/ovs/_build-gcc/tests/system-userspace-testsuite.dir/139 Press ctrl-d to continue: ===================================================== And from another window, one can execute ovs-xxx commands like: export OVS_RUNDIR=/opt/vdasari/Developer/ovs/_build-gcc/tests/system-userspace-testsuite.dir/139 $ ovs-ofctl dump-ports br0 . . Signed-off-by: Vasu Dasari <vdasari@gmail.com> --- tests/ovs-macros.at | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)